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