ip-tunnel: add support for tunnel flags

Implement support for IP tunnel flags. Currently only some IPv6 tunnel
flags are supported. Example:

 # nmcli connection add type ip-tunnel mode ip6ip6 \
   ip-tunnel.flags ip6-ign-encap-limit,ip6-use-orig-tclass \
   ifname abc ip-tunnel.parent ens8 ipv4.method disabled \
   ipv6.method manual ipv6.address ::8888 remote ::42

 # ip -d l
  61: abc@ens8: <NOARP,UP,LOWER_UP> mtu 1460 qdisc noqueue ...
    link/tunnel6 :: brd ::42 promiscuity 0
    ip6tnl ip6ip6 remote ::42 local :: dev ens8 encaplimit none
    hoplimit 0 tclass inherit ...

https://bugzilla.gnome.org/show_bug.cgi?id=791846
This commit is contained in:
Beniamino Galvani
2017-12-22 10:24:25 +01:00
parent 686afe531a
commit da4c9e51a0
16 changed files with 274 additions and 22 deletions

View File

@@ -36,6 +36,7 @@
#include <linux/if_link.h>
#include <linux/if_tun.h>
#include <linux/if_tunnel.h>
#include <linux/ip6_tunnel.h>
#include <netlink/netlink.h>
#include <netlink/msg.h>
#include <libudev.h>
@@ -1292,6 +1293,7 @@ _parse_lnk_ip6tnl (const char *kind, struct nlattr *info_data)
[IFLA_IPTUN_ENCAP_LIMIT] = { .type = NLA_U8 },
[IFLA_IPTUN_FLOWINFO] = { .type = NLA_U32 },
[IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
[IFLA_IPTUN_FLAGS] = { .type = NLA_U32 },
};
struct nlattr *tb[IFLA_IPTUN_MAX + 1];
int err;
@@ -1326,6 +1328,8 @@ _parse_lnk_ip6tnl (const char *kind, struct nlattr *info_data)
}
if (tb[IFLA_IPTUN_PROTO])
props->proto = nla_get_u8 (tb[IFLA_IPTUN_PROTO]);
if (tb[IFLA_IPTUN_FLAGS])
props->flags = nla_get_u32 (tb[IFLA_IPTUN_FLAGS]);
return obj;
}
@@ -5386,6 +5390,7 @@ link_ip6tnl_add (NMPlatform *platform,
& IP6_FLOWINFO_TCLASS_MASK;
NLA_PUT_U32 (nlmsg, IFLA_IPTUN_FLOWINFO, htonl (flowinfo));
NLA_PUT_U8 (nlmsg, IFLA_IPTUN_PROTO, props->proto);
NLA_PUT_U32 (nlmsg, IFLA_IPTUN_FLAGS, props->flags);
nla_nest_end (nlmsg, data);
nla_nest_end (nlmsg, info);