Skip to contentSkip to conversation

selftests: net: lib: kill PIDs before del netns

PATCH In review Matthieu Baerts (NGI0) 3 participants 5 messages Aug 2, 2024

Subsystems (3)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

PATCH 1/1 selftests: net: lib: kill PIDs before del netns

When deleting netns, it is possible to still have some tasks running, e.g. background tasks like tcpdump running in the background, not stopped because the test has been interrupted.

Before deleting the netns, it is then safer to kill all attached PIDs, if any. That should reduce some noises after the end of some tests, and help with the debugging of some issues. That's why this modification is seen as a "fix".

Fixes 25ae948b4478 ("selftests/net: add lib.sh")
---
 tools/testing/selftests/net/lib.sh | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/net/lib.sh +1 -0
index d0219032f773..8ee4489238ca 100644
@@ -146,6 +146,7 @@ cleanup_ns()
 
 	for ns in "$@"; do
 		[ -z "${ns}" ] && continue
+		ip netns pids "${ns}" 2> /dev/null | xargs -r kill || true
 		ip netns delete "${ns}" &> /dev/null || true
 		if ! busywait $BUSYWAIT_TIMEOUT ip netns list \| grep -vq "^$ns$" &> /dev/null; then
 			echo "Warn: Failed to remove namespace $ns"

---
base-commit: 3b0e1975962a388844508be0b3e61e759837fa3e
change-id: 20240802-selftests-net-lib-cleanup-kill-f546a233572e

Best regards,

Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
#1 lore raw

Hi Matthieu,

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/10217280630

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

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)

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Matthieu Baerts (NGI0)
Quoted 9 lines · On Fri, 2 Aug 2024, Matthieu Baerts (NGI0) wrote:

When deleting netns, it is possible to still have some tasks running, e.g. background tasks like tcpdump running in the background, not stopped because the test has been interrupted.

Before deleting the netns, it is then safer to kill all attached PIDs, if any. That should reduce some noises after the end of some tests, and help with the debugging of some issues. That's why this modification is seen as a "fix".

Quoted 6 lines
Fixes 25ae948b4478 ("selftests/net: add lib.sh")

---
tools/testing/selftests/net/lib.sh | 1 +

1 file changed, 1 insertion(+)

Sounds like a good idea to me:

Quoted 23 lines
tools/testing/selftests/net/lib.sh +1 -1
index d0219032f773..8ee4489238ca 100644
@@ -146,6 +146,7 @@ cleanup_ns()
 
 	for ns in "$@"; do
 		[ -z "${ns}" ] && continue
+		ip netns pids "${ns}" 2> /dev/null | xargs -r kill || true
 		ip netns delete "${ns}" &> /dev/null || true
 		if ! busywait $BUSYWAIT_TIMEOUT ip netns list \| grep -vq "^$ns$" &> /dev/null; then
 			echo "Warn: Failed to remove namespace $ns"
 
---

base-commit: 3b0e1975962a388844508be0b3e61e759837fa3e
change-id: 20240802-selftests-net-lib-cleanup-kill-f546a233572e

Best regards,

Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
maintainer Acked-by
#3 lore raw
Quoted 19 lines · Mat Martineau
Quoted 9 lines · On Fri, 2 Aug 2024, Matthieu Baerts (NGI0) wrote:

When deleting netns, it is possible to still have some tasks running, e.g. background tasks like tcpdump running in the background, not stopped because the test has been interrupted.

Before deleting the netns, it is then safer to kill all attached PIDs, if any. That should reduce some noises after the end of some tests, and help with the debugging of some issues. That's why this modification is seen as a "fix".

Quoted 6 lines
Fixes 25ae948b4478 ("selftests/net: add lib.sh")

---
tools/testing/selftests/net/lib.sh | 1 +

1 file changed, 1 insertion(+)
Quoted 3 lines

Sounds like a good idea to me:

Oops, it's in the net/ lib, not net/mptcp! I should have said:

Quoted 25 lines
Quoted 25 lines
tools/testing/selftests/net/lib.sh +1 -1
index d0219032f773..8ee4489238ca 100644
@@ -146,6 +146,7 @@ cleanup_ns()
 
      for ns in "$@"; do
              [ -z "${ns}" ] && continue
+             ip netns pids "${ns}" 2> /dev/null | xargs -r kill || true
              ip netns delete "${ns}" &> /dev/null || true
              if ! busywait $BUSYWAIT_TIMEOUT ip netns list \| grep -vq "^$ns$" &> /dev/null; then
                      echo "Warn: Failed to remove namespace $ns"
 
---

base-commit: 3b0e1975962a388844508be0b3e61e759837fa3e
change-id: 20240802-selftests-net-lib-cleanup-kill-f546a233572e

Best regards,
--
Matthieu Baerts (NGI0) <[email protected]>

author maintainer
#4 lore raw

Hi Mat,

Quoted 20 lines · Mat Martineau
Quoted 19 lines · Mat Martineau
Quoted 15 lines · On Fri, 2 Aug 2024, Matthieu Baerts (NGI0) wrote:

When deleting netns, it is possible to still have some tasks running, e.g. background tasks like tcpdump running in the background, not stopped because the test has been interrupted.

Before deleting the netns, it is then safer to kill all attached PIDs, if any. That should reduce some noises after the end of some tests, and help with the debugging of some issues. That's why this modification is seen as a "fix".

Fixes 25ae948b4478 ("selftests/net: add lib.sh")

---
tools/testing/selftests/net/lib.sh | 1 +

1 file changed, 1 insertion(+)
Quoted 7 lines
Quoted 3 lines

Sounds like a good idea to me:

Oops, it's in the net/ lib, not net/mptcp! I should have said:

Thank you for the review!

Now in our tree:

New patches for t/upstream-net and t/upstream:
- 8ebb566eeb44: selftests: net: lib: kill PIDs before del netns
- Results: 4636b17d0a66..35242dba0f3b (export-net)
- Results: 3b0e1975962a..2b058d91b960 (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/37ea6923481f76518c4ec25ce70981cc77a5dfca/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/5faa935e1c80da7b646c37ff0ea876778b8c984a/checks

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.