nd6: restore a missing reachability confirmation
On sending a packet over a STALE cache, the cache should be tried a reachability confirmation, which is described in RFC 2461/4861 7.3.3. On the fast path in nd6_resolve, however, the treatment for STALE caches has been skipped accidentally. So STALE caches never be back to the REACHABLE state. To fix the issue, branch to the fast path only when the cache entry is the REACHABLE state and leave other caches to the slow path that includes the treatment. To this end we need to allow to return a link-layer address if a valid address is available on the slow path too, which is the same behavior as FreeBSD and OpenBSD.
This commit is contained in:
parent
05bd368781
commit
0ec6d93dcf
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nd6.c,v 1.254 2019/05/13 02:03:07 christos Exp $ */
|
||||
/* $NetBSD: nd6.c,v 1.255 2019/06/28 06:45:16 ozaki-r Exp $ */
|
||||
/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.254 2019/05/13 02:03:07 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.255 2019/06/28 06:45:16 ozaki-r Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_net_mpsafe.h"
|
||||
|
@ -2319,8 +2319,8 @@ nd6_resolve(struct ifnet *ifp, const struct rtentry *rt, struct mbuf *m,
|
|||
/* Look up the neighbor cache for the nexthop */
|
||||
ln = nd6_lookup(&dst->sin6_addr, ifp, false);
|
||||
|
||||
if (ln != NULL && (ln->la_flags & LLE_VALID) != 0) {
|
||||
KASSERT(ln->ln_state > ND6_LLINFO_INCOMPLETE);
|
||||
if (ln != NULL && (ln->la_flags & LLE_VALID) != 0 &&
|
||||
ln->ln_state == ND6_LLINFO_REACHABLE) {
|
||||
/* Fast path */
|
||||
memcpy(lldst, &ln->ll_addr, MIN(dstsize, ifp->if_addrlen));
|
||||
LLE_RUNLOCK(ln);
|
||||
|
@ -2382,6 +2382,18 @@ nd6_resolve(struct ifnet *ifp, const struct rtentry *rt, struct mbuf *m,
|
|||
nd6_llinfo_settimer(ln, nd6_delay * hz);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the neighbor cache entry has a state other than INCOMPLETE
|
||||
* (i.e. its link-layer address is already resolved), just
|
||||
* send the packet.
|
||||
*/
|
||||
if (ln->ln_state > ND6_LLINFO_INCOMPLETE) {
|
||||
KASSERT((ln->la_flags & LLE_VALID) != 0);
|
||||
memcpy(lldst, &ln->ll_addr, MIN(dstsize, ifp->if_addrlen));
|
||||
LLE_WUNLOCK(ln);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* There is a neighbor cache entry, but no ethernet address
|
||||
* response yet. Append this latest packet to the end of the
|
||||
|
|
Loading…
Reference in New Issue