blob: 4c7a0a33a3599a1fcee5cb6dd6190e180356fe40 [file] [log] [blame]
Brad Bishop96ff1982019-08-19 13:50:42 -04001From 6bd76d2d4ff130decd3aa13e0c2dbfd56ff8d7b7 Mon Sep 17 00:00:00 2001
Joel Stanley3cd63892019-07-10 11:55:13 +09302From: Susant Sahani <ssahani@gmail.com>
3Date: Thu, 9 May 2019 07:35:35 +0530
Brad Bishop96ff1982019-08-19 13:50:42 -04004Subject: [PATCH] networkd: fix link_up() (#12505)
Joel Stanley3cd63892019-07-10 11:55:13 +09305
6Fillup IFLA_INET6_ADDR_GEN_MODE while we do link_up.
7
8Fixes the following error:
9```
10dummy-test: Could not bring up interface: Invalid argument
11```
12
13After reading the kernel code when we do a link up
14```
15net/core/rtnetlink.c
16IFLA_AF_SPEC
17 af_ops->set_link_af(dev, af);
18 inet6_set_link_af
19 if (tb[IFLA_INET6_ADDR_GEN_MODE])
20 Here it looks for IFLA_INET6_ADDR_GEN_MODE
21```
22Since link up we didn't filling up that it's failing.
23
24Closes #12504.
25
Brad Bishop96ff1982019-08-19 13:50:42 -040026Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com>
27
28Upstream-Status: Backport [https://github.com/systemd/systemd/commit/4eb086a38712ea98faf41e075b84555b11b54362.patch]
29
Joel Stanley3cd63892019-07-10 11:55:13 +093030---
31 src/network/networkd-link.c | 15 +++++++++++++++
32 1 file changed, 15 insertions(+)
33
34diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
Brad Bishop96ff1982019-08-19 13:50:42 -040035index e466b96792..042496173c 100644
Joel Stanley3cd63892019-07-10 11:55:13 +093036--- a/src/network/networkd-link.c
37+++ b/src/network/networkd-link.c
Brad Bishop96ff1982019-08-19 13:50:42 -040038@@ -2034,6 +2034,8 @@ static int link_up(Link *link) {
Joel Stanley3cd63892019-07-10 11:55:13 +093039 }
40
41 if (link_ipv6_enabled(link)) {
42+ uint8_t ipv6ll_mode;
43+
44 r = sd_netlink_message_open_container(req, IFLA_AF_SPEC);
45 if (r < 0)
46 return log_link_error_errno(link, r, "Could not open IFLA_AF_SPEC container: %m");
Brad Bishop96ff1982019-08-19 13:50:42 -040047@@ -2049,6 +2051,19 @@ static int link_up(Link *link) {
Joel Stanley3cd63892019-07-10 11:55:13 +093048 return log_link_error_errno(link, r, "Could not append IFLA_INET6_TOKEN: %m");
49 }
50
51+ if (!link_ipv6ll_enabled(link))
52+ ipv6ll_mode = IN6_ADDR_GEN_MODE_NONE;
53+ else if (sysctl_read_ip_property(AF_INET6, link->ifname, "stable_secret", NULL) < 0)
54+ /* The file may not exist. And event if it exists, when stable_secret is unset,
55+ * reading the file fails with EIO. */
56+ ipv6ll_mode = IN6_ADDR_GEN_MODE_EUI64;
57+ else
58+ ipv6ll_mode = IN6_ADDR_GEN_MODE_STABLE_PRIVACY;
59+
60+ r = sd_netlink_message_append_u8(req, IFLA_INET6_ADDR_GEN_MODE, ipv6ll_mode);
61+ if (r < 0)
62+ return log_link_error_errno(link, r, "Could not append IFLA_INET6_ADDR_GEN_MODE: %m");
63+
64 r = sd_netlink_message_close_container(req);
65 if (r < 0)
66 return log_link_error_errno(link, r, "Could not close AF_INET6 container: %m");