Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Sep 2015 11:50:03 +0000 (UTC)
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r287985 - head/sys/netinet6
Message-ID:  <201509191150.t8JBo3mL066339@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: melifaro
Date: Sat Sep 19 11:50:02 2015
New Revision: 287985
URL: https://svnweb.freebsd.org/changeset/base/287985

Log:
  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.

Modified:
  head/sys/netinet6/nd6.c

Modified: head/sys/netinet6/nd6.c
==============================================================================
--- head/sys/netinet6/nd6.c	Sat Sep 19 03:58:31 2015	(r287984)
+++ head/sys/netinet6/nd6.c	Sat Sep 19 11:50:02 2015	(r287985)
@@ -1689,7 +1689,6 @@ nd6_cache_lladdr(struct ifnet *ifp, stru
 	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, stru
 		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, stru
 	 *	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, stru
 		 */
 		bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
 		ln->la_flags |= LLE_VALID;
-		EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
-	}
+		ln->ln_state = ND6_LLINFO_STALE;
 
-	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;
-	}
-
-	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, stru
 	 * 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
 	/*
 	 * 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509191150.t8JBo3mL066339>