blob: c359a1f3305928b2735907582f9b4677335bf27a [file] [log] [blame]
Joel Stanley3cd63892019-07-10 11:55:13 +09301From e6be20d87c400258a966b0bb0e1c4c94b91017df Mon Sep 17 00:00:00 2001
2From: Yu Watanabe <watanabe.yu+github@gmail.com>
3Date: Thu, 9 May 2019 14:39:46 +0900
4Subject: [PATCH 2/2] network: do not send ipv6 token to kernel
5
6We disabled kernel RA support. Then, we should not send
7IFLA_INET6_TOKEN.
8Thus, we do not need to send IFLA_INET6_ADDR_GEN_MODE twice.
9
10Follow-up for 0e2fdb83bb5e22047e0c7cc058b415d0e93f02cf and
114eb086a38712ea98faf41e075b84555b11b54362.
12
13Signed-off-by: Joel Stanley <joel@jms.id.au>
14---
15 src/network/networkd-link.c | 51 +++++--------------------------------
16 1 file changed, 6 insertions(+), 45 deletions(-)
17
18diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
19index 3a0706e0a894..b709aaa71b4d 100644
20--- a/src/network/networkd-link.c
21+++ b/src/network/networkd-link.c
22@@ -1985,6 +1985,9 @@ static int link_configure_addrgen_mode(Link *link) {
23 assert(link->manager);
24 assert(link->manager->rtnl);
25
26+ if (!socket_ipv6_is_supported())
27+ return 0;
28+
29 log_link_debug(link, "Setting address genmode for link");
30
31 r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
32@@ -2078,46 +2081,6 @@ static int link_up(Link *link) {
33 return log_link_error_errno(link, r, "Could not set MAC address: %m");
34 }
35
36- if (link_ipv6_enabled(link)) {
37- uint8_t ipv6ll_mode;
38-
39- r = sd_netlink_message_open_container(req, IFLA_AF_SPEC);
40- if (r < 0)
41- return log_link_error_errno(link, r, "Could not open IFLA_AF_SPEC container: %m");
42-
43- /* if the kernel lacks ipv6 support setting IFF_UP fails if any ipv6 options are passed */
44- r = sd_netlink_message_open_container(req, AF_INET6);
45- if (r < 0)
46- return log_link_error_errno(link, r, "Could not open AF_INET6 container: %m");
47-
48- if (!in_addr_is_null(AF_INET6, &link->network->ipv6_token)) {
49- r = sd_netlink_message_append_in6_addr(req, IFLA_INET6_TOKEN, &link->network->ipv6_token.in6);
50- if (r < 0)
51- return log_link_error_errno(link, r, "Could not append IFLA_INET6_TOKEN: %m");
52- }
53-
54- if (!link_ipv6ll_enabled(link))
55- ipv6ll_mode = IN6_ADDR_GEN_MODE_NONE;
56- else if (sysctl_read_ip_property(AF_INET6, link->ifname, "stable_secret", NULL) < 0)
57- /* The file may not exist. And event if it exists, when stable_secret is unset,
58- * reading the file fails with EIO. */
59- ipv6ll_mode = IN6_ADDR_GEN_MODE_EUI64;
60- else
61- ipv6ll_mode = IN6_ADDR_GEN_MODE_STABLE_PRIVACY;
62-
63- r = sd_netlink_message_append_u8(req, IFLA_INET6_ADDR_GEN_MODE, ipv6ll_mode);
64- if (r < 0)
65- return log_link_error_errno(link, r, "Could not append IFLA_INET6_ADDR_GEN_MODE: %m");
66-
67- r = sd_netlink_message_close_container(req);
68- if (r < 0)
69- return log_link_error_errno(link, r, "Could not close AF_INET6 container: %m");
70-
71- r = sd_netlink_message_close_container(req);
72- if (r < 0)
73- return log_link_error_errno(link, r, "Could not close IFLA_AF_SPEC container: %m");
74- }
75-
76 r = netlink_call_async(link->manager->rtnl, NULL, req, link_up_handler,
77 link_netlink_destroy_callback, link);
78 if (r < 0)
79@@ -3204,11 +3167,9 @@ static int link_configure(Link *link) {
80 if (r < 0)
81 return r;
82
83- if (socket_ipv6_is_supported()) {
84- r = link_configure_addrgen_mode(link);
85- if (r < 0)
86- return r;
87- }
88+ r = link_configure_addrgen_mode(link);
89+ if (r < 0)
90+ return r;
91
92 return link_configure_after_setting_mtu(link);
93 }
94--
952.20.1
96