Message ID | 20250113085228.121778-3-liucong2@kylinos.cn (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Geliang Tang |
Headers | show |
Series | selftests: mptcp: Fix various issues in main_loop | expand |
Context | Check | Description |
---|---|---|
matttbe/build | success | Build and static analysis OK |
matttbe/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 20 lines checked |
matttbe/shellcheck | success | MPTCP selftests files have not been modified |
matttbe/KVM_Validation__normal | success | Success! ✅ |
matttbe/KVM_Validation__debug | success | Success! ✅ |
matttbe/KVM_Validation__btf-normal__only_bpftest_all_ | success | Success! ✅ |
matttbe/KVM_Validation__btf-debug__only_bpftest_all_ | warning | Unstable: 1 failed test(s): bpftest_test_progs_mptcp |
cc mptcp only. On Mon, 2025-01-13 at 16:52 +0800, Cong Liu wrote: > When both cfg_input and cfg_sockopt_types.mptfo are set, the input > file > descriptor (fd_in) is opened before the reconnection loop but closed > within the loop. However, when mptfo is enabled, the descriptor is > not > reopened in the loop, causing subsequent iterations to use an invalid > file descriptor. > > Move the file open operation into the loop to ensure fd_in is always > valid when needed, regardless of mptfo setting. > > Signed-off-by: Cong Liu <liucong2@kylinos.cn> > --- > tools/testing/selftests/net/mptcp/mptcp_connect.c | 8 +------- > 1 file changed, 1 insertion(+), 7 deletions(-) > > diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c > b/tools/testing/selftests/net/mptcp/mptcp_connect.c > index 31f4c5618569..4d4ea4627daa 100644 > --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c > +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c > @@ -1247,12 +1247,6 @@ int main_loop(void) > struct addrinfo *peer; > struct wstate winfo; > > - if (cfg_input && cfg_sockopt_types.mptfo) { > - fd_in = open(cfg_input, O_RDONLY); > - if (fd_in < 0) > - xerror("can't open %s:%d", cfg_input, > errno); > - } > - > memset(&winfo, 0, sizeof(winfo)); > fd = sock_connect_mptcp(cfg_host, cfg_port, cfg_sock_proto, > &peer, fd_in, &winfo); Is this 'fd_in' here valid if the previous 'fd_in = open(cfg_input, O_RDONLY);' is deleted? > if (fd < 0) > @@ -1270,7 +1264,7 @@ int main_loop(void) > if (cfg_cmsg_types.cmsg_enabled) > apply_cmsg_types(fd, &cfg_cmsg_types); > > - if (cfg_input && !cfg_sockopt_types.mptfo) { > + if (cfg_input) { > fd_in = open(cfg_input, O_RDONLY); > if (fd_in < 0) > xerror("can't open %s:%d", cfg_input, > errno);
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c index 31f4c5618569..4d4ea4627daa 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -1247,12 +1247,6 @@ int main_loop(void) struct addrinfo *peer; struct wstate winfo; - if (cfg_input && cfg_sockopt_types.mptfo) { - fd_in = open(cfg_input, O_RDONLY); - if (fd_in < 0) - xerror("can't open %s:%d", cfg_input, errno); - } - memset(&winfo, 0, sizeof(winfo)); fd = sock_connect_mptcp(cfg_host, cfg_port, cfg_sock_proto, &peer, fd_in, &winfo); if (fd < 0) @@ -1270,7 +1264,7 @@ int main_loop(void) if (cfg_cmsg_types.cmsg_enabled) apply_cmsg_types(fd, &cfg_cmsg_types); - if (cfg_input && !cfg_sockopt_types.mptfo) { + if (cfg_input) { fd_in = open(cfg_input, O_RDONLY); if (fd_in < 0) xerror("can't open %s:%d", cfg_input, errno);
When both cfg_input and cfg_sockopt_types.mptfo are set, the input file descriptor (fd_in) is opened before the reconnection loop but closed within the loop. However, when mptfo is enabled, the descriptor is not reopened in the loop, causing subsequent iterations to use an invalid file descriptor. Move the file open operation into the loop to ensure fd_in is always valid when needed, regardless of mptfo setting. Signed-off-by: Cong Liu <liucong2@kylinos.cn> --- tools/testing/selftests/net/mptcp/mptcp_connect.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)