diff options
author | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2015-09-19 11:50:02 +0000 |
---|---|---|
committer | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2015-09-19 11:50:02 +0000 |
commit | 501adf0140ea2a5af2d14f84e4eb2c039204a3d2 (patch) | |
tree | 3e08df158cb900a892d078f9392266e0096b5526 /sys/netinet6/nd6.c | |
parent | 3adbeacc6651fc9255352380045f244602fd3673 (diff) | |
download | src-501adf0140ea2a5af2d14f84e4eb2c039204a3d2.tar.gz src-501adf0140ea2a5af2d14f84e4eb2c039204a3d2.zip |
Cleanup nd6_cache_lladdr(). No functional changes.
* Since new extries are now allocated explicitly, fill in
all the necessary fields for lle _before_ attaching it to the table.
* Remove ND6_LLINFO_INCOMPLETE check which was unused even in
first KAME merge (r53541).
* After that, the only new state that function can set, was
ND6_LLINFO_STALE. Given everything above, simplify logic besides
do_update and is_newentry.
* Fix nd_resolve() comment.
Notes
Notes:
svn path=/head/; revision=287985
Diffstat (limited to 'sys/netinet6/nd6.c')
-rw-r--r-- | sys/netinet6/nd6.c | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 9580d65aad3c..cf9730246dc7 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1689,7 +1689,6 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, int olladdr; int llchange; int flags; - int newstate = 0; uint16_t router = 0; struct sockaddr_in6 sin6; struct mbuf *chain = NULL; @@ -1722,6 +1721,16 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, ln = nd6_alloc(from, 0, ifp); if (ln == NULL) return; + + /* + * Since we already know all the data for the new entry, + * fill it before insertion. + */ + if (lladdr != NULL) { + bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen); + ln->la_flags |= LLE_VALID; + ln->ln_state = ND6_LLINFO_STALE; + } IF_AFDATA_WLOCK(ifp); LLE_WLOCK(ln); /* Prefer any existing lle over newly-created one */ @@ -1767,6 +1776,10 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, * 1 -- y -- (7) * STALE */ + do_update = 0; + if (!is_newentry && llchange != 0) + do_update = 1; /* (3,5) */ + if (lladdr) { /* (3-5) and (7) */ /* * Record source link-layer address @@ -1774,35 +1787,13 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, */ bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen); ln->la_flags |= LLE_VALID; - EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED); - } - - if (!is_newentry) { - if (llchange != 0) { /* (3,5) */ - do_update = 1; - newstate = ND6_LLINFO_STALE; - } else /* (1-2,4) */ - do_update = 0; - } else { - do_update = 1; - if (lladdr == NULL) /* (6) */ - newstate = ND6_LLINFO_NOSTATE; - else /* (7) */ - newstate = ND6_LLINFO_STALE; - } + ln->ln_state = ND6_LLINFO_STALE; - if (do_update) { - /* - * Update the state of the neighbor cache. - */ - ln->ln_state = newstate; + EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED); - if (ln->ln_state == ND6_LLINFO_STALE) { + if (do_update) { if (ln->la_hold != NULL) nd6_grab_holdchain(ln, &chain, &sin6); - } else if (ln->ln_state == ND6_LLINFO_INCOMPLETE) { - /* probe right away */ - nd6_llinfo_settimer_locked((void *)ln, 0); } } @@ -1838,7 +1829,7 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, * for those are not autoconfigured hosts, we explicitly avoid such * cases for safety. */ - if (do_update && router && + if ((do_update || is_newentry) && router && ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV) { /* * guaranteed recursion @@ -2005,7 +1996,7 @@ nd6_resolve(struct ifnet *ifp, int is_gw, struct mbuf *m, /* * Perform fast path for the following cases: * 1) lle state is REACHABLE - * 2) lle state is DELAY (NS message sentNS message sent) + * 2) lle state is DELAY (NS message sent) * * Every other case involves lle modification, so we handle * them separately. |