]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: set IFLA_INET6_ADDR_GEN_MODE as per stable_secret
authorTom Yan <tom.ty89@gmail.com>
Wed, 25 May 2016 12:04:01 +0000 (20:04 +0800)
committerTom Yan <tom.ty89@gmail.com>
Wed, 25 May 2016 12:04:01 +0000 (20:04 +0800)
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.

src/basic/missing.h
src/network/networkd-link.c

index 651e414395113f73b994e27f1c58e0992905108d..9b4be5e3d0db2e374183f43bb70f23733a6fab8d 100644 (file)
@@ -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
index a021fc886f315995f86365b9055e3d082d9715f9..9d2f244087ec66beb19514c2f0f150ec017bf9f5 100644 (file)
@@ -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");