net/lwip : fix RD validation checking routine
This commit is patch to fix RD validation checking routine
- if redirect source address is not the current first-hop router,
do not update caches by using RD options
@@ -860,7 +860,7 @@ void nd6_input(struct pbuf *p, struct netif *inp)
return;
}
- if (!ip6_addr_islinklocal(ip6_current_src_addr()) || (nd6_find_neighbor_cache_entry(ip6_current_src_addr()) < 0)) {
+ if (!ip6_addr_islinklocal(ip6_current_src_addr())) {
pbuf_free(p);
ND6_STATS_INC(nd6.drop);
return;
@@ -874,6 +874,27 @@ void nd6_input(struct pbuf *p, struct netif *inp)
}
}
+ /* Copy original destination address to current source address, to have an aligned copy. */
+ ip6_addr_set(&tmp, &(ND6H_RD_DEST_ADDR(redir_hdr)));
+
+ /* Find dest address in cache */
+ i = nd6_find_destination_cache_entry(&tmp);
+
+ if (i >= 0) {
+ if ((nd6_get_router(&destination_cache[i].next_hop_addr, inp) >= 0)
+ && (!ip6_addr_cmp(&destination_cache[i].next_hop_addr, ip6_current_src_addr()))) {
+ LWIP_DEBUGF(ND6_DEBUG, ("Redirect source address is not the current first-hop router, dropped\n"));
+ pbuf_free(p);
+ ND6_STATS_INC(nd6.drop);
+ return;
+ }
+ } else {
+ /* Destination not in cache, drop packet. */
+ pbuf_free(p);
+ ND6_STATS_INC(nd6.drop);
+ return;
+ }
+
/* End of validation check for RD message */
/* Processing redirect header's option field
@@ -917,17 +938,6 @@ void nd6_input(struct pbuf *p, struct netif *inp)
}
}
- /* Copy original destination address to current source address, to have an aligned copy. */
- ip6_addr_set(&tmp, &(ND6H_RD_DEST_ADDR(redir_hdr)));
-
- /* Find dest address in cache */
- i = nd6_find_destination_cache_entry(&tmp);
- if (i < 0) {
- /* Destination not in cache, drop packet. */
- pbuf_free(p);
- return;
- }
-
/* Set the new target address. */
ip6_addr_set(&(destination_cache[i].next_hop_addr), &(ND6H_RD_TARGET_ADDR(redir_hdr)));
