[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240404185844.0ddb8632@kernel.org>
Date: Thu, 4 Apr 2024 18:58:44 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Petr Machata <petrm@...dia.com>
Cc: <davem@...emloft.net>, <netdev@...r.kernel.org>, <edumazet@...gle.com>,
<pabeni@...hat.com>, <shuah@...nel.org>, <sdf@...gle.com>,
<donald.hunter@...il.com>, <linux-kselftest@...r.kernel.org>
Subject: Re: [PATCH net-next v2 6/7] selftests: drivers: add scaffolding for
Netlink tests in Python
On Thu, 4 Apr 2024 12:42:24 +0200 Petr Machata wrote:
> > + def __init__(self, nsimdev, port_index, ifname, ns=None):
> > + # In case udev renamed the netdev to according to new schema,
> > + # check if the name matches the port_index.
> > + nsimnamere = re.compile(r"eni\d+np(\d+)")
> > + match = nsimnamere.match(ifname)
> > + 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]
>
> I don't think self.ifname, .ns, .dfs_dir, .dev are actually used outside
> of this function.
Right, one of the "further down the line" tests need these.
I'll remove for now.
> > + def dfs_write(self, path, val):
> > + self.nsimdev.dfs_write(f'ports/{self.port_index}/' + path, val)
> > +
> > +
> > +class NetdevSimDev:
> > + """
> > + Class for netdevsim bus device and its attributes.
> > + """
> > + @staticmethod
> > + def ctrl_write(path, val):
> > + fullpath = os.path.join("/sys/bus/netdevsim/", path)
> > + with open(fullpath, "w") as f:
> > + f.write(val)
> > +
> > + def dfs_write(self, path, val):
> > + fullpath = os.path.join(f"/sys/kernel/debug/netdevsim/netdevsim{self.addr}/", path)
> > + with open(fullpath, "w") as f:
> > + f.write(val)
> > +
> > + def __init__(self, port_count=1, ns=None):
> > + # nsim will spawn in init_net, we'll set to actual ns once we switch it the.sre
>
> the.sre?
Ha, must have started typing with focus on the wrong window.
Good it wasn't my password :D
Powered by blists - more mailing lists