]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests: net: lib: kill PIDs before del netns
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>
Tue, 13 Aug 2024 13:39:34 +0000 (15:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Aug 2024 15:35:49 +0000 (17:35 +0200)
[ Upstream commit 7965a7f32a53d9ad807ce2c53bdda69ba104974f ]

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")
Acked-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Acked-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://patch.msgid.link/20240813-upstream-net-20240813-selftests-net-lib-kill-v1-1-27b689b248b8@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/net/lib.sh

index b2572aff6286f1dbf83640d3ed3ded3a9b734b8f..93de05fedd91a8d8cb13306eb62b5c6f7dbdf6d0 100644 (file)
@@ -132,6 +132,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"