* [PATCH net-next v1 1/1] selftests/net/openvswitch: terminate namespace processes before deletion
@ 2026-12-06 9:29 Minxi Hou
0 siblings, 0 replies; only message in thread
From: Minxi Hou @ 2026-12-06 9:29 UTC (permalink / raw)
To: netdev
Cc: Aaron Conole, Eelco Chaudron, Ilya Maximets, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
Simon Horman, Shuah Khan, dev, linux-kselftest, Ilya Maximets
ovs_netns_spawn_daemon() records only the PID of the process it starts.
A daemon such as socat with the fork option can leave children behind
when cleanup terminates that PID. Deleting the namespace name does not
terminate the remaining processes, so a live child can keep the network
namespace alive after the test exits.
Send SIGTERM to the processes in each test namespace and use the existing
bounded wait before deleting its name. Keep the sweep before deletion,
while ip netns pids can still find the namespace's processes. Cleanup
remains best effort if a process does not exit within the timeout.
Fixes: 07a9e3975039 ("selftests/net/openvswitch: add SCTP flow key support and test")
Signed-off-by: Minxi Hou <houminxi@gmail.com>
---
Testing: all 19 registered OVS selftest cases passed in a fresh guest
on a reused 7.4.0-rc4-virtme kernel and matching OVS module. The suite
completed in 155.074 seconds. No matching test processes remained
during the 10-second post-suite observation; datapaths and named
namespaces were empty, and the OVS module unloaded.
The userspace sources are from this base plus the patch; the kernel
was not rebuilt from this base.
A controlled real SCTP connection reproduced the cleanup defect:
with only the new cleanup registration withdrawn, a forked listener
child remained alive for 10 seconds. The fixed and restored copies
drained the namespace. Natural withdrawal runs did not reliably
reproduce the original intermittent leak.
AI assistance: Hermes assisted with diagnosis, the cleanup helper,
test execution and this message. The task was to clean up processes
left by the OVS selftests without changing their forwarding tests.
.../selftests/net/openvswitch/openvswitch.sh | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/openvswitch/openvswitch.sh b/tools/testing/selftests/net/openvswitch/openvswitch.sh
index 21444657a04049c293ad8b875f89602eeb9218aa..01f1f56608147caeecc3c40614fc4a156cff1e7c 100755
--- a/tools/testing/selftests/net/openvswitch/openvswitch.sh
+++ b/tools/testing/selftests/net/openvswitch/openvswitch.sh
@@ -68,6 +68,24 @@ ovs_wait() {
return 1
}
+# Called indirectly by ovs_wait during namespace cleanup.
+# shellcheck disable=SC2329
+ovs_netns_pids_gone() {
+ [ -z "$(ip netns pids "$1" 2>/dev/null)" ]
+}
+
+# Registered as a deferred command by ovs_add_netns_and_veths.
+# shellcheck disable=SC2329
+ovs_cleanup_netns() {
+ local netns=$1
+ local pid
+
+ for pid in $(ip netns pids "$netns" 2>/dev/null); do
+ kill -TERM "$pid" 2>/dev/null || true
+ done
+ ovs_wait ovs_netns_pids_gone "$netns" || true
+}
+
ovs_base=`pwd`
sbxs=
sbx_add () {
@@ -160,10 +178,12 @@ ovs_spawn_daemon() {
ovs_netns_spawn_daemon $sbx "_default" $*
}
+# Called by test functions dispatched indirectly by run_test.
+# shellcheck disable=SC2329
ovs_add_netns_and_veths () {
info "Adding netns attached: sbx:$1 dp:$2 {$3, $4, $5}"
ovs_sbx "$1" ip netns add "$3" || return 1
- on_exit "ovs_sbx $1 ip netns del $3"
+ on_exit "ovs_sbx $1 ovs_cleanup_netns $3; ovs_sbx $1 ip netns del $3"
ovs_sbx "$1" ip link add "$4" type veth peer name "$5" || return 1
on_exit "ovs_sbx $1 ip link del $4 >/dev/null 2>&1"
ovs_sbx "$1" ip link set "$4" up || return 1
base-commit: 76c4fde2458287eb92924f35fe7888e5fc427ed5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-06 9:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-06 9:29 [PATCH net-next v1 1/1] selftests/net/openvswitch: terminate namespace processes before deletion Minxi Hou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox