summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-ipv4acd.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-08-18 08:39:22 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-08-18 08:44:39 +0200
commit03ff3c5a466cef45ebfd9353eecdfba89281886a (patch)
tree8c7a59b0204b1adbf319f1565a7fe7f20caebc18 /src/network/networkd-ipv4acd.c
parentnetwork: update setting for IPv4ACD or IPv6DAD in existing Address objects (diff)
downloadsystemd-03ff3c5a466cef45ebfd9353eecdfba89281886a.tar.xz
systemd-03ff3c5a466cef45ebfd9353eecdfba89281886a.zip
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.
Diffstat (limited to 'src/network/networkd-ipv4acd.c')
-rw-r--r--src/network/networkd-ipv4acd.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/network/networkd-ipv4acd.c b/src/network/networkd-ipv4acd.c
index f55e998f23..a633575444 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);