mirror of
https://github.com/systemd/systemd.git
synced 2024-11-27 04:03:36 +08:00
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:
parent
05dc2132e0
commit
69c317a07f
@ -115,6 +115,9 @@
|
||||
<row><entry><varname>ipvlan</varname></entry>
|
||||
<entry>An ipvlan device is a stacked device which receives packets from its underlying device based on IP address filtering.</entry></row>
|
||||
|
||||
<row><entry><varname>ipvtap</varname></entry>
|
||||
<entry>An ipvtap device is a stacked device which receives packets from its underlying device based on IP address filtering and can be accessed using the tap user space interface.</entry></row>
|
||||
|
||||
<row><entry><varname>macvlan</varname></entry>
|
||||
<entry>A macvlan device is a stacked device which receives packets from its underlying device based on MAC address filtering.</entry></row>
|
||||
|
||||
@ -519,6 +522,15 @@
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[IPVTAP] Section Options</title>
|
||||
|
||||
<para>The <literal>[IPVTAP]</literal> section only applies for
|
||||
netdevs of kind <literal>ipvtap</literal> and accepts the
|
||||
same key as <literal>[IPVLAN]</literal>.</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[VXLAN] Section Options</title>
|
||||
<para>The <literal>[VXLAN]</literal> section only applies for
|
||||
|
@ -337,6 +337,7 @@ static const char* const nl_union_link_info_data_table[] = {
|
||||
[NL_UNION_LINK_INFO_DATA_MACVLAN] = "macvlan",
|
||||
[NL_UNION_LINK_INFO_DATA_MACVTAP] = "macvtap",
|
||||
[NL_UNION_LINK_INFO_DATA_IPVLAN] = "ipvlan",
|
||||
[NL_UNION_LINK_INFO_DATA_IPVTAP] = "ipvtap",
|
||||
[NL_UNION_LINK_INFO_DATA_VXLAN] = "vxlan",
|
||||
[NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL] = "ipip",
|
||||
[NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL] = "gre",
|
||||
@ -375,6 +376,8 @@ static const NLTypeSystem rtnl_link_info_data_type_systems[] = {
|
||||
.types = rtnl_link_info_data_macvlan_types },
|
||||
[NL_UNION_LINK_INFO_DATA_IPVLAN] = { .count = ELEMENTSOF(rtnl_link_info_data_ipvlan_types),
|
||||
.types = rtnl_link_info_data_ipvlan_types },
|
||||
[NL_UNION_LINK_INFO_DATA_IPVTAP] = { .count = ELEMENTSOF(rtnl_link_info_data_ipvlan_types),
|
||||
.types = rtnl_link_info_data_ipvlan_types },
|
||||
[NL_UNION_LINK_INFO_DATA_VXLAN] = { .count = ELEMENTSOF(rtnl_link_info_data_vxlan_types),
|
||||
.types = rtnl_link_info_data_vxlan_types },
|
||||
[NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_iptun_types),
|
||||
|
@ -62,6 +62,7 @@ typedef enum NLUnionLinkInfoData {
|
||||
NL_UNION_LINK_INFO_DATA_MACVLAN,
|
||||
NL_UNION_LINK_INFO_DATA_MACVTAP,
|
||||
NL_UNION_LINK_INFO_DATA_IPVLAN,
|
||||
NL_UNION_LINK_INFO_DATA_IPVTAP,
|
||||
NL_UNION_LINK_INFO_DATA_VXLAN,
|
||||
NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL,
|
||||
|
@ -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,
|
||||
|
@ -44,6 +44,7 @@ Network.VLAN, config_parse_stacked_netdev,
|
||||
Network.MACVLAN, config_parse_stacked_netdev, NETDEV_KIND_MACVLAN, offsetof(Network, stacked_netdev_names)
|
||||
Network.MACVTAP, config_parse_stacked_netdev, NETDEV_KIND_MACVTAP, offsetof(Network, stacked_netdev_names)
|
||||
Network.IPVLAN, config_parse_stacked_netdev, NETDEV_KIND_IPVLAN, offsetof(Network, stacked_netdev_names)
|
||||
Network.IPVTAP, config_parse_stacked_netdev, NETDEV_KIND_IPVTAP, offsetof(Network, stacked_netdev_names)
|
||||
Network.VXLAN, config_parse_stacked_netdev, NETDEV_KIND_VXLAN, offsetof(Network, stacked_netdev_names)
|
||||
Network.L2TP, config_parse_stacked_netdev, NETDEV_KIND_L2TP, offsetof(Network, stacked_netdev_names)
|
||||
Network.MACsec, config_parse_stacked_netdev, NETDEV_KIND_MACSEC, offsetof(Network, stacked_netdev_names)
|
||||
|
@ -708,8 +708,8 @@ int config_parse_stacked_netdev(const char *unit,
|
||||
assert(data);
|
||||
assert(IN_SET(kind,
|
||||
NETDEV_KIND_VLAN, NETDEV_KIND_MACVLAN, NETDEV_KIND_MACVTAP,
|
||||
NETDEV_KIND_IPVLAN, NETDEV_KIND_VXLAN, NETDEV_KIND_L2TP,
|
||||
NETDEV_KIND_MACSEC, _NETDEV_KIND_TUNNEL));
|
||||
NETDEV_KIND_IPVLAN, NETDEV_KIND_IPVTAP, NETDEV_KIND_VXLAN,
|
||||
NETDEV_KIND_L2TP, NETDEV_KIND_MACSEC, _NETDEV_KIND_TUNNEL));
|
||||
|
||||
if (!ifname_valid(rvalue)) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||
|
@ -151,6 +151,9 @@ VNetHeader=
|
||||
[IPVLAN]
|
||||
Mode=
|
||||
Flags=
|
||||
[IPVTAP]
|
||||
Mode=
|
||||
Flags=
|
||||
[Tun]
|
||||
OneQueue=
|
||||
MultiQueue=
|
||||
|
@ -104,6 +104,7 @@ Tunnel=
|
||||
Gateway=
|
||||
IPv4LL=
|
||||
IPVLAN=
|
||||
IPVTAP=
|
||||
EmitLLDP=
|
||||
IPv6MTUBytes=
|
||||
IPv4ProxyARP=
|
||||
|
Loading…
Reference in New Issue
Block a user