1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-28 11:21:59 +03:00

network: unref existing sd_ipv4acd object when not necessary

On reconfiguring an interface, the new setting may not enable IPv4ACD
for an existing address anymore. Hence, we need to unref it. Otherwise,
newly requested addresses may never be ready for (re-)configuring.
This commit is contained in:
Yu Watanabe 2022-08-18 15:39:22 +09:00
parent 3c45d0d099
commit 03ff3c5a46

View File

@ -39,6 +39,26 @@ bool link_ipv4acd_supported(Link *link) {
return true;
}
static bool address_ipv4acd_enabled(Address *address) {
assert(address);
assert(address->link);
if (address->family != AF_INET)
return false;
if (!FLAGS_SET(address->duplicate_address_detection, ADDRESS_FAMILY_IPV4))
return false;
/* Currently, only static and DHCP4 addresses are supported. */
if (!IN_SET(address->source, NETWORK_CONFIG_SOURCE_STATIC, NETWORK_CONFIG_SOURCE_DHCP4))
return false;
if (!link_ipv4acd_supported(address->link))
return false;
return true;
}
bool ipv4acd_bound(const Address *address) {
assert(address);
@ -188,17 +208,11 @@ int ipv4acd_configure(Address *address) {
link = ASSERT_PTR(address->link);
if (address->family != AF_INET)
if (!address_ipv4acd_enabled(address)) {
address->acd = sd_ipv4acd_unref(address->acd);
address->acd_bound = false;
return 0;
if (!FLAGS_SET(address->duplicate_address_detection, ADDRESS_FAMILY_IPV4))
return 0;
if (!link_ipv4acd_supported(link))
return 0;
/* Currently, only static and DHCP4 addresses are supported. */
assert(IN_SET(address->source, NETWORK_CONFIG_SOURCE_STATIC, NETWORK_CONFIG_SOURCE_DHCP4));
}
if (address->acd)
return address_ipv4acd_start(address);