summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-11-12 15:55:03 +0900
committerGitHub <noreply@github.com>2018-11-12 15:55:03 +0900
commitbf877a54c7d52945e8d0d1e96a14f35181410fb2 (patch)
tree62bb3f73df659690127409334831c62656178503 /src/network
parentd7ef030b26885691402368e46708188e1af1f223 (diff)
parentd29dc4f1b84e5ab0225ed81b1688c37df87f2de7 (diff)
downloadsystemd-bf877a54c7d52945e8d0d1e96a14f35181410fb2.tar.gz
Merge pull request #10669 from danderson/networkd-6rd
networkd: add 6rd support for sit netdevs
Diffstat (limited to 'src/network')
-rw-r--r--src/network/netdev/netdev-gperf.gperf1
-rw-r--r--src/network/netdev/tunnel.c48
-rw-r--r--src/network/netdev/tunnel.h6
3 files changed, 55 insertions, 0 deletions
diff --git a/src/network/netdev/netdev-gperf.gperf b/src/network/netdev/netdev-gperf.gperf
index 61d73e15ff..be7f004d63 100644
--- a/src/network/netdev/netdev-gperf.gperf
+++ b/src/network/netdev/netdev-gperf.gperf
@@ -70,6 +70,7 @@ Tunnel.FooOverUDP, config_parse_bool, 0,
Tunnel.FOUDestinationPort, config_parse_ip_port, 0, offsetof(Tunnel, fou_destination_port)
Tunnel.FOUSourcePort, config_parse_ip_port, 0, offsetof(Tunnel, encap_src_port)
Tunnel.Encapsulation, config_parse_fou_encap_type, 0, offsetof(Tunnel, fou_encap_type)
+Tunnel.IPv6RapidDeploymentPrefix, config_parse_6rd_prefix, 0, 0
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 861c30404c..fa9a9ac077 100644
--- a/src/network/netdev/tunnel.c
+++ b/src/network/netdev/tunnel.c
@@ -114,6 +114,18 @@ static int netdev_sit_fill_message_create(NetDev *netdev, Link *link, sd_netlink
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_PMTUDISC attribute: %m");
+ if (t->sixrd_prefixlen > 0) {
+ 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.
+ */
+ r = sd_netlink_message_append_u16(m, IFLA_IPTUN_6RD_PREFIXLEN, t->sixrd_prefixlen);
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_6RD_PREFIXLEN attribute: %m");
+ }
+
return r;
}
@@ -617,6 +629,42 @@ int config_parse_encap_limit(const char* unit,
return 0;
}
+int config_parse_6rd_prefix(const char* unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+ Tunnel *t = userdata;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ union in_addr_union p;
+ uint8_t l;
+ int r;
+
+ r = in_addr_prefix_from_string(rvalue, AF_INET6, &p, &l);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 6rd prefix \"%s\", ignoring: %m", rvalue);
+ return 0;
+ }
+ if (l == 0) {
+ log_syntax(unit, LOG_ERR, filename, line, 0, "6rd prefix length of \"%s\" must be greater than zero, ignoring", rvalue);
+ return 0;
+ }
+
+ t->sixrd_prefix = p.in6;
+ t->sixrd_prefixlen = l;
+
+ return 0;
+}
+
static void ipip_init(NetDev *n) {
Tunnel *t = IPIP(n);
diff --git a/src/network/netdev/tunnel.h b/src/network/netdev/tunnel.h
index 40ddb1c043..24721e87cd 100644
--- a/src/network/netdev/tunnel.h
+++ b/src/network/netdev/tunnel.h
@@ -3,6 +3,7 @@
#include "in-addr-util.h"
+#include "conf-parser.h"
#include "netdev/netdev.h"
#include "netdev/fou-tunnel.h"
@@ -50,6 +51,9 @@ typedef struct Tunnel {
uint16_t encap_src_port;
uint16_t fou_destination_port;
+
+ struct in6_addr sixrd_prefix;
+ uint8_t sixrd_prefixlen;
} Tunnel;
DEFINE_NETDEV_CAST(IPIP, Tunnel);
@@ -108,3 +112,5 @@ int config_parse_tunnel_key(const char *unit, const char *filename,
unsigned section_line, const char *lvalue,
int ltype, const char *rvalue, void *data,
void *userdata);
+
+CONFIG_PARSER_PROTOTYPE(config_parse_6rd_prefix);