From: Yu Watanabe Date: Thu, 18 Aug 2022 06:39:22 +0000 (+0900) Subject: network: unref existing sd_ipv4acd object when not necessary X-Git-Tag: v252-rc1~416^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03ff3c5a466cef45ebfd9353eecdfba89281886a;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/network/networkd-ipv4acd.c b/src/network/networkd-ipv4acd.c index f55e998f233..a6335754448 100644 --- a/src/network/networkd-ipv4acd.c +++ b/src/network/networkd-ipv4acd.c @@ -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) - return 0; - - if (!FLAGS_SET(address->duplicate_address_detection, ADDRESS_FAMILY_IPV4)) - return 0; - - if (!link_ipv4acd_supported(link)) + if (!address_ipv4acd_enabled(address)) { + address->acd = sd_ipv4acd_unref(address->acd); + address->acd_bound = false; 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);