Module Name:    src
Committed By:   ozaki-r
Date:           Mon Dec 19 03:32:54 UTC 2016

Modified Files:
        src/sys/netinet6: in6_ifattach.c nd6.c nd6.h

Log Message:
Get rid of extra nd6_purge from in6_ifdetach

There were two nd6_purge in in6_ifdetach for some reason, but at least now
We don't need extra nd6_purge. Remove it and instead add assertions that
check if surely purged.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/netinet6/in6_ifattach.c
cvs rdiff -u -r1.217 -r1.218 src/sys/netinet6/nd6.c
cvs rdiff -u -r1.79 -r1.80 src/sys/netinet6/nd6.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet6/in6_ifattach.c
diff -u src/sys/netinet6/in6_ifattach.c:1.107 src/sys/netinet6/in6_ifattach.c:1.108
--- src/sys/netinet6/in6_ifattach.c:1.107	Wed Nov 30 02:08:57 2016
+++ src/sys/netinet6/in6_ifattach.c	Mon Dec 19 03:32:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_ifattach.c,v 1.107 2016/11/30 02:08:57 ozaki-r Exp $	*/
+/*	$NetBSD: in6_ifattach.c,v 1.108 2016/12/19 03:32:54 ozaki-r Exp $	*/
 /*	$KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.107 2016/11/30 02:08:57 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.108 2016/12/19 03:32:54 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -815,21 +815,13 @@ in6_ifdetach(struct ifnet *ifp)
 	/* remove ip6_mrouter stuff */
 	ip6_mrouter_detach(ifp);
 
-	/* remove neighbor management table */
-	nd6_purge(ifp, NULL);
-
 	/* cleanup multicast address kludge table, if there is any */
 	in6_purgemkludge(ifp);
 
-	/*
-	 * remove neighbor management table.  we call it twice just to make
-	 * sure we nuke everything.  maybe we need just one call.
-	 * XXX: since the first call did not release addresses, some prefixes
-	 * might remain.  We should call nd6_purge() again to release the
-	 * prefixes after removing all addresses above.
-	 * (Or can we just delay calling nd6_purge until at this point?)
-	 */
+	/* remove neighbor management table */
 	nd6_purge(ifp, NULL);
+
+	nd6_assert_purged(ifp);
 }
 
 int

Index: src/sys/netinet6/nd6.c
diff -u src/sys/netinet6/nd6.c:1.217 src/sys/netinet6/nd6.c:1.218
--- src/sys/netinet6/nd6.c:1.217	Wed Dec 14 04:05:11 2016
+++ src/sys/netinet6/nd6.c	Mon Dec 19 03:32:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.217 2016/12/14 04:05:11 ozaki-r Exp $	*/
+/*	$NetBSD: nd6.c,v 1.218 2016/12/19 03:32:54 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.217 2016/12/14 04:05:11 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.218 2016/12/19 03:32:54 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -906,6 +906,26 @@ nd6_purge(struct ifnet *ifp, struct in6_
 		lltable_purge_entries(ext->lltable);
 }
 
+void
+nd6_assert_purged(struct ifnet *ifp)
+{
+	struct nd_defrouter *dr;
+	struct nd_prefix *pr;
+
+	ND_DEFROUTER_LIST_FOREACH(dr) {
+		KASSERTMSG(dr->ifp != ifp,
+		    "defrouter %s remains on %s",
+		    ip6_sprintf(&dr->rtaddr), ifp->if_xname);
+	}
+
+	ND_PREFIX_LIST_FOREACH(pr) {
+		KASSERTMSG(pr->ndpr_ifp != ifp,
+		    "prefix %s/%d remains on %s",
+		    ip6_sprintf(&pr->ndpr_prefix.sin6_addr),
+		    pr->ndpr_plen, ifp->if_xname);
+	}
+}
+
 struct llentry *
 nd6_lookup(const struct in6_addr *addr6, const struct ifnet *ifp, bool wlock)
 {

Index: src/sys/netinet6/nd6.h
diff -u src/sys/netinet6/nd6.h:1.79 src/sys/netinet6/nd6.h:1.80
--- src/sys/netinet6/nd6.h:1.79	Wed Dec 14 04:05:11 2016
+++ src/sys/netinet6/nd6.h	Mon Dec 19 03:32:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.h,v 1.79 2016/12/14 04:05:11 ozaki-r Exp $	*/
+/*	$NetBSD: nd6.h,v 1.80 2016/12/19 03:32:54 ozaki-r Exp $	*/
 /*	$KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $	*/
 
 /*
@@ -428,6 +428,7 @@ struct llentry *nd6_create(const struct 
 void nd6_setmtu(struct ifnet *);
 void nd6_llinfo_settimer(struct llentry *, time_t);
 void nd6_purge(struct ifnet *, struct in6_ifextra *);
+void nd6_assert_purged(struct ifnet *);
 void nd6_nud_hint(struct rtentry *);
 int nd6_resolve(struct ifnet *, struct rtentry *,
 	struct mbuf *, struct sockaddr *, u_char *);

Reply via email to