diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 388e48879b1..5de5f2def86 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1377,8 +1378,9 @@ nd6_is_new_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp) int nd6_is_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp) { + struct nhop6_basic nh6; struct llentry *lle; - int rc = 0; + int fibnum, rc = 0; IF_AFDATA_UNLOCK_ASSERT(ifp); if (nd6_is_new_addr_neighbor(addr, ifp)) @@ -1394,6 +1396,21 @@ nd6_is_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp) rc = 1; } IF_AFDATA_RUNLOCK(ifp); + + /* + * Check that address is in the routing table. + * This covers non-prefix on-link INET6 routes. + */ + if (rc == 0) { + fibnum = V_rt_add_addr_allfibs ? RT_DEFAULT_FIB: ifp->if_fib; + rc = fib6_lookup_nh_basic(fibnum, + &addr->sin6_addr, 0, 0, 0, &nh6); + if (rc || (nh6.nh_flags & NHF_GATEWAY) || ifp != nh6.nh_ifp) + rc = 0; + else + rc = 1; + } + return (rc); }