diff options
author | Susant Sahani <ssahani@gmail.com> | 2015-07-27 11:18:28 +0530 |
---|---|---|
committer | Susant Sahani <ssahani@gmail.com> | 2015-07-27 11:18:28 +0530 |
commit | f33ff02b1aca5272ec678d3f4a211b4337882348 (patch) | |
tree | fae4205eb67486d9dddf82d892b5fec84b8011f5 /src/network/networkd-netdev-macvlan.c | |
parent | d13125752d6fdac84f7b4b6983f79a0b0acabc40 (diff) |
networkd: add support for macvtap
This patch add support for macvtap.
see http://virt.kernelnewbies.org/MacVTap
Diffstat (limited to 'src/network/networkd-netdev-macvlan.c')
-rw-r--r-- | src/network/networkd-netdev-macvlan.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/network/networkd-netdev-macvlan.c b/src/network/networkd-netdev-macvlan.c index c2c564935c..e17de793ce 100644 --- a/src/network/networkd-netdev-macvlan.c +++ b/src/network/networkd-netdev-macvlan.c @@ -35,14 +35,20 @@ DEFINE_STRING_TABLE_LOOKUP(macvlan_mode, MacVlanMode); DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode, macvlan_mode, MacVlanMode, "Failed to parse macvlan mode"); static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) { - MacVlan *m = MACVLAN(netdev); + MacVlan *m; int r; assert(netdev); - assert(m); assert(link); assert(netdev->ifname); + if (netdev->kind == NETDEV_KIND_MACVLAN) + m = MACVLAN(netdev); + else + m = MACVTAP(netdev); + + assert(m); + if (m->mode != _NETDEV_MACVLAN_MODE_INVALID) { r = sd_netlink_message_append_u32(req, IFLA_MACVLAN_MODE, m->mode); if (r < 0) @@ -53,14 +59,28 @@ static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_net } static void macvlan_init(NetDev *n) { - MacVlan *m = MACVLAN(n); + MacVlan *m; assert(n); + + if (n->kind == NETDEV_KIND_MACVLAN) + m = MACVLAN(n); + else + m = MACVTAP(n); + assert(m); m->mode = _NETDEV_MACVLAN_MODE_INVALID; } +const NetDevVTable macvtap_vtable = { + .object_size = sizeof(MacVlan), + .init = macvlan_init, + .sections = "Match\0NetDev\0MACVTAP\0", + .fill_message_create = netdev_macvlan_fill_message_create, + .create_type = NETDEV_CREATE_STACKED, +}; + const NetDevVTable macvlan_vtable = { .object_size = sizeof(MacVlan), .init = macvlan_init, |