svn commit: r299014 - stable/10/sys/netinet6

Mark Johnston markj at FreeBSD.org
Tue May 3 23:46:03 UTC 2016


Author: markj
Date: Tue May  3 23:46:01 2016
New Revision: 299014
URL: https://svnweb.freebsd.org/changeset/base/299014

Log:
  MFC r295575, r295576, r295578, r295579, r295580:
  Various NDP cleanups. No functional change intended.

Modified:
  stable/10/sys/netinet6/nd6.c
  stable/10/sys/netinet6/nd6_nbr.c
  stable/10/sys/netinet6/nd6_rtr.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet6/nd6.c
==============================================================================
--- stable/10/sys/netinet6/nd6.c	Tue May  3 23:39:41 2016	(r299013)
+++ stable/10/sys/netinet6/nd6.c	Tue May  3 23:46:01 2016	(r299014)
@@ -112,11 +112,6 @@ VNET_DEFINE(int, nd6_debug) = 1;
 VNET_DEFINE(int, nd6_debug) = 0;
 #endif
 
-/* for debugging? */
-#if 0
-static int nd6_inuse, nd6_allocated;
-#endif
-
 VNET_DEFINE(struct nd_drhead, nd_defrouter);
 VNET_DEFINE(struct nd_prhead, nd_prefix);
 
@@ -175,7 +170,7 @@ nd6_ifattach(struct ifnet *ifp)
 {
 	struct nd_ifinfo *nd;
 
-	nd = (struct nd_ifinfo *)malloc(sizeof(*nd), M_IP6NDP, M_WAITOK|M_ZERO);
+	nd = malloc(sizeof(*nd), M_IP6NDP, M_WAITOK | M_ZERO);
 	nd->initialized = 1;
 
 	nd->chlim = IPV6_DEFHLIM;
@@ -2182,7 +2177,6 @@ clear_llinfo_pqueue(struct llentry *ln)
 	}
 
 	ln->la_hold = NULL;
-	return;
 }
 
 static int nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS);

Modified: stable/10/sys/netinet6/nd6_nbr.c
==============================================================================
--- stable/10/sys/netinet6/nd6_nbr.c	Tue May  3 23:39:41 2016	(r299013)
+++ stable/10/sys/netinet6/nd6_nbr.c	Tue May  3 23:46:01 2016	(r299014)
@@ -623,7 +623,6 @@ nd6_ns_output_fib(struct ifnet *ifp, con
 		RTFREE(ro.ro_rt);
 	}
 	m_freem(m);
-	return;
 }
 
 #ifndef BURN_BRIDGES
@@ -901,12 +900,6 @@ nd6_na_input(struct mbuf *m, int off, in
 
 			in6 = &L3_ADDR_SIN6(ln)->sin6_addr;
 
-			/*
-			 * Lock to protect the default router list.
-			 * XXX: this might be unnecessary, since this function
-			 * is only called under the network software interrupt
-			 * context.  However, we keep it just for safety.
-			 */
 			dr = defrouter_lookup(in6, ln->lle_tbl->llt_ifp);
 			if (dr)
 				defrtrlist_del(dr);
@@ -1127,7 +1120,6 @@ nd6_na_output_fib(struct ifnet *ifp, con
 		RTFREE(ro.ro_rt);
 	}
 	m_freem(m);
-	return;
 }
 
 #ifndef BURN_BRIDGES

Modified: stable/10/sys/netinet6/nd6_rtr.c
==============================================================================
--- stable/10/sys/netinet6/nd6_rtr.c	Tue May  3 23:39:41 2016	(r299013)
+++ stable/10/sys/netinet6/nd6_rtr.c	Tue May  3 23:46:01 2016	(r299014)
@@ -501,7 +501,6 @@ defrouter_addreq(struct nd_defrouter *ne
 	}
 	if (error == 0)
 		new->installed = 1;
-	return;
 }
 
 struct nd_defrouter *
@@ -700,8 +699,6 @@ defrouter_select(void)
 			defrouter_delreq(installed_dr);
 		defrouter_addreq(selected_dr);
 	}
-
-	return;
 }
 
 /*
@@ -735,53 +732,47 @@ static struct nd_defrouter *
 defrtrlist_update(struct nd_defrouter *new)
 {
 	struct nd_defrouter *dr, *n;
+	int oldpref;
 
 	if ((dr = defrouter_lookup(&new->rtaddr, new->ifp)) != NULL) {
 		/* entry exists */
 		if (new->rtlifetime == 0) {
 			defrtrlist_del(dr);
-			dr = NULL;
-		} else {
-			int oldpref = rtpref(dr);
+			return (NULL);
+		}
 
-			/* override */
-			dr->flags = new->flags; /* xxx flag check */
-			dr->rtlifetime = new->rtlifetime;
-			dr->expire = new->expire;
+		oldpref = rtpref(dr);
 
-			/*
-			 * If the preference does not change, there's no need
-			 * to sort the entries. Also make sure the selected
-			 * router is still installed in the kernel.
-			 */
-			if (dr->installed && rtpref(new) == oldpref)
-				return (dr);
+		/* override */
+		dr->flags = new->flags; /* xxx flag check */
+		dr->rtlifetime = new->rtlifetime;
+		dr->expire = new->expire;
 
-			/*
-			 * preferred router may be changed, so relocate
-			 * this router.
-			 * XXX: calling TAILQ_REMOVE directly is a bad manner.
-			 * However, since defrtrlist_del() has many side
-			 * effects, we intentionally do so here.
-			 * defrouter_select() below will handle routing
-			 * changes later.
-			 */
-			TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry);
-			n = dr;
-			goto insert;
-		}
-		return (dr);
+		/*
+		 * If the preference does not change, there's no need
+		 * to sort the entries. Also make sure the selected
+		 * router is still installed in the kernel.
+		 */
+		if (dr->installed && rtpref(new) == oldpref)
+			return (dr);
+
+		/*
+		 * The preferred router may have changed, so relocate this
+		 * router.
+		 */
+		TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry);
+		n = dr;
+		goto insert;
 	}
 
 	/* entry does not exist */
 	if (new->rtlifetime == 0)
 		return (NULL);
 
-	n = (struct nd_defrouter *)malloc(sizeof(*n), M_IP6NDP, M_NOWAIT);
+	n = malloc(sizeof(*n), M_IP6NDP, M_NOWAIT | M_ZERO);
 	if (n == NULL)
 		return (NULL);
-	bzero(n, sizeof(*n));
-	*n = *new;
+	memcpy(n, new, sizeof(*n));
 
 insert:
 	/*
@@ -824,10 +815,9 @@ pfxrtr_add(struct nd_prefix *pr, struct 
 {
 	struct nd_pfxrouter *new;
 
-	new = (struct nd_pfxrouter *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT);
+	new = malloc(sizeof(*new), M_IP6NDP, M_NOWAIT | M_ZERO);
 	if (new == NULL)
 		return;
-	bzero(new, sizeof(*new));
 	new->router = dr;
 
 	LIST_INSERT_HEAD(&pr->ndpr_advrtrs, new, pfr_entry);
@@ -868,10 +858,9 @@ nd6_prelist_add(struct nd_prefixctl *pr,
 	int i;
 	char ip6buf[INET6_ADDRSTRLEN];
 
-	new = (struct nd_prefix *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT);
+	new = malloc(sizeof(*new), M_IP6NDP, M_NOWAIT | M_ZERO);
 	if (new == NULL)
-		return(ENOMEM);
-	bzero(new, sizeof(*new));
+		return (ENOMEM);
 	new->ndpr_ifp = pr->ndpr_ifp;
 	new->ndpr_prefix = pr->ndpr_prefix;
 	new->ndpr_plen = pr->ndpr_plen;


More information about the svn-src-all mailing list