diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-01-03 19:00:53 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-01-03 19:01:39 +0100 |
| commit | 76d86b16e617e761300a6de97f41f36bf091ef65 (patch) | |
| tree | d74218490d9f4ba45f1ea6ef322aef37ebbea621 /pkg/csource/generated.go | |
| parent | b485b85127bfc3a3afe341145bbb9705a223d4f3 (diff) | |
executor: setup vlan/macvlan/ipvlan devices
Diffstat (limited to 'pkg/csource/generated.go')
| -rw-r--r-- | pkg/csource/generated.go | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 3dfcc3e00..ad553310f 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -1320,6 +1320,54 @@ static void netlink_add_virt_wifi(struct nlmsg* nlmsg, int sock, const char* nam name, link, strerror(err)); (void)err; } + +static void netlink_add_vlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16 id, uint16 proto) +{ + netlink_add_device_impl(nlmsg, "vlan", name); + netlink_nest(nlmsg, IFLA_INFO_DATA); + netlink_attr(nlmsg, IFLA_VLAN_ID, &id, sizeof(id)); + netlink_attr(nlmsg, IFLA_VLAN_PROTOCOL, &proto, sizeof(proto)); + netlink_done(nlmsg); + netlink_done(nlmsg); + int ifindex = if_nametoindex(link); + netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); + int err = netlink_send(nlmsg, sock); + debug("netlink: add %s type vlan link %s id %d: %s\n", + name, link, id, strerror(err)); + (void)err; +} + +static void netlink_add_macvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link) +{ + netlink_add_device_impl(nlmsg, "macvlan", name); + netlink_nest(nlmsg, IFLA_INFO_DATA); + uint32 mode = MACVLAN_MODE_BRIDGE; + netlink_attr(nlmsg, IFLA_MACVLAN_MODE, &mode, sizeof(mode)); + netlink_done(nlmsg); + netlink_done(nlmsg); + int ifindex = if_nametoindex(link); + netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); + int err = netlink_send(nlmsg, sock); + debug("netlink: add %s type macvlan link %s mode %d: %s\n", + name, link, mode, strerror(err)); + (void)err; +} + +static void netlink_add_ipvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16 mode, uint16 flags) +{ + netlink_add_device_impl(nlmsg, "ipvlan", name); + netlink_nest(nlmsg, IFLA_INFO_DATA); + netlink_attr(nlmsg, IFLA_IPVLAN_MODE, &mode, sizeof(mode)); + netlink_attr(nlmsg, IFLA_IPVLAN_FLAGS, &flags, sizeof(flags)); + netlink_done(nlmsg); + netlink_done(nlmsg); + int ifindex = if_nametoindex(link); + netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); + int err = netlink_send(nlmsg, sock); + debug("netlink: add %s type ipvlan link %s mode %d: %s\n", + name, link, mode, strerror(err)); + (void)err; +} #endif #if SYZ_EXECUTOR || SYZ_NET_DEVICES || SYZ_NET_INJECTION || SYZ_DEVLINK_PCI @@ -1766,6 +1814,14 @@ static void initialize_netdevices(void) {"veth0_virt_wifi", ETH_ALEN}, {"veth1_virt_wifi", ETH_ALEN}, {"virt_wifi0", ETH_ALEN}, + {"veth0_vlan", ETH_ALEN}, + {"veth1_vlan", ETH_ALEN}, + {"vlan0", ETH_ALEN}, + {"vlan1", ETH_ALEN}, + {"macvlan0", ETH_ALEN}, + {"macvlan1", ETH_ALEN}, + {"ipvlan0", ETH_ALEN}, + {"ipvlan1", ETH_ALEN}, }; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) @@ -1796,6 +1852,14 @@ static void initialize_netdevices(void) netlink_add_veth(&nlmsg, sock, "veth0_virt_wifi", "veth1_virt_wifi"); netlink_add_virt_wifi(&nlmsg, sock, "virt_wifi0", "veth1_virt_wifi"); + netlink_add_veth(&nlmsg, sock, "veth0_vlan", "veth1_vlan"); + netlink_add_vlan(&nlmsg, sock, "vlan0", "veth0_vlan", 0, htons(ETH_P_8021Q)); + netlink_add_vlan(&nlmsg, sock, "vlan1", "veth0_vlan", 1, htons(ETH_P_8021AD)); + netlink_add_macvlan(&nlmsg, sock, "macvlan0", "veth1_vlan"); + netlink_add_macvlan(&nlmsg, sock, "macvlan1", "veth1_vlan"); + netlink_add_ipvlan(&nlmsg, sock, "ipvlan0", "veth0_vlan", IPVLAN_MODE_L2, 0); + netlink_add_ipvlan(&nlmsg, sock, "ipvlan1", "veth0_vlan", IPVLAN_MODE_L3S, IPVLAN_F_VEPA); + netdevsim_add((int)procid, 4); for (i = 0; i < sizeof(devices) / (sizeof(devices[0])); i++) { |
