summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Yan <tom.ty89@gmail.com>2016-05-25 20:04:01 +0800
committerTom Yan <tom.ty89@gmail.com>2016-05-25 20:04:01 +0800
commitfbc38f230bcc296772f53898fb79cda7075025b8 (patch)
treec7c58252f67d972578fc6ebf8d7975f5a572cb92 /src
parent15fec93be37f12ef6c36a3e8f7dbb1984e1bcfe7 (diff)
networkd: set IFLA_INET6_ADDR_GEN_MODE as per stable_secret
Although networkd has option (LinkLocalAddressing=) to toggle IPv6LL autoconfiguration, when it is enabled, the address is autoconfigured by the kernel, but not networkd. Therefore, we do not statically set IFLA_INET6_ADDR_GEN_MODE to IN6_ADDR_GEN_MODE_EUI64, but dynamically depending on whether stable_secret is set, just as what the kernel does by default. Note that this does NOT affect the global addresses configured by networkd.
Diffstat (limited to 'src')
-rw-r--r--src/basic/missing.h1
-rw-r--r--src/network/networkd-link.c15
2 files changed, 15 insertions, 1 deletions
diff --git a/src/basic/missing.h b/src/basic/missing.h
index 651e414395..9b4be5e3d0 100644
--- a/src/basic/missing.h
+++ b/src/basic/missing.h
@@ -565,6 +565,7 @@ struct btrfs_ioctl_quota_ctl_args {
#define IN6_ADDR_GEN_MODE_EUI64 0
#define IN6_ADDR_GEN_MODE_NONE 1
+#define IN6_ADDR_GEN_MODE_STABLE_PRIVACY 2
#endif
#if !HAVE_DECL_IFLA_MACVLAN_FLAGS
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index a021fc886f..9d2f244087 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1607,7 +1607,20 @@ static int link_up(Link *link) {
if (r < 0)
return log_link_error_errno(link, r, "Could not open AF_INET6 container: %m");
- ipv6ll_mode = link_ipv6ll_enabled(link) ? IN6_ADDR_GEN_MODE_EUI64 : IN6_ADDR_GEN_MODE_NONE;
+ if (!link_ipv6ll_enabled(link))
+ ipv6ll_mode = IN6_ADDR_GEN_MODE_NONE;
+ else {
+ const char *p = NULL;
+ _cleanup_free_ char *stable_secret = NULL;
+
+ p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/stable_secret");
+ r = read_one_line_file(p, &stable_secret);
+
+ if (r < 0)
+ ipv6ll_mode = IN6_ADDR_GEN_MODE_EUI64;
+ else
+ ipv6ll_mode = IN6_ADDR_GEN_MODE_STABLE_PRIVACY;
+ }
r = sd_netlink_message_append_u8(req, IFLA_INET6_ADDR_GEN_MODE, ipv6ll_mode);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFLA_INET6_ADDR_GEN_MODE: %m");