diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index bb569798707cb..58e8acf46eb93 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -1269,21 +1269,25 @@ void net_if_ipv6_start_dad(struct net_if *iface, ifaddr->dad_count = 1U; - if (!net_ipv6_start_dad(iface, ifaddr)) { - ifaddr->dad_start = k_uptime_get_32(); - ifaddr->ifindex = net_if_get_by_iface(iface); - - k_mutex_lock(&lock, K_FOREVER); - sys_slist_find_and_remove(&active_dad_timers, - &ifaddr->dad_node); - sys_slist_append(&active_dad_timers, &ifaddr->dad_node); - k_mutex_unlock(&lock); - - /* FUTURE: use schedule, not reschedule. */ - if (!k_work_delayable_remaining_get(&dad_timer)) { - k_work_reschedule(&dad_timer, - K_MSEC(DAD_TIMEOUT)); - } + if (net_ipv6_start_dad(iface, ifaddr) != 0) { + NET_ERR("Interface %p failed to send DAD query for %s", + iface, + net_sprint_ipv6_addr(&ifaddr->address.in6_addr)); + } + + ifaddr->dad_start = k_uptime_get_32(); + ifaddr->ifindex = net_if_get_by_iface(iface); + + k_mutex_lock(&lock, K_FOREVER); + sys_slist_find_and_remove(&active_dad_timers, + &ifaddr->dad_node); + sys_slist_append(&active_dad_timers, &ifaddr->dad_node); + k_mutex_unlock(&lock); + + /* FUTURE: use schedule, not reschedule. */ + if (!k_work_delayable_remaining_get(&dad_timer)) { + k_work_reschedule(&dad_timer, + K_MSEC(DAD_TIMEOUT)); } } else { NET_DBG("Interface %p is down, starting DAD for %s later.", @@ -4843,8 +4847,13 @@ static void remove_ipv6_ifaddr(struct net_if *iface, #if defined(CONFIG_NET_IPV6_DAD) if (!net_if_flag_is_set(iface, NET_IF_IPV6_NO_ND)) { k_mutex_lock(&lock, K_FOREVER); - sys_slist_find_and_remove(&active_dad_timers, - &ifaddr->dad_node); + if (sys_slist_find_and_remove(&active_dad_timers, + &ifaddr->dad_node)) { + /* Addreess with active DAD timer would still have + * stale entry in the neighbor cache. + */ + net_ipv6_nbr_rm(iface, &ifaddr->address.in6_addr); + } k_mutex_unlock(&lock); } #endif diff --git a/tests/net/conn_mgr_conn/src/test_ifaces.c b/tests/net/conn_mgr_conn/src/test_ifaces.c index 535eee07de80c..bd21197160a50 100644 --- a/tests/net/conn_mgr_conn/src/test_ifaces.c +++ b/tests/net/conn_mgr_conn/src/test_ifaces.c @@ -16,7 +16,7 @@ static void test_iface_init(struct net_if *iface) { /* Fake link layer address is needed to silence assertions inside the net core */ - static uint8_t fake_lladdr[] = { 0x01 }; + static uint8_t fake_lladdr[] = { 0x00, 0x00, 0x5E, 0x00, 0x53, 0x01 }; net_if_set_link_addr(iface, fake_lladdr, sizeof(fake_lladdr), NET_LINK_DUMMY); diff --git a/tests/net/conn_mgr_monitor/src/test_ifaces.c b/tests/net/conn_mgr_monitor/src/test_ifaces.c index 1b7a5080ec1f4..05eda78dfcf77 100644 --- a/tests/net/conn_mgr_monitor/src/test_ifaces.c +++ b/tests/net/conn_mgr_monitor/src/test_ifaces.c @@ -15,7 +15,7 @@ static void test_iface_init(struct net_if *iface) { /* Fake link layer address is needed to silence assertions inside the net core */ - static uint8_t fake_lladdr[] = { 0x01 }; + static uint8_t fake_lladdr[] = { 0x00, 0x00, 0x5E, 0x00, 0x53, 0x01 }; net_if_set_link_addr(iface, fake_lladdr, sizeof(fake_lladdr), NET_LINK_DUMMY);