Merge pull request #13069 from yuwata/network-do-not-set-routes-when-carrier-lost
network: do not configure routes when dropping addresses
This commit is contained in:
commit
26408c7d5f
|
@ -103,6 +103,11 @@ static int link_set_dhcp_routes(Link *link) {
|
||||||
if (!link->network->dhcp_use_routes)
|
if (!link->network->dhcp_use_routes)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (!link_has_carrier(link) && !link->network->configure_without_carrier)
|
||||||
|
/* During configuring addresses, the link lost its carrier. As networkd is dropping
|
||||||
|
* the addresses now, let's not configure the routes either. */
|
||||||
|
return 0;
|
||||||
|
|
||||||
table = link_get_dhcp_route_table(link);
|
table = link_get_dhcp_route_table(link);
|
||||||
|
|
||||||
r = sd_dhcp_lease_get_address(link->dhcp_lease, &address);
|
r = sd_dhcp_lease_get_address(link->dhcp_lease, &address);
|
||||||
|
|
|
@ -934,6 +934,11 @@ int link_request_set_routes(Link *link) {
|
||||||
|
|
||||||
link->static_routes_configured = false;
|
link->static_routes_configured = false;
|
||||||
|
|
||||||
|
if (!link_has_carrier(link) && !link->network->configure_without_carrier)
|
||||||
|
/* During configuring addresses, the link lost its carrier. As networkd is dropping
|
||||||
|
* the addresses now, let's not configure the routes either. */
|
||||||
|
return 0;
|
||||||
|
|
||||||
r = link_request_set_routing_policy_rule(link);
|
r = link_request_set_routing_policy_rule(link);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -2815,7 +2815,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'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')
|
self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
|
||||||
|
|
||||||
time.sleep(3)
|
time.sleep(10)
|
||||||
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
|
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
|
||||||
print(output)
|
print(output)
|
||||||
self.assertRegex(output, '192.168.5.1')
|
self.assertRegex(output, '192.168.5.1')
|
||||||
|
@ -2833,7 +2833,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'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')
|
self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
|
||||||
|
|
||||||
time.sleep(3)
|
time.sleep(10)
|
||||||
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
|
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
|
||||||
print(output)
|
print(output)
|
||||||
self.assertNotRegex(output, '192.168.5.1')
|
self.assertNotRegex(output, '192.168.5.1')
|
||||||
|
@ -2851,7 +2851,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'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')
|
self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
|
||||||
|
|
||||||
time.sleep(3)
|
time.sleep(10)
|
||||||
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
|
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
|
||||||
print(output)
|
print(output)
|
||||||
self.assertRegex(output, '192.168.5.1')
|
self.assertRegex(output, '192.168.5.1')
|
||||||
|
@ -2869,7 +2869,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'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')
|
self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
|
||||||
|
|
||||||
time.sleep(3)
|
time.sleep(10)
|
||||||
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
|
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
|
||||||
print(output)
|
print(output)
|
||||||
self.assertRegex(output, '192.168.5.1')
|
self.assertRegex(output, '192.168.5.1')
|
||||||
|
|
Loading…
Reference in a new issue