From 2ff04a931ae85d0e1adc05b59afd95f9eaa4810d Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Tue, 20 Dec 2016 22:11:54 +0000 Subject: [PATCH] nd6: check link status before sending packets In the cases that nd6 checks whether the interface is up before sending a packet, also check whether the link is up. Without this additional check, temporary link downtime could easily result in unnecessary false negatives for Duplicate Address Detection. In addition, use the netif abstraction macros to perform the checks. --- src/core/ipv6/nd6.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/ipv6/nd6.c b/src/core/ipv6/nd6.c index 3cbc571d..3d8a1eba 100644 --- a/src/core/ipv6/nd6.c +++ b/src/core/ipv6/nd6.c @@ -1004,7 +1004,7 @@ nd6_tmr(void) } #endif /* LWIP_IPV6_ADDRESS_LIFETIMES */ netif_ip6_addr_set_state(netif, i, addr_state); - } else if (netif->flags & NETIF_FLAG_UP) { + } else if (netif_is_up(netif) && netif_is_link_up(netif)) { /* Send a NS for this address. */ nd6_send_ns(netif, netif_ip6_addr(netif, i), ND6_SEND_FLAG_MULTICAST_DEST); /* tentative: set next state by increasing by one */ @@ -1017,7 +1017,8 @@ nd6_tmr(void) #if LWIP_IPV6_SEND_ROUTER_SOLICIT /* Send router solicitation messages, if necessary. */ for (netif = netif_list; netif != NULL; netif = netif->next) { - if ((netif->rs_count > 0) && (netif->flags & NETIF_FLAG_UP) && + if ((netif->rs_count > 0) && netif_is_up(netif) && + netif_is_link_up(netif) && !ip6_addr_isinvalid(netif_ip6_addr_state(netif, 0)) && !ip6_addr_isduplicated(netif_ip6_addr_state(netif, 0))) { if (nd6_send_rs(netif) == ERR_OK) {