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.
This commit is contained in:
parent
15fec93be3
commit
fbc38f230b
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue