Skip to content

Commit bd4c0b7

Browse files
jukkardkalowsk
authored andcommitted
net: acd: Avoid removing auto IPv4 address twice
When the network interface goes down, we call net_ipv4_autoconf_reset() which removes the autoaddress from the network interface. The net_ipv4_autoconf_reset() is also called when ACD is started in which case we could see this error message <dbg> net_if_start_acd: Starting ACD for iface 2 <err> net_if: iface 2 addr 169.254.174.230 (net_if_ipv4_addr_rm():4625) <dbg> net_if_ipv4_addr_rm: Address 169.254.174.230 not found (-22) This error is superfluous and not needed. So before trying to remove the address, check if the interface already has it set and only then remove it. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
1 parent 902c95a commit bd4c0b7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

subsys/net/ip/ipv4_autoconf.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,18 @@ void net_ipv4_autoconf_start(struct net_if *iface)
138138
void net_ipv4_autoconf_reset(struct net_if *iface)
139139
{
140140
struct net_if_config *cfg;
141+
struct net_if_addr *ifaddr;
142+
struct net_if *ret;
141143

142144
cfg = net_if_get_config(iface);
143145
if (!cfg) {
144146
return;
145147
}
146148

147-
net_if_ipv4_addr_rm(iface, &cfg->ipv4auto.requested_ip);
149+
ifaddr = net_if_ipv4_addr_lookup(&cfg->ipv4auto.requested_ip, &ret);
150+
if (ifaddr != NULL && ret == iface) {
151+
net_if_ipv4_addr_rm(iface, &cfg->ipv4auto.requested_ip);
152+
}
148153

149154
NET_DBG("Autoconf reset for %p", iface);
150155
}

0 commit comments

Comments
 (0)