diff options
| author | Andrei Vagin <avagin@google.com> | 2019-11-25 16:56:24 -0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-11-26 10:07:31 +0100 |
| commit | 2649e7ccc4893a6006c8636daccdcae5afb3e8c6 (patch) | |
| tree | ae1fd8e2db88b266ad0696e0c895cfdc0f0f64e0 /executor/common_linux.h | |
| parent | f746151a9375b5b700196314d9e5f308b81e729f (diff) | |
Call initialize_devlink_ports only when a device has been created
gVisor doesn't support netdevsim and NETLINK_GENERIC and
without this fix, sys-executor always fails:
E openat(AT_FDCWD, /sys/bus/netdevsim/new_device, ...)
X openat(AT_FDCWD, /sys/bus/netdevsim/new_device, ...) = 0x0 errno=2
E socket(AF_NETLINK, SOCK_RAW|0x0, NETLINK_GENERIC)
X socket(AF_NETLINK, SOCK_RAW|0x0, NETLINK_GENERIC) = 0x0 errno=93
E write(0x2 host:[3], "socket(AF_NETLINK) failed\n", 0x1a)
X write(0x2 host:[3], ..., 0x1a) = 0x1a (2.767µs)
E write(0x2 host:[3], " (errno 93)\n", 0xc)
X write(0x2 host:[3], ..., 0xc) = 0xc (2.729µs)
E exit_group(0x43)
X exit_group(0x43) = 0x0 (900ns)
Cc: Jiri Pirko <jiri@mellanox.com>
Fixes: f350e2dc1f59 ("executor: rename devlink port netdevices to defined names")
Signed-off-by: Andrei Vagin <avagin@google.com>
Diffstat (limited to 'executor/common_linux.h')
| -rw-r--r-- | executor/common_linux.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h index 38b67ef3e..35dff507d 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -653,9 +653,10 @@ static void netdevsim_add(unsigned int addr, unsigned int port_count) char buf[16]; sprintf(buf, "%u %u", addr, port_count); - write_file("/sys/bus/netdevsim/new_device", buf); - snprintf(buf, sizeof(buf), "netdevsim%d", addr); - initialize_devlink_ports("netdevsim", buf, "netdevsim"); + if (write_file("/sys/bus/netdevsim/new_device", buf)) { + snprintf(buf, sizeof(buf), "netdevsim%d", addr); + initialize_devlink_ports("netdevsim", buf, "netdevsim"); + } } // We test in a separate namespace, which does not have any network devices initially (even lo). |
