aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_linux.h
diff options
context:
space:
mode:
Diffstat (limited to 'executor/common_linux.h')
-rw-r--r--executor/common_linux.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h
index 90566cb26..99821d535 100644
--- a/executor/common_linux.h
+++ b/executor/common_linux.h
@@ -405,10 +405,15 @@ static void initialize_netdevices(void)
{
unsigned i;
const char* devtypes[] = {"ip6gretap", "bridge", "vcan", "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",
"ip6tnl0", "ip6gre0", "ip6gretap0",
- "erspan0", "bond0", "veth0", "veth1", "team0"};
+ "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"};
#ifdef SYZ_EXECUTOR
if (!flag_enable_tun)
@@ -418,6 +423,24 @@ static void initialize_netdevices(void)
execute_command(0, "ip link add dev %s0 type %s", devtypes[i], devtypes[i]);
// This adds connected veth0 and veth1 devices.
execute_command(0, "ip link add type veth");
+
+ // This creates connected bridge/bond/team_slave devices of type veth,
+ // and makes them slaves of bridge/bond/team devices, respectively.
+ // Note: slave devices don't need MAC/IP addresses, only master devices.
+ // veth0_to_* is not slave devices, which still need ip addresses.
+ for (i = 0; i < sizeof(devmasters) / (sizeof(devmasters[0])); i++) {
+ execute_command(0, "ip link add name %s_slave_0 type veth peer name veth0_to_%s", devmasters[i], devmasters[i]);
+ 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");
+
for (i = 0; i < sizeof(devnames) / (sizeof(devnames[0])); i++) {
char addr[32];
// Assign some unique address to devices. Some devices won't up without this.
@@ -431,12 +454,6 @@ static void initialize_netdevices(void)
execute_command(0, "ip link set dev %s address %s", devnames[i], addr);
execute_command(0, "ip link set dev %s up", devnames[i]);
}
- // This creates connected bond_slave and team_slave devices of type veth,
- // and makes them slaves of bond0 and team0 devices, respectively.
- // Note: slave devices don't need MAC/IP addresses, only master devices.
- execute_command(0, "ip link add name bond_slave type veth peer name team_slave");
- execute_command(0, "ip link set bond_slave master bond0");
- execute_command(0, "ip link set team_slave master team0");
}
#endif