aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/test_offload.py
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2019-11-05 13:26:12 -0800
committerDavid S. Miller <davem@davemloft.net>2019-11-06 09:59:58 -0800
commitacceca8d2416bf866c5826240f9907cc91273f95 (patch)
treee2a7ca25572a44e398dd5632f04e7b1712ea4e51 /tools/testing/selftests/bpf/test_offload.py
parentnetdevsim: drop code duplicated by a merge (diff)
downloadlinux-dev-acceca8d2416bf866c5826240f9907cc91273f95.tar.xz
linux-dev-acceca8d2416bf866c5826240f9907cc91273f95.zip
selftests: bpf: log direct file writes
Recent changes to netdevsim moved creating and destroying devices from netlink to sysfs. The sysfs writes have been implemented as direct writes, without shelling out. This is faster, but leaves no trace in the logs. Add explicit logs to make debugging possible. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/bpf/test_offload.py')
-rwxr-xr-xtools/testing/selftests/bpf/test_offload.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py
index 1afa22c88e42..8294ae3ffb3c 100755
--- a/tools/testing/selftests/bpf/test_offload.py
+++ b/tools/testing/selftests/bpf/test_offload.py
@@ -335,13 +335,22 @@ class NetdevSimDev:
"""
Class for netdevsim bus device and its attributes.
"""
+ @staticmethod
+ def ctrl_write(path, val):
+ fullpath = os.path.join("/sys/bus/netdevsim/", path)
+ try:
+ with open(fullpath, "w") as f:
+ f.write(val)
+ except OSError as e:
+ log("WRITE %s: %r" % (fullpath, val), -e.errno)
+ raise e
+ log("WRITE %s: %r" % (fullpath, val), 0)
def __init__(self, port_count=1):
addr = 0
while True:
try:
- with open("/sys/bus/netdevsim/new_device", "w") as f:
- f.write("%u %u" % (addr, port_count))
+ self.ctrl_write("new_device", "%u %u" % (addr, port_count))
except OSError as e:
if e.errno == errno.ENOSPC:
addr += 1
@@ -403,14 +412,13 @@ class NetdevSimDev:
return progs
def remove(self):
- with open("/sys/bus/netdevsim/del_device", "w") as f:
- f.write("%u" % self.addr)
+ self.ctrl_write("del_device", "%u" % (self.addr, ))
devs.remove(self)
def remove_nsim(self, nsim):
self.nsims.remove(nsim)
- with open("/sys/bus/netdevsim/devices/netdevsim%u/del_port" % self.addr ,"w") as f:
- f.write("%u" % nsim.port_index)
+ self.ctrl_write("devices/netdevsim%u/del_port" % (self.addr, ),
+ "%u" % (nsim.port_index, ))
class NetdevSim:
"""