Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 1 | From 6bd76d2d4ff130decd3aa13e0c2dbfd56ff8d7b7 Mon Sep 17 00:00:00 2001 |
Joel Stanley | 3cd6389 | 2019-07-10 11:55:13 +0930 | [diff] [blame] | 2 | From: Susant Sahani <ssahani@gmail.com> |
| 3 | Date: Thu, 9 May 2019 07:35:35 +0530 |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 4 | Subject: [PATCH] networkd: fix link_up() (#12505) |
Joel Stanley | 3cd6389 | 2019-07-10 11:55:13 +0930 | [diff] [blame] | 5 | |
| 6 | Fillup IFLA_INET6_ADDR_GEN_MODE while we do link_up. |
| 7 | |
| 8 | Fixes the following error: |
| 9 | ``` |
| 10 | dummy-test: Could not bring up interface: Invalid argument |
| 11 | ``` |
| 12 | |
| 13 | After reading the kernel code when we do a link up |
| 14 | ``` |
| 15 | net/core/rtnetlink.c |
| 16 | IFLA_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 | ``` |
| 22 | Since link up we didn't filling up that it's failing. |
| 23 | |
| 24 | Closes #12504. |
| 25 | |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 26 | Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> |
| 27 | |
| 28 | Upstream-Status: Backport [https://github.com/systemd/systemd/commit/4eb086a38712ea98faf41e075b84555b11b54362.patch] |
| 29 | |
Joel Stanley | 3cd6389 | 2019-07-10 11:55:13 +0930 | [diff] [blame] | 30 | --- |
| 31 | src/network/networkd-link.c | 15 +++++++++++++++ |
| 32 | 1 file changed, 15 insertions(+) |
| 33 | |
| 34 | diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 35 | index e466b96792..042496173c 100644 |
Joel Stanley | 3cd6389 | 2019-07-10 11:55:13 +0930 | [diff] [blame] | 36 | --- a/src/network/networkd-link.c |
| 37 | +++ b/src/network/networkd-link.c |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 38 | @@ -2034,6 +2034,8 @@ static int link_up(Link *link) { |
Joel Stanley | 3cd6389 | 2019-07-10 11:55:13 +0930 | [diff] [blame] | 39 | } |
| 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 Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 47 | @@ -2049,6 +2051,19 @@ static int link_up(Link *link) { |
Joel Stanley | 3cd6389 | 2019-07-10 11:55:13 +0930 | [diff] [blame] | 48 | 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"); |