[SRU][J][PATCH 3/6] selftests/net: add variable NS_LIST for lib.sh
Ian Whitfield
ian.whitfield at canonical.com
Thu Oct 1 20:39:45 UTC 2026
From: Hangbin Liu <liuhangbin at gmail.com>
BugLink: https://bugs.launchpad.net/bugs/2055473
Add a global variable NS_LIST to store all the namespaces that setup_ns
created, so the caller could call cleanup_all_ns() instead of remember
all the netns names when using cleanup_ns().
Signed-off-by: Hangbin Liu <liuhangbin at gmail.com>
Link: https://lore.kernel.org/r/20231213060856.4030084-2-liuhangbin@gmail.com
Signed-off-by: Jakub Kicinski <kuba at kernel.org>
(cherry picked from commit b6925b4ed57cccf42ca0fb46c7446f0859e7ad4b)
Signed-off-by: Ian Whitfield <ian.whitfield at canonical.com>
---
tools/testing/selftests/net/lib.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh
index 4167125df55f5..7c5a267517be6 100644
--- a/tools/testing/selftests/net/lib.sh
+++ b/tools/testing/selftests/net/lib.sh
@@ -6,6 +6,8 @@
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
+# namespace list created by setup_ns
+NS_LIST=""
##############################################################################
# Helpers
@@ -72,6 +74,11 @@ cleanup_ns()
return $ret
}
+cleanup_all_ns()
+{
+ cleanup_ns $NS_LIST
+}
+
# setup netns with given names as prefix. e.g
# setup_ns local remote
setup_ns()
@@ -98,4 +105,5 @@ setup_ns()
ip -n "$ns" link set lo up
ns_list="$ns_list $ns"
done
+ NS_LIST="$NS_LIST $ns_list"
}
--
2.43.0
More information about the kernel-team
mailing list