[posix] enable receiving Neighbor Advertisement on infra interface (#8521)

This commit enables receiving Neighbor Advertisements (NA) on the
infra link.

OTBR relies on receiving Neighbor Advertisement to check if a router
is active. Without receiving NA, OTBR may wrongly see a router as
inactive and remove the discovered prefixes from Network Data too
early, which breaks the border routing feature.
This commit is contained in:
whd
2022-12-15 05:28:17 +08:00
committed by GitHub
parent 144d480ca9
commit 01f9e89ffb
+2 -1
View File
@@ -132,10 +132,11 @@ int CreateIcmp6Socket(void)
sock = SocketWithCloseExec(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6, kSocketBlock);
VerifyOrDie(sock != -1, OT_EXIT_ERROR_ERRNO);
// Only accept router advertisements and solicitations.
// Only accept Router Advertisements, Router Solicitations and Neighbor Advertisements.
ICMP6_FILTER_SETBLOCKALL(&filter);
ICMP6_FILTER_SETPASS(ND_ROUTER_SOLICIT, &filter);
ICMP6_FILTER_SETPASS(ND_ROUTER_ADVERT, &filter);
ICMP6_FILTER_SETPASS(ND_NEIGHBOR_ADVERT, &filter);
rval = setsockopt(sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filter, sizeof(filter));
VerifyOrDie(rval == 0, OT_EXIT_ERROR_ERRNO);