From 4799d932b57f9acf955a067a7a1e598c6f3c7e40 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 31 Mar 2019 16:24:48 +0900 Subject: [PATCH] network: add FooOverUDP support for SIT and GRE tunnels --- src/network/netdev/tunnel.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c index 8599020d226..eae31ff0a82 100644 --- a/src/network/netdev/tunnel.c +++ b/src/network/netdev/tunnel.c @@ -72,7 +72,7 @@ static int netdev_ipip_sit_fill_message_create(NetDev *netdev, Link *link, sd_ne if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_PMTUDISC attribute: %m"); - if (netdev->kind == NETDEV_KIND_IPIP && t->fou_tunnel) { + if (t->fou_tunnel) { r = sd_netlink_message_append_u16(m, IFLA_IPTUN_ENCAP_TYPE, t->fou_encap_type); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_ENCAP_TYPE attribute: %m"); @@ -214,6 +214,20 @@ static int netdev_gre_erspan_fill_message_create(NetDev *netdev, Link *link, sd_ if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_OFLAGS, attribute: %m"); + if (t->fou_tunnel) { + r = sd_netlink_message_append_u16(m, IFLA_GRE_ENCAP_TYPE, t->fou_encap_type); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_ENCAP_TYPE attribute: %m"); + + r = sd_netlink_message_append_u16(m, IFLA_GRE_ENCAP_SPORT, htobe16(t->encap_src_port)); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_ENCAP_SPORT attribute: %m"); + + r = sd_netlink_message_append_u16(m, IFLA_GRE_ENCAP_DPORT, htobe16(t->fou_destination_port)); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_ENCAP_DPORT attribute: %m"); + } + return r; } @@ -686,6 +700,7 @@ static void sit_init(NetDev *n) { assert(t); t->pmtudisc = true; + t->fou_encap_type = FOU_ENCAP_DIRECT; t->isatap = -1; } @@ -727,6 +742,7 @@ static void gre_erspan_init(NetDev *n) { t->pmtudisc = true; t->gre_erspan_sequence = -1; + t->fou_encap_type = FOU_ENCAP_DIRECT; } static void ip6gre_init(NetDev *n) {