From 8107f4731e43b5571a40aa5df881dd8b5f0d3fe6 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 17 Jul 2019 09:40:06 +0900 Subject: [PATCH 1/6] network: drop fallback mechanism to assign DHCPv6 addresses with IFA_F_NOPREFIXROUTE The flag IFA_F_NOPREFIXROUTE was introduced in kernel-3.14. But even if the kernel does not support the flag, it should be just ignored. So, it is not necessary to do the fallback logic. Moreover, the current logic is not a fallback mechanism but just retrying. So, it should not work. Let's drop that. --- src/network/networkd-dhcp6.c | 13 +------------ src/network/networkd-link.c | 1 - src/network/networkd-link.h | 1 - 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index 7905e09a48..0a011c5b38 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -405,21 +405,10 @@ static int dhcp6_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link * r = sd_netlink_message_get_errno(m); if (r < 0 && r != -EEXIST) { - if (link->rtnl_extended_attrs) { - log_link_warning(link, "Could not set extended netlink attributes, reverting to fallback mechanism"); - - link->rtnl_extended_attrs = false; - dhcp6_lease_address_acquired(link->dhcp6_client, link); - - return 1; - } - log_link_error_errno(link, r, "Could not set DHCPv6 address: %m"); - link_enter_failed(link); return 1; - } - if (r >= 0) + } else if (r >= 0) (void) manager_rtnl_process_address(rtnl, m, link->manager); r = link_request_set_routes(link); diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index a08ad80f15..63f7422096 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -605,7 +605,6 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) { .n_ref = 1, .manager = manager, .state = LINK_STATE_PENDING, - .rtnl_extended_attrs = true, .ifindex = ifindex, .iftype = iftype, .sysctl_ipv6_enabled = -1, diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h index e8680bbb1f..bfdcef0e50 100644 --- a/src/network/networkd-link.h +++ b/src/network/networkd-link.h @@ -113,7 +113,6 @@ typedef struct Link { sd_radv *radv; sd_dhcp6_client *dhcp6_client; - bool rtnl_extended_attrs; /* This is about LLDP reception */ sd_lldp *lldp; From 2eff7cc59c7fe205c249ab218a42f3a520845e4a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 17 Jul 2019 09:46:36 +0900 Subject: [PATCH 2/6] network: drop unnecessary line breaks --- src/network/networkd-dhcp6.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index 0a011c5b38..9d552761c7 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -436,10 +436,8 @@ static int dhcp6_address_change( addr->family = AF_INET6; addr->in_addr.in6 = *ip6_addr; - addr->flags = IFA_F_NOPREFIXROUTE; addr->prefixlen = 128; - addr->cinfo.ifa_prefered = lifetime_preferred; addr->cinfo.ifa_valid = lifetime_valid; From 26a65470bafddce12103b4702623a74829501777 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 17 Jul 2019 10:21:07 +0900 Subject: [PATCH 3/6] network: fix use after free() The hashmap will be accessed by client_stop(). --- src/network/networkd-manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 51cc8f654b..6037e8564f 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -1395,7 +1395,7 @@ void manager_free(Manager *m) { while ((a = hashmap_first_key(m->dhcp6_prefixes))) (void) dhcp6_prefix_remove(m, a); - hashmap_free(m->dhcp6_prefixes); + m->dhcp6_prefixes = hashmap_free(m->dhcp6_prefixes); while ((link = hashmap_steal_first(m->links))) { if (link->dhcp6_client) From 9fdae8d5b2a7e81ad6e9ad7e09aa80bfe7c290f0 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 17 Jul 2019 10:07:42 +0900 Subject: [PATCH 4/6] man: fix wrong section name --- man/systemd.network.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index e9c46187ad..cd1aa73f46 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1559,7 +1559,7 @@ UseDNS= UseNTP= - As in the [DHCP] section. + As in the [DHCPv4] section. From 693283cd58be248061cf99c88b84aa891680a369 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 17 Jul 2019 23:03:01 +0900 Subject: [PATCH 5/6] Revert "test-network: extend sleep time" This reverts commit 7d7bb5c8613b774bf77c531f46d31ee20d7a1b1e. Still the CIs are flaky and the commit just slow down them. --- test/test-network/systemd-networkd-tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 7d059f47e7..9ef9b023e9 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -2905,7 +2905,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4') self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6') - time.sleep(10) + time.sleep(3) output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env) print(output) self.assertRegex(output, '192.168.5.1') @@ -2923,7 +2923,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4') self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6') - time.sleep(10) + time.sleep(3) output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env) print(output) self.assertNotRegex(output, '192.168.5.1') @@ -2941,7 +2941,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4') self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6') - time.sleep(10) + time.sleep(3) output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env) print(output) self.assertRegex(output, '192.168.5.1') @@ -2959,7 +2959,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4') self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6') - time.sleep(10) + time.sleep(3) output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env) print(output) self.assertRegex(output, '192.168.5.1') From 6787917dfa423e71745a9332ff11d62094e03a5a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 17 Jul 2019 23:12:07 +0900 Subject: [PATCH 6/6] network: update state file after dhcp6 events E.g. DNS servers may be received from DHCPv6 server. If the link is already in configured state, the DNS servers are not written in the state file. --- src/network/networkd-dhcp6.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index 9d552761c7..d6262a3885 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -497,6 +497,7 @@ static void dhcp6_handler(sd_dhcp6_client *client, int event, void *userdata) { (void) dhcp6_lease_pd_prefix_lost(client, link); (void) dhcp6_prefix_remove_all(link->manager, link); + link_dirty(link); link->dhcp6_configured = false; break; @@ -519,6 +520,7 @@ static void dhcp6_handler(sd_dhcp6_client *client, int event, void *userdata) { return; } + link_dirty(link); link->dhcp6_configured = true; break;