summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py
diff options
context:
space:
mode:
authorPedro Tammela <pctammela@mojatatu.com>2023-11-17 18:12:05 +0100
committerJakub Kicinski <kuba@kernel.org>2023-11-21 03:06:36 +0100
commit3d5026fc5adbc796a0547fcef19d997786e0bb31 (patch)
treec7b0b77e82232465560b46ef8fe94c1d6bd1d1aa /tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py
parentselftests: tc-testing: move back to per test ns setup (diff)
downloadlinux-3d5026fc5adbc796a0547fcef19d997786e0bb31.tar.xz
linux-3d5026fc5adbc796a0547fcef19d997786e0bb31.zip
selftests: tc-testing: use netns delete from pyroute2
When pyroute2 is available, use the native netns delete routine instead of calling iproute2 to do it. As forks are expensive with some kernel configs, minimize its usage to avoid kselftests timeouts. Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> Reviewed-by: Simon Horman <horms@kernel.org> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Link: https://lore.kernel.org/r/20231117171208.2066136-4-pctammela@mojatatu.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to '')
-rw-r--r--tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py b/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py
index 2b8cbfdf1083..920dcbedc395 100644
--- a/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py
+++ b/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py
@@ -64,7 +64,10 @@ class SubPlugin(TdcPlugin):
if self.args.verbose:
print('{}.post_case'.format(self.sub_class))
- self._ns_destroy()
+ if netlink == True:
+ self._nl_ns_destroy()
+ else:
+ self._ns_destroy()
def post_suite(self, index):
if self.args.verbose:
@@ -174,6 +177,10 @@ class SubPlugin(TdcPlugin):
'''
self._exec_cmd_batched('pre', self._ns_create_cmds())
+ def _nl_ns_destroy(self):
+ ns = self.args.NAMES['NS']
+ netns.remove(ns)
+
def _ns_destroy_cmd(self):
return self._replace_keywords('netns delete {}'.format(self.args.NAMES['NS']))