Skip to content

Commit 8e4856c

Browse files
rlubosnashif
authored andcommitted
net: ipv6: Fix neighbor registration based on received RA message
When Router Advertisement with Source Link-Layer Address option is received, host should register a new neighbor marked as STALE (RFC 4861, ch. 6.3.4). This behavior was broken however, because we always added a new neighbor in INCOMPLETE state before processing SLLA option. In result, the entry was not updated to the STALE state, and a redundant Neighbor Solicitation was sent. Fix this by moving the code responsible for adding neighbor in INCOMPLETE state after options processing, and only as a fallback behavior if the SLLA option was not present. Signed-off-by: Robert Lubos <[email protected]> (cherry picked from commit fce5392)
1 parent 32f69a4 commit 8e4856c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

subsys/net/ip/ipv6_nbr.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,12 +2559,6 @@ static int handle_ra_input(struct net_icmp_ctx *ctx,
25592559
nd_opt_hdr = (struct net_icmpv6_nd_opt_hdr *)
25602560
net_pkt_get_data(pkt, &nd_access);
25612561

2562-
/* Add neighbor cache entry using link local address, regardless of link layer address
2563-
* presence in Router Advertisement.
2564-
*/
2565-
nbr = net_ipv6_nbr_add(net_pkt_iface(pkt), (struct in6_addr *)NET_IPV6_HDR(pkt)->src, NULL,
2566-
true, NET_IPV6_NBR_STATE_INCOMPLETE);
2567-
25682562
while (nd_opt_hdr) {
25692563
net_pkt_acknowledge_data(pkt, &nd_access);
25702564

@@ -2665,6 +2659,15 @@ static int handle_ra_input(struct net_icmp_ctx *ctx,
26652659
net_pkt_get_data(pkt, &nd_access);
26662660
}
26672661

2662+
if (nbr == NULL) {
2663+
/* Add neighbor cache entry using link local address, regardless
2664+
* of link layer address presence in Router Advertisement.
2665+
*/
2666+
nbr = net_ipv6_nbr_add(net_pkt_iface(pkt),
2667+
(struct in6_addr *)NET_IPV6_HDR(pkt)->src,
2668+
NULL, true, NET_IPV6_NBR_STATE_INCOMPLETE);
2669+
}
2670+
26682671
router = net_if_ipv6_router_lookup(net_pkt_iface(pkt),
26692672
(struct in6_addr *)ip_hdr->src);
26702673
if (router) {

0 commit comments

Comments
 (0)