From 4d5783c847e671999df8399a84dc8df4b40f8c0d Mon Sep 17 00:00:00 2001 From: ume Date: Mon, 1 Apr 2002 15:15:05 +0000 Subject: In nd6_lookup(), check if rt_llinfo is non-NULL to avoid returning an entry that has the LLINFO flag but is not a neighbor cache entry. Obtained from: KAME MFC after: 1 week --- sys/netinet6/nd6.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'sys/netinet6') diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index c5b8101..dfdb4e2 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -867,20 +867,25 @@ nd6_lookup(addr6, create, ifp) rt->rt_refcnt--; /* * Validation for the entry. + * Note that the check for rt_llinfo is necessary because a cloned + * route from a parent route that has the L flag (e.g. the default + * route to a p2p interface) may have the flag, too, while the + * destination is not actually a neighbor. * XXX: we can't use rt->rt_ifp to check for the interface, since * it might be the loopback interface if the entry is for our * own address on a non-loopback interface. Instead, we should - * use rt->rt_ifa->ifa_ifp, which would specify the REAL interface. + * use rt->rt_ifa->ifa_ifp, which would specify the REAL + * interface. */ if ((rt->rt_flags & RTF_GATEWAY) || (rt->rt_flags & RTF_LLINFO) == 0 || - rt->rt_gateway->sa_family != AF_LINK || + rt->rt_gateway->sa_family != AF_LINK || rt->rt_llinfo == NULL || (ifp && rt->rt_ifa->ifa_ifp != ifp)) { if (create) { log(LOG_DEBUG, "nd6_lookup: failed to lookup %s (if = %s)\n", ip6_sprintf(addr6), ifp ? if_name(ifp) : "unspec"); /* xxx more logs... kazu */ } - return(0); + return(NULL); } return(rt); } @@ -933,7 +938,7 @@ nd6_is_addr_neighbor(addr, ifp) * Even if the address matches none of our addresses, it might be * in the neighbor cache. */ - if (nd6_lookup(&addr->sin6_addr, 0, ifp)) + if (nd6_lookup(&addr->sin6_addr, 0, ifp) != NULL) return(1); return(0); -- cgit v1.1