From 918049ad53fb5136403b0a03e454d29edbcb0363 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Sat, 1 Dec 2018 18:21:20 +0530 Subject: [PATCH] networkd: Add support to configure ISATAP tunnel Let's just reuse the code of sit tunnel to create a ISATAP tunnel. Matter of turning a flag Please see https://elixir.bootlin.com/linux/v4.19.6/source/net/ipv6/sit.c#L208 --- man/systemd.netdev.xml | 7 +++++++ src/network/netdev/netdev-gperf.gperf | 1 + src/network/netdev/tunnel.c | 12 ++++++++++++ src/network/netdev/tunnel.h | 1 + test/fuzz/fuzz-netdev-parser/directives.netdev | 1 + 5 files changed, 22 insertions(+) diff --git a/man/systemd.netdev.xml b/man/systemd.netdev.xml index f17a6a96190..67ccc66dd8e 100644 --- a/man/systemd.netdev.xml +++ b/man/systemd.netdev.xml @@ -924,6 +924,13 @@ applicable to SIT tunnels. + + ISATAP= + + Takes a boolean. If set, configures the tunnel as Intra-Site Automatic Tunnel Addressing Protocol (ISATAP) tunnel. + Only applicable to SIT tunnels. When unset, the kernel's default will be used. + + SerializeTunneledPackets= diff --git a/src/network/netdev/netdev-gperf.gperf b/src/network/netdev/netdev-gperf.gperf index 49752c2d8a2..fbc7a59e9e8 100644 --- a/src/network/netdev/netdev-gperf.gperf +++ b/src/network/netdev/netdev-gperf.gperf @@ -73,6 +73,7 @@ Tunnel.Encapsulation, config_parse_fou_encap_type, 0, Tunnel.IPv6RapidDeploymentPrefix, config_parse_6rd_prefix, 0, 0 Tunnel.ERSPANIndex, config_parse_uint32, 0, offsetof(Tunnel, erspan_index) Tunnel.SerializeTunneledPackets, config_parse_tristate, 0, offsetof(Tunnel, erspan_sequence) +Tunnel.ISATAP, config_parse_tristate, 0, offsetof(Tunnel, isatap) FooOverUDP.Protocol, config_parse_uint8, 0, offsetof(FouTunnel, fou_protocol) FooOverUDP.Encapsulation, config_parse_fou_encap_type, 0, offsetof(FouTunnel, fou_encap_type) FooOverUDP.Port, config_parse_ip_port, 0, offsetof(FouTunnel, port) diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c index 36f1fe7b034..684edddb5f5 100644 --- a/src/network/netdev/tunnel.c +++ b/src/network/netdev/tunnel.c @@ -118,6 +118,7 @@ static int netdev_sit_fill_message_create(NetDev *netdev, Link *link, sd_netlink r = sd_netlink_message_append_in6_addr(m, IFLA_IPTUN_6RD_PREFIX, &t->sixrd_prefix); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_6RD_PREFIX attribute: %m"); + /* u16 is deliberate here, even though we're passing a netmask that can never be >128. The kernel is * expecting to receive the prefixlen as a u16. */ @@ -126,6 +127,16 @@ static int netdev_sit_fill_message_create(NetDev *netdev, Link *link, sd_netlink return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_6RD_PREFIXLEN attribute: %m"); } + if (t->isatap >= 0) { + uint16_t flags = 0; + + SET_FLAG(flags, SIT_ISATAP, t->isatap); + + r = sd_netlink_message_append_u16(m, IFLA_IPTUN_FLAGS, flags); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_FLAGS attribute: %m"); + } + return r; } @@ -761,6 +772,7 @@ static void sit_init(NetDev *n) { assert(t); t->pmtudisc = true; + t->isatap = -1; } static void vti_init(NetDev *n) { diff --git a/src/network/netdev/tunnel.h b/src/network/netdev/tunnel.h index 51b61637ad4..8f511dd1f64 100644 --- a/src/network/netdev/tunnel.h +++ b/src/network/netdev/tunnel.h @@ -30,6 +30,7 @@ typedef struct Tunnel { int ipv6_flowlabel; int allow_localremote; int erspan_sequence; + int isatap; unsigned ttl; unsigned tos; diff --git a/test/fuzz/fuzz-netdev-parser/directives.netdev b/test/fuzz/fuzz-netdev-parser/directives.netdev index 19226df8062..5a8d41eb683 100644 --- a/test/fuzz/fuzz-netdev-parser/directives.netdev +++ b/test/fuzz/fuzz-netdev-parser/directives.netdev @@ -76,6 +76,7 @@ FOUSourcePort= IPv6RapidDeploymentPrefix= ERSPANIndex= SerializeTunneledPackets= +ISATAP= [VXLAN] UDP6ZeroChecksumRx= ARPProxy=