Merge pull request #11232 from yuwata/fix-9130-alternative

network: always check link is ready when address is updated
This commit is contained in:
Yu Watanabe 2019-01-08 12:22:21 +09:00 committed by GitHub
commit c226800996
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 20 deletions

View file

@ -351,18 +351,17 @@ int address_update(
address->cinfo = *cinfo;
link_update_operstate(address->link);
link_check_ready(address->link);
if (!ready && address_is_ready(address)) {
link_check_ready(address->link);
if (!ready &&
address_is_ready(address) &&
address->family == AF_INET6 &&
in_addr_is_link_local(AF_INET6, &address->in_addr) > 0 &&
in_addr_is_null(AF_INET6, (const union in_addr_union*) &address->link->ipv6ll_address) > 0) {
if (address->family == AF_INET6 &&
in_addr_is_link_local(AF_INET6, &address->in_addr) > 0 &&
in_addr_is_null(AF_INET6, (const union in_addr_union*) &address->link->ipv6ll_address) > 0) {
r = link_ipv6ll_gained(address->link, &address->in_addr.in6);
if (r < 0)
return r;
}
r = link_ipv6ll_gained(address->link, &address->in_addr.in6);
if (r < 0)
return r;
}
return 0;
@ -632,14 +631,10 @@ int address_configure(
r = sd_netlink_message_append_in6_addr(req, IFA_ADDRESS, &address->in_addr_peer.in6);
if (r < 0)
return log_error_errno(r, "Could not append IFA_ADDRESS attribute: %m");
} else {
if (address->family == AF_INET) {
if (address->prefixlen <= 30) {
r = sd_netlink_message_append_in_addr(req, IFA_BROADCAST, &address->broadcast);
if (r < 0)
return log_error_errno(r, "Could not append IFA_BROADCAST attribute: %m");
}
}
} else if (address->family == AF_INET && address->prefixlen <= 30) {
r = sd_netlink_message_append_in_addr(req, IFA_BROADCAST, &address->broadcast);
if (r < 0)
return log_error_errno(r, "Could not append IFA_BROADCAST attribute: %m");
}
if (address->label) {
@ -648,8 +643,7 @@ int address_configure(
return log_error_errno(r, "Could not append IFA_LABEL attribute: %m");
}
r = sd_netlink_message_append_cache_info(req, IFA_CACHEINFO,
&address->cinfo);
r = sd_netlink_message_append_cache_info(req, IFA_CACHEINFO, &address->cinfo);
if (r < 0)
return log_error_errno(r, "Could not append IFA_CACHEINFO attribute: %m");

View file

@ -1,6 +1,9 @@
[Match]
Name=dummy98
[Network]
IPv6AcceptRA=no
[Address]
Address=10.2.3.4/16
Peer=10.2.3.5/16

View file

@ -649,6 +649,21 @@ class NetworkdNetWorkTests(unittest.TestCase, Utilities):
subprocess.call(['ip', 'rule', 'del', 'table', '7'])
def test_address_peer(self):
self.copy_unit_to_networkd_unit_path('25-address-section.network', '12-dummy.netdev')
self.start_networkd()
self.assertTrue(self.link_exits('dummy98'))
output = subprocess.check_output(['ip', 'address', 'show', 'dummy98']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, 'inet 10.2.3.4 peer 10.2.3.5/16 scope global 32')
self.assertRegex(output, 'inet 10.6.7.8/16 brd 10.6.255.255 scope global 33')
output = subprocess.check_output(['networkctl', 'status', 'dummy98']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, 'State: routable \(configured\)')
def test_address_preferred_lifetime_zero_ipv6(self):
self.copy_unit_to_networkd_unit_path('25-address-section-miscellaneous.network', '12-dummy.netdev')
self.start_networkd()