diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-12-26 21:44:05 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-12-26 21:44:05 +0100 |
| commit | 586a19e7ece21850ff9347ce78245bf19fe1cdcd (patch) | |
| tree | 6941564018916656a3d2a9a392cdc401c94fef8c /executor | |
| parent | c87e9eb9bdc75ed5efdd04066f0b1275f6738742 (diff) | |
executor: create more net devices on linux
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common_linux.h | 68 | ||||
| -rw-r--r-- | executor/defs.h | 10 | ||||
| -rw-r--r-- | executor/executor.cc | 12 |
3 files changed, 63 insertions, 27 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h index 56d5e15ab..9f7ce04e4 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -89,7 +89,7 @@ static void vsnprintf_check(char* str, size_t size, const char* format, va_list #define PATH_PREFIX "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin " #define PATH_PREFIX_LEN (sizeof(PATH_PREFIX) - 1) -static void execute_command(bool panic, const char* format, ...) +static PRINTF(2, 3) void execute_command(bool panic, const char* format, ...) { va_list args; char command[PATH_PREFIX_LEN + COMMAND_MAX_LEN]; @@ -251,8 +251,32 @@ static void initialize_netdevices(void) if (!flag_enable_net_dev) return; #endif - unsigned i; - const char* devtypes[] = {"ip6gretap", "bridge", "vcan", "bond", "team"}; + // TODO: add the following devices: + // - vlan + // - vxlan + // - macvlan + // - ipvlan + // - macsec + // - ipip + // - lowpan + // - ipoib + // - geneve + // - vrf + // - rmnet + // - openvswitch + // Naive attempts to add devices of these types fail with various errors. + // Also init namespace contains the following devices (which presumably can't be + // created in non-init namespace), can we use them somehow? + // - ifb0/1 + // - wpan0/1 + // - hwsim0 + // - teql0 + // - eql + char netdevsim[16]; + sprintf(netdevsim, "netdevsim%d", (int)procid); + const char* devtypes[] = {"ip6gretap", "ip6erspan", "bridge", "vcan", + "bond", "team", "dummy", "nlmon", "caif", "batadv"}; + const char* devmasters[] = {"bridge", "bond", "team"}; // If you extend this array, also update netdev_addr_id in vnet.txt. const char* devnames[] = {"lo", "sit0", "bridge0", "vcan0", "tunl0", "gre0", "gretap0", "ip_vti0", "ip6_vti0", @@ -260,11 +284,17 @@ static void initialize_netdevices(void) "erspan0", "bond0", "veth0", "veth1", "team0", "veth0_to_bridge", "veth1_to_bridge", "veth0_to_bond", "veth1_to_bond", - "veth0_to_team", "veth1_to_team"}; - const char* devmasters[] = {"bridge", "bond", "team"}; - + "veth0_to_team", "veth1_to_team", + "veth0_to_hsr", "veth1_to_hsr", "hsr0", + "ip6erspan0", "dummy0", "nlmon0", "vxcan1", + "caif0", "batadv0", netdevsim}; + unsigned i; for (i = 0; i < sizeof(devtypes) / (sizeof(devtypes[0])); i++) execute_command(0, "ip link add dev %s0 type %s", devtypes[i], devtypes[i]); + // Note: adding device vxcan0 fails. + execute_command(0, "ip link add dev vxcan1 type vxcan"); + // Note: netdevsim devices can't have the same name even in different namespaces. + execute_command(0, "ip link add dev %s type netdevsim", netdevsim); // This adds connected veth0 and veth1 devices. execute_command(0, "ip link add type veth"); @@ -277,13 +307,17 @@ static void initialize_netdevices(void) execute_command(0, "ip link add name %s_slave_1 type veth peer name veth1_to_%s", devmasters[i], devmasters[i]); execute_command(0, "ip link set %s_slave_0 master %s0", devmasters[i], devmasters[i]); execute_command(0, "ip link set %s_slave_1 master %s0", devmasters[i], devmasters[i]); - execute_command(0, "ip link set veth0_to_%s up", devmasters[i]); - execute_command(0, "ip link set veth1_to_%s up", devmasters[i]); } // bond/team_slave_* will set up automatically when set their master. // But bridge_slave_* need to set up manually. execute_command(0, "ip link set bridge_slave_0 up"); execute_command(0, "ip link set bridge_slave_1 up"); + // Setup hsr device (slightly different from what we do for devmasters). + execute_command(0, "ip link add name hsr_slave_0 type veth peer name veth0_to_hsr"); + execute_command(0, "ip link add name hsr_slave_1 type veth peer name veth1_to_hsr"); + execute_command(0, "ip link add dev hsr0 type hsr slave1 hsr_slave_0 slave2 hsr_slave_1"); + execute_command(0, "ip link set hsr_slave_0 up"); + execute_command(0, "ip link set hsr_slave_1 up"); for (i = 0; i < sizeof(devnames) / (sizeof(devnames[0])); i++) { char addr[32]; @@ -295,6 +329,7 @@ static void initialize_netdevices(void) snprintf_check(addr, sizeof(addr), DEV_IPV6, i + 10); execute_command(0, "ip -6 addr add %s/120 dev %s", addr, devnames[i]); snprintf_check(addr, sizeof(addr), DEV_MAC, i + 10); + // TODO: double-check sizes of addresses, some devices want 4/5/7/16-byte addresses. execute_command(0, "ip link set dev %s address %s", devnames[i], addr); execute_command(0, "ip link set dev %s up", devnames[i]); } @@ -307,19 +342,20 @@ static void initialize_netdevices_init(void) if (!flag_enable_net_dev) return; #endif + int pid = procid; // Note: syscall descriptions know these addresses. // NETROM device, address 7 bytes (AX25_ADDR_LEN), see net/netrom/{af_netrom,nr_dev}.c - execute_command(0, "ip link set dev nr%d address bb:bb:bb:bb:bb:00:%02hx", procid, procid); - execute_command(0, "ip -4 addr add 172.30.00.%d/24 dev nr%d", procid + 1, procid); - execute_command(0, "ip -6 addr add fe88::00:%02hx/120 dev nr%d", procid + 1, procid); - execute_command(0, "ip link set dev nr%d up", procid); + execute_command(0, "ip link set dev nr%d address bb:bb:bb:bb:bb:00:%02hx", pid, pid); + execute_command(0, "ip -4 addr add 172.30.00.%d/24 dev nr%d", pid + 1, pid); + execute_command(0, "ip -6 addr add fe88::00:%02hx/120 dev nr%d", pid + 1, pid); + execute_command(0, "ip link set dev nr%d up", pid); // ROSE device, address 5 bytes (ROSE_ADDR_LEN), see net/rose/{af_rose,rose_dev}.c - execute_command(0, "ip link set dev rose%d address bb:bb:bb:01:%02hx", procid, procid); - execute_command(0, "ip -4 addr add 172.30.01.%d/24 dev rose%d", procid + 1, procid); - execute_command(0, "ip -6 addr add fe88::01:%02hx/120 dev rose%d", procid + 1, procid); + execute_command(0, "ip link set dev rose%d address bb:bb:bb:01:%02hx", pid, pid); + execute_command(0, "ip -4 addr add 172.30.01.%d/24 dev rose%d", pid + 1, pid); + execute_command(0, "ip -6 addr add fe88::01:%02hx/120 dev rose%d", pid + 1, pid); // We don't up because it crashes kernel: // https://groups.google.com/d/msg/syzkaller/v-4B3zoBC-4/02SCKEzJBwAJ - // execute_command(0, "ip link set dev rose%d up", procid); + // execute_command(0, "ip link set dev rose%d up", pid); } #endif diff --git a/executor/defs.h b/executor/defs.h index bef70aebd..9a64c14c6 100644 --- a/executor/defs.h +++ b/executor/defs.h @@ -60,7 +60,7 @@ #if GOARCH_386 #define GOARCH "386" -#define SYZ_REVISION "3c1dc0a8b39f3f033ba3ab615d94d05980674818" +#define SYZ_REVISION "7aa5d2021c4912f5e8ad8ece188cd61b1a986041" #define SYZ_EXECUTOR_USES_FORK_SERVER 1 #define SYZ_EXECUTOR_USES_SHMEM 1 #define SYZ_PAGE_SIZE 4096 @@ -70,7 +70,7 @@ #if GOARCH_amd64 #define GOARCH "amd64" -#define SYZ_REVISION "a820c2637e924defa0488900c4e1405481df29ae" +#define SYZ_REVISION "1a1c33374821580428bd0182dfdd6e8a3e27db8c" #define SYZ_EXECUTOR_USES_FORK_SERVER 1 #define SYZ_EXECUTOR_USES_SHMEM 1 #define SYZ_PAGE_SIZE 4096 @@ -80,7 +80,7 @@ #if GOARCH_arm #define GOARCH "arm" -#define SYZ_REVISION "1804d21998116014ae81dec15908741778a30d2e" +#define SYZ_REVISION "a952755b0d255be46d4a9c702fbc370ec1cecc58" #define SYZ_EXECUTOR_USES_FORK_SERVER 1 #define SYZ_EXECUTOR_USES_SHMEM 1 #define SYZ_PAGE_SIZE 4096 @@ -90,7 +90,7 @@ #if GOARCH_arm64 #define GOARCH "arm64" -#define SYZ_REVISION "d26b13f830abdce253acd9eb514e0c2a0d96d9b4" +#define SYZ_REVISION "9dad7b4a6f846956a450e103959543743ff1025f" #define SYZ_EXECUTOR_USES_FORK_SERVER 1 #define SYZ_EXECUTOR_USES_SHMEM 1 #define SYZ_PAGE_SIZE 4096 @@ -100,7 +100,7 @@ #if GOARCH_ppc64le #define GOARCH "ppc64le" -#define SYZ_REVISION "9e08b512e30b2a31dde133ceb60b6b86024fc17b" +#define SYZ_REVISION "39821c0267ee7a09834a5d6cbfe4eb6085d50cfe" #define SYZ_EXECUTOR_USES_FORK_SERVER 1 #define SYZ_EXECUTOR_USES_SHMEM 1 #define SYZ_PAGE_SIZE 4096 diff --git a/executor/executor.cc b/executor/executor.cc index c0d549c0a..54cbdbbe3 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -21,13 +21,13 @@ #define SYSCALLAPI #define NORETURN __attribute__((noreturn)) #define ALIGNED(N) __attribute__((aligned(N))) -#define PRINTF __attribute__((format(printf, 1, 2))) +#define PRINTF(fmt, args) __attribute__((format(printf, fmt, args))) #else // Assuming windows/cl. #define SYSCALLAPI WINAPI #define NORETURN __declspec(noreturn) #define ALIGNED(N) __declspec(align(N)) -#define PRINTF +#define PRINTF(fmt, args) #endif #ifndef GIT_REVISION @@ -63,15 +63,15 @@ const int kRetryStatus = 69; const int kErrorStatus = 68; // Logical error (e.g. invalid input program), use as an assert() alternative. -static NORETURN PRINTF void fail(const char* msg, ...); +static NORETURN PRINTF(1, 2) void fail(const char* msg, ...); // Kernel error (e.g. wrong syscall return value). -NORETURN PRINTF void error(const char* msg, ...); +NORETURN PRINTF(1, 2) void error(const char* msg, ...); // Just exit (e.g. due to temporal ENOMEM error). -static NORETURN PRINTF void exitf(const char* msg, ...); +static NORETURN PRINTF(1, 2) void exitf(const char* msg, ...); static NORETURN void doexit(int status); // Print debug output, does not add \n at the end of msg as opposed to the previous functions. -static PRINTF void debug(const char* msg, ...); +static PRINTF(1, 2) void debug(const char* msg, ...); void debug_dump_data(const char* data, int length); #if 0 |
