Fix bug #55972: The Neighbour Solicitation used to do IPv6 address resolution was wrong

Apply patch from Gao Qingshui
This commit is contained in:
Dirk Ziegelmeier 2019-03-24 21:34:08 +01:00 committed by Simon Goldschmidt
parent e60f9bb24f
commit 6b9264b49e

View File

@ -1187,10 +1187,22 @@ nd6_send_ns(struct netif *netif, const ip6_addr_t *target_addr, u8_t flags)
LWIP_ASSERT("target address is required", target_addr != NULL); LWIP_ASSERT("target address is required", target_addr != NULL);
if (!(flags & ND6_SEND_FLAG_ANY_SRC) && if (!(flags & ND6_SEND_FLAG_ANY_SRC)) {
ip6_addr_isvalid(netif_ip6_addr_state(netif,0))) { int i;
/* Use link-local address as source address. */ for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
src_addr = netif_ip6_addr(netif, 0); if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
ip6_addr_netcmp(target_addr, netif_ip6_addr(netif, i))) {
src_addr = netif_ip6_addr(netif, i);
break;
}
}
if (i == LWIP_IPV6_NUM_ADDRESSES) {
LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_WARNING, ("ICMPv6 NS: no available src address\n"));
ND6_STATS_INC(nd6.err);
return;
}
/* calculate option length (in 8-byte-blocks) */ /* calculate option length (in 8-byte-blocks) */
lladdr_opt_len = ((netif->hwaddr_len + 2) + 7) >> 3; lladdr_opt_len = ((netif->hwaddr_len + 2) + 7) >> 3;
} else { } else {