Skip to content

Commit b1d41f9

Browse files
author
Mika Leppänen
committed
Corrected lwip not to send NS probes when link layer address is not available
1 parent 2adbf72 commit b1d41f9

File tree

1 file changed

+9
-5
lines changed
  • features/FEATURE_LWIP/lwip-interface/lwip/src/core/ipv6

1 file changed

+9
-5
lines changed

features/FEATURE_LWIP/lwip-interface/lwip/src/core/ipv6/lwip_nd6.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ nd6_send_rs(struct netif *netif)
12681268
ip6_addr_set_allrouters_linklocal(&multicast_address);
12691269

12701270
/* Allocate a packet. */
1271-
if (src_addr != IP6_ADDR_ANY6) {
1271+
if (src_addr != IP6_ADDR_ANY6 && netif->hwaddr_len) {
12721272
lladdr_opt_len = ((netif->hwaddr_len + 2) >> 3) + (((netif->hwaddr_len + 2) & 0x07) ? 1 : 0);
12731273
}
12741274
p = pbuf_alloc(PBUF_IP, sizeof(struct rs_header) + (lladdr_opt_len << 3), PBUF_RAM);
@@ -1285,7 +1285,7 @@ nd6_send_rs(struct netif *netif)
12851285
rs_hdr->chksum = 0;
12861286
rs_hdr->reserved = 0;
12871287

1288-
if (src_addr != IP6_ADDR_ANY6) {
1288+
if (src_addr != IP6_ADDR_ANY6 && lladdr_opt_len) {
12891289
/* Include our hw address. */
12901290
lladdr_opt = (struct lladdr_option *)((u8_t*)p->payload + sizeof(struct rs_header));
12911291
lladdr_opt->type = ND6_OPTION_TYPE_SOURCE_LLADDR;
@@ -1736,9 +1736,13 @@ nd6_new_router(const ip6_addr_t *router_addr, struct netif *netif)
17361736
ip6_addr_set(&(neighbor_cache[neighbor_index].next_hop_address), router_addr);
17371737
neighbor_cache[neighbor_index].netif = netif;
17381738
neighbor_cache[neighbor_index].q = NULL;
1739-
neighbor_cache[neighbor_index].state = ND6_INCOMPLETE;
1740-
neighbor_cache[neighbor_index].counter.probes_sent = 1;
1741-
nd6_send_neighbor_cache_probe(&neighbor_cache[neighbor_index], ND6_SEND_FLAG_MULTICAST_DEST);
1739+
if (netif->hwaddr_len) {
1740+
neighbor_cache[neighbor_index].state = ND6_INCOMPLETE;
1741+
neighbor_cache[neighbor_index].counter.probes_sent = 1;
1742+
nd6_send_neighbor_cache_probe(&neighbor_cache[neighbor_index], ND6_SEND_FLAG_MULTICAST_DEST);
1743+
} else {
1744+
neighbor_cache[neighbor_index].state = ND6_STALE;
1745+
}
17421746
}
17431747

17441748
/* Mark neighbor as router. */

0 commit comments

Comments
 (0)