Skip to content

Commit 3bef10f

Browse files
arbraunscarlescufi
authored andcommitted
net: ip: always cancel IPv6 DAD when address is removed
If the address was removed immediately after being added (e.g. because the interface MAC address is changed on boot), it would remain in the DAD timer list. In one scenario, the DAD timeout would eventually fire, causing the now-removed address to be modified, potentially causing issues that way. In another scenario, if the interface was immediately brought back up again with a different link-local address, this new address would reuse the first address slot on the interface. Starting the DAD process for this new address would lead to the same address slot being added to the DAD timer list a second time, causing an infinite list and associated lockup during iteration. Always remove the address from the DAD timer list when it is removed from the interface, not just when DAD fails. Signed-off-by: Armin Brauns <[email protected]>
1 parent 8a65b3f commit 3bef10f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

subsys/net/ip/net_if.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -1337,10 +1337,6 @@ void net_if_ipv6_dad_failed(struct net_if *iface, const struct in6_addr *addr)
13371337
}
13381338

13391339

1340-
k_mutex_lock(&lock, K_FOREVER);
1341-
sys_slist_find_and_remove(&active_dad_timers, &ifaddr->dad_node);
1342-
k_mutex_unlock(&lock);
1343-
13441340
net_mgmt_event_notify_with_info(NET_EVENT_IPV6_DAD_FAILED, iface,
13451341
&ifaddr->address.in6_addr,
13461342
sizeof(struct in6_addr));
@@ -1850,6 +1846,14 @@ bool net_if_ipv6_addr_rm(struct net_if *iface, const struct in6_addr *addr)
18501846
k_mutex_unlock(&lock);
18511847
}
18521848

1849+
#if defined(CONFIG_NET_IPV6_DAD)
1850+
if (!net_if_flag_is_set(iface, NET_IF_IPV6_NO_ND)) {
1851+
k_mutex_lock(&lock, K_FOREVER);
1852+
sys_slist_find_and_remove(&active_dad_timers, &ipv6->unicast[i].dad_node);
1853+
k_mutex_unlock(&lock);
1854+
}
1855+
#endif
1856+
18531857
ipv6->unicast[i].is_used = false;
18541858

18551859
net_ipv6_addr_create_solicited_node(addr, &maddr);

0 commit comments

Comments
 (0)