Skip to content

Commit

Permalink
net: if: Setup DAD timer regardless of DAD query result
Browse files Browse the repository at this point in the history
In rare occasions when sending DAD NS packet fails, we should still
setup the DAD timer, unless we implement some kind of more advanced
retry mechanism. If we don't do that, the IPv6 address added to the
interface will never be usable in such cases.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 008a7ca)
  • Loading branch information
rlubos authored and github-actions[bot] committed Feb 19, 2025
1 parent 4230d58 commit 47ee608
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions subsys/net/ip/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,21 +1295,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));

Check notice on line 1301 in subsys/net/ip/net_if.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/net/ip/net_if.c:1301 - NET_ERR("Interface %p failed to send DAD query for %s", - iface, + NET_ERR("Interface %p failed to send DAD query for %s", iface,

Check notice on line 1301 in subsys/net/ip/net_if.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/net/ip/net_if.c:1301 - NET_ERR("Interface %p failed to send DAD query for %s", - iface, + NET_ERR("Interface %p failed to send DAD query for %s", iface,
}

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));
}

Check notice on line 1317 in subsys/net/ip/net_if.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/net/ip/net_if.c:1317 - sys_slist_find_and_remove(&active_dad_timers, - &ifaddr->dad_node); + 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)); + k_work_reschedule(&dad_timer, K_MSEC(DAD_TIMEOUT));

Check notice on line 1317 in subsys/net/ip/net_if.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/net/ip/net_if.c:1317 - sys_slist_find_and_remove(&active_dad_timers, - &ifaddr->dad_node); + 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)); + k_work_reschedule(&dad_timer, K_MSEC(DAD_TIMEOUT));
} else {
NET_DBG("Interface %p is down, starting DAD for %s later.",
Expand Down

0 comments on commit 47ee608

Please sign in to comment.