summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-10-23 23:18:59 +0900
committerGitHub <noreply@github.com>2019-10-23 23:18:59 +0900
commit69ec2fdd9c7a12c37bb02f7ec7690b6535502dd8 (patch)
tree3225048804ca8f91ca6bf82188b2e15a15de92fc
parent3dc9e2220f31ae68106680f3da05848e0433d0f4 (diff)
parent21bba27d9ba368515be3ec2639a86733dd79480d (diff)
downloadsystemd-69ec2fdd9c7a12c37bb02f7ec7690b6535502dd8.tar.gz
Merge pull request #13807 from 1848/ip6gre_key_fix
networkd: Set key (IFLA_GRE_IKEY,IFLA_GRE_OKEY) on ip6gre interfaces.
-rw-r--r--man/systemd.netdev.xml10
-rw-r--r--src/network/netdev/tunnel.c36
2 files changed, 46 insertions, 0 deletions
diff --git a/man/systemd.netdev.xml b/man/systemd.netdev.xml
index 43133559b3..8031bc0e0b 100644
--- a/man/systemd.netdev.xml
+++ b/man/systemd.netdev.xml
@@ -2019,6 +2019,16 @@ Remote=10.65.223.239</programlisting>
</example>
<example>
+ <title>/etc/systemd/network/25-ip6gre.netdev</title>
+ <programlisting>[NetDev]
+Name=ip6gre-tun
+Kind=ip6gre
+
+[Tunnel]
+Key=123</programlisting>
+ </example>
+
+ <example>
<title>/etc/systemd/network/25-vti.netdev</title>
<programlisting>[NetDev]
diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c
index c2525408ba..de7367f714 100644
--- a/src/network/netdev/tunnel.c
+++ b/src/network/netdev/tunnel.c
@@ -226,6 +226,10 @@ static int netdev_gre_erspan_fill_message_create(NetDev *netdev, Link *link, sd_
}
static int netdev_ip6gre_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
+ uint32_t ikey = 0;
+ uint32_t okey = 0;
+ uint16_t iflags = 0;
+ uint16_t oflags = 0;
Tunnel *t;
int r;
@@ -267,6 +271,38 @@ static int netdev_ip6gre_fill_message_create(NetDev *netdev, Link *link, sd_netl
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_FLAGS attribute: %m");
+ if (t->key != 0) {
+ ikey = okey = htobe32(t->key);
+ iflags |= GRE_KEY;
+ oflags |= GRE_KEY;
+ }
+
+ if (t->ikey != 0) {
+ ikey = htobe32(t->ikey);
+ iflags |= GRE_KEY;
+ }
+
+ if (t->okey != 0) {
+ okey = htobe32(t->okey);
+ oflags |= GRE_KEY;
+ }
+
+ r = sd_netlink_message_append_u32(m, IFLA_GRE_IKEY, ikey);
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_IKEY attribute: %m");
+
+ r = sd_netlink_message_append_u32(m, IFLA_GRE_OKEY, okey);
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_OKEY attribute: %m");
+
+ r = sd_netlink_message_append_u16(m, IFLA_GRE_IFLAGS, iflags);
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_IFLAGS attribute: %m");
+
+ r = sd_netlink_message_append_u16(m, IFLA_GRE_OFLAGS, oflags);
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_OFLAGS, attribute: %m");
+
return r;
}