]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests: rds: Register network teardown via atexit
authorAllison Henderson <achender@kernel.org>
Mon, 18 May 2026 01:24:41 +0000 (18:24 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 21 May 2026 00:03:03 +0000 (17:03 -0700)
commita8876203489f49e60a693f8becb19963519ccc71
treedee09d7d51e287a0f6c49822cecd411cbfe2f951
parent0c4d043f61f9bd37817ad51d36e11adf77cd461a
selftests: rds: Register network teardown via atexit

This patch adds a teardown_tcp() helper that removes net0/net1.
The cmd calls here use fail=False so they can be called from
completed or partially-setup states on error. Also call
teardown_tcp() at the top of setup_tcp() so a previous
interrupted run does not leave net0/net1 lingering and break a
subsequent ip netns add.  Register teardown_tcp() with atexit
before setup_tcp() is invoked.

Likewise, we can simpliy stop_pcaps() handling by registering it
with atexit instead of calling it from the signal handler.

atexit handlers run on any exit path - normal completion, raised
exception, and sys.exit() from the timeout signal handler.  This
guarantees cleanup are called without further wrapping the test
body in a try/finally blocks.

atexit LIFO ordering keeps stop_pcaps before teardown_tcp so
tcpdumps are killed cleanly before their namespaces go away.

This is a preparatory cleanup for the upcoming ROCE patch which
will also register a teardown_rdma() alongside teardown_tcp()

Signed-off-by: Allison Henderson <achender@kernel.org>
Link: https://patch.msgid.link/20260518012443.2629206-10-achender@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/rds/test.py