networkd: introduce netdev ipvtap
This patch adds netdev ipvtap that is based on the IP-VLAN network interface, called ipvtap. An ipvtap device can be created in the same way as an ipvlan device, using 'kind ipvtap', and then accessed using the tap user space interface.
This commit is contained in:
committed by
Yu Watanabe
parent
05dc2132e0
commit
69c317a07f
@@ -32,7 +32,10 @@ static int netdev_ipvlan_fill_message_create(NetDev *netdev, Link *link, sd_netl
|
||||
assert(link);
|
||||
assert(netdev->ifname);
|
||||
|
||||
m = IPVLAN(netdev);
|
||||
if (netdev->kind == NETDEV_KIND_IPVLAN)
|
||||
m = IPVLAN(netdev);
|
||||
else
|
||||
m = IPVTAP(netdev);
|
||||
|
||||
assert(m);
|
||||
|
||||
@@ -56,7 +59,10 @@ static void ipvlan_init(NetDev *n) {
|
||||
|
||||
assert(n);
|
||||
|
||||
m = IPVLAN(n);
|
||||
if (n->kind == NETDEV_KIND_IPVLAN)
|
||||
m = IPVLAN(n);
|
||||
else
|
||||
m = IPVTAP(n);
|
||||
|
||||
assert(m);
|
||||
|
||||
@@ -71,3 +77,11 @@ const NetDevVTable ipvlan_vtable = {
|
||||
.fill_message_create = netdev_ipvlan_fill_message_create,
|
||||
.create_type = NETDEV_CREATE_STACKED,
|
||||
};
|
||||
|
||||
const NetDevVTable ipvtap_vtable = {
|
||||
.object_size = sizeof(IPVlan),
|
||||
.init = ipvlan_init,
|
||||
.sections = "Match\0NetDev\0IPVTAP\0",
|
||||
.fill_message_create = netdev_ipvlan_fill_message_create,
|
||||
.create_type = NETDEV_CREATE_STACKED,
|
||||
};
|
||||
|
||||
@@ -30,7 +30,9 @@ typedef struct IPVlan {
|
||||
} IPVlan;
|
||||
|
||||
DEFINE_NETDEV_CAST(IPVLAN, IPVlan);
|
||||
DEFINE_NETDEV_CAST(IPVTAP, IPVlan);
|
||||
extern const NetDevVTable ipvlan_vtable;
|
||||
extern const NetDevVTable ipvtap_vtable;
|
||||
|
||||
const char *ipvlan_mode_to_string(IPVlanMode d) _const_;
|
||||
IPVlanMode ipvlan_mode_from_string(const char *d) _pure_;
|
||||
|
||||
@@ -54,6 +54,8 @@ MACVLAN.Mode, config_parse_macvlan_mode,
|
||||
MACVTAP.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode)
|
||||
IPVLAN.Mode, config_parse_ipvlan_mode, 0, offsetof(IPVlan, mode)
|
||||
IPVLAN.Flags, config_parse_ipvlan_flags, 0, offsetof(IPVlan, flags)
|
||||
IPVTAP.Mode, config_parse_ipvlan_mode, 0, offsetof(IPVlan, mode)
|
||||
IPVTAP.Flags, config_parse_ipvlan_flags, 0, offsetof(IPVlan, flags)
|
||||
Tunnel.Local, config_parse_tunnel_address, 0, offsetof(Tunnel, local)
|
||||
Tunnel.Remote, config_parse_tunnel_address, 0, offsetof(Tunnel, remote)
|
||||
Tunnel.TOS, config_parse_unsigned, 0, offsetof(Tunnel, tos)
|
||||
|
||||
@@ -45,6 +45,7 @@ const NetDevVTable * const netdev_vtable[_NETDEV_KIND_MAX] = {
|
||||
[NETDEV_KIND_MACVLAN] = &macvlan_vtable,
|
||||
[NETDEV_KIND_MACVTAP] = &macvtap_vtable,
|
||||
[NETDEV_KIND_IPVLAN] = &ipvlan_vtable,
|
||||
[NETDEV_KIND_IPVTAP] = &ipvtap_vtable,
|
||||
[NETDEV_KIND_VXLAN] = &vxlan_vtable,
|
||||
[NETDEV_KIND_IPIP] = &ipip_vtable,
|
||||
[NETDEV_KIND_GRE] = &gre_vtable,
|
||||
@@ -78,6 +79,7 @@ static const char* const netdev_kind_table[_NETDEV_KIND_MAX] = {
|
||||
[NETDEV_KIND_MACVLAN] = "macvlan",
|
||||
[NETDEV_KIND_MACVTAP] = "macvtap",
|
||||
[NETDEV_KIND_IPVLAN] = "ipvlan",
|
||||
[NETDEV_KIND_IPVTAP] = "ipvtap",
|
||||
[NETDEV_KIND_VXLAN] = "vxlan",
|
||||
[NETDEV_KIND_IPIP] = "ipip",
|
||||
[NETDEV_KIND_GRE] = "gre",
|
||||
|
||||
@@ -24,6 +24,7 @@ typedef enum NetDevKind {
|
||||
NETDEV_KIND_MACVLAN,
|
||||
NETDEV_KIND_MACVTAP,
|
||||
NETDEV_KIND_IPVLAN,
|
||||
NETDEV_KIND_IPVTAP,
|
||||
NETDEV_KIND_VXLAN,
|
||||
NETDEV_KIND_IPIP,
|
||||
NETDEV_KIND_GRE,
|
||||
|
||||
Reference in New Issue
Block a user