aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/selftests/net/lib/py/nsim.py
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2024-04-08 20:15:49 -0700
committerJakub Kicinski <kuba@kernel.org>2024-04-10 14:03:12 -0700
commit6ce2b689932ba8288ceef9a82c1caf029b0b23f9 (patch)
tree899e0e02adfddd8a8072e782c2a1c4e3dc7887b4 /tools/testing/selftests/net/lib/py/nsim.py
parentb1c2ce11d42886d08cfa28e38ee07f2b606ced0b (diff)
selftests: net: reuse common code in bpf_offload
net/lib/py/nsim.py already contains the most useful parts of the netdevsim wrapper classes. Reuse them. Acked-by: Stanislav Fomichev <sdf@google.com> Acked-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://lore.kernel.org/r/20240409031549.3531084-5-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/testing/selftests/net/lib/py/nsim.py')
-rw-r--r--tools/testing/selftests/net/lib/py/nsim.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/testing/selftests/net/lib/py/nsim.py b/tools/testing/selftests/net/lib/py/nsim.py
index b2d696e12805..97457aca7e08 100644
--- a/tools/testing/selftests/net/lib/py/nsim.py
+++ b/tools/testing/selftests/net/lib/py/nsim.py
@@ -21,8 +21,11 @@ class NetdevSim:
if match and int(match.groups()[0]) != port_index + 1:
raise Exception("netdevice name mismatches the expected one")
+ self.ifname = ifname
self.nsimdev = nsimdev
self.port_index = port_index
+ self.ns = ns
+ self.dfs_dir = "%s/ports/%u/" % (nsimdev.dfs_dir, port_index)
ret = ip("-j link show dev %s" % ifname, ns=ns)
self.dev = json.loads(ret.stdout)[0]
@@ -79,8 +82,10 @@ class NetdevSimDev:
self.nsims = []
for port_index in range(port_count):
- self.nsims.append(NetdevSim(self, port_index, ifnames[port_index],
- ns=ns))
+ self.nsims.append(self._make_port(port_index, ifnames[port_index]))
+
+ def _make_port(self, port_index, ifname):
+ return NetdevSim(self, port_index, ifname, self.ns)
def get_ifnames(self):
ifnames = []