Skip to contentSkip to conversation

selftests: mptcp: add close function in main_loop_s function

PATCH In review Matthieu Baerts (NGI0) 2 participants 3 messages Jul 1, 2024

Subsystems (3)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

PATCH 1/1 selftests: mptcp: add close function in main_loop_s function

From: Liu Jing <[email protected]>

in main_loop_s function, when open(cfg_input, O_RDONLY),When the open(cfg_input, O_RDONLY) function is run, the last fd file descriptor is not closed if the if (--cfg_repeat > 0) branch is not taken

---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -1
index d2043ec3bf6d..48b7389ae75b 100644
@@ -1119,7 +1119,8 @@ int main_loop_s(int listensock)
 		if (cfg_input)
 			close(fd);
 		goto again;
-	}
+	} else
+		close(fd);
 
 	return 0;
 }
Signature · 1 line
2.45.2
author maintainer
#1 lore raw

Hi Liu Jing,

Thank you for this patch.

I have some comments, please see below. Can you send a v2 please?

Please send such patches to MPTCP mailing list, as mentioned in the MAINTAINERS file: for us to be able to track and review these patches. And for our CI to validate them.

Quoted 3 lines · On 01/07/2024 20:16, Matthieu Baerts (NGI0) wrote:

From: Liu Jing <[email protected]>

in main_loop_s function, when open(cfg_input, O_RDONLY),When the open(cfg_input, O_RDONLY) function is run,

"when open(cfg_input, O_RDONLY)" is duplicated.

Quoted 1 line

the last fd file descriptor is not closed if the if (--cfg_repeat > 0) branch is not taken

Could you limit the lines to max 72 chars for the description and around ~50 for the title please?

selftests: mptcp: always close input's FD if opened

Also, it looks like it is a bug-fix. Then please add a 'Fixes' tag, e.g.:

Fixes 05be5e273c84 ("selftests: mptcp: add disconnect tests")
Quoted 2 lines

(In your v2, please drop my SoB that has been automatically added when sending this patch to our ML)

Quoted 9 lines
---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +0 -0
index d2043ec3bf6d..48b7389ae75b 100644

tools/testing/selftests/net/mptcp/mptcp_connect.c int main_loop_s(int listensock) · line 1123

Quoted 6 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -1
@@ -1119,7 +1119,8 @@ int main_loop_s(int listensock)
 		if (cfg_input)
 			 close(fd);
 		goto again;
-	}
+	} else
+		close(fd);

I think it would be clearer to move...

  if (cfg_input)
          close(fd);

... before 'if (--cfg_repeat > 0)' (with an empty line in between): so first we 'close(fd)' if needed, then we check if we need to do it again.

Note: Please run 'checkpatch.pl': it was complaining about this line:

https://github.com/multipath-tcp/mptcp_net-next/actions/runs/9749324582

https://docs.kernel.org/process/5.Posting.html

tools/testing/selftests/net/mptcp/mptcp_connect.c int main_loop_s(int listensock) · line 1126

Quoted 3 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +0 -0
 	return 0;
 }

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#2 lore raw
In reply to Matthieu Baerts (NGI0)

Hi Liu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/9749324571

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/27aea1e315d8
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=867250

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)