FreeBSD/sys/netinet6/nd6.c
/*
 * Remove prefix and default router list entries corresponding to ifp. Neighbor
 * cache entries are freed in in6_domifdetach().
 */
Remove prefix and default router list entries corresponding to ifp. Neighbor
cache entries are freed in in6_domifdetach().
Remove prefix and default router list entries corresponding to ifp . Neighbor cache entries are freed in in6_domifdetach () .
void
nd6_purge(struct ifnet *ifp)
{
	struct nd_drhead drq;
	struct nd_defrouter *dr, *ndr;
	struct nd_prefix *pr, *npr;
	TAILQ_INIT(&drq);
	ND6_WLOCK();
	TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, ndr) {
		if (dr->installed)
			continue;
		if (dr->ifp == ifp)
			defrouter_unlink(dr, &drq);
	}
	TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, ndr) {
		if (!dr->installed)
			continue;
		if (dr->ifp == ifp)
			defrouter_unlink(dr, &drq);
	}
	ND6_WUNLOCK();
	while ((dr = TAILQ_FIRST(&drq)) != NULL) {
		TAILQ_REMOVE(&drq, dr, dr_entry);
		defrouter_del(dr);
	}
	LIST_FOREACH_SAFE(pr, &V_nd_prefix, ndpr_entry, npr) {
		if (pr->ndpr_ifp == ifp) {
			pr->ndpr_refcnt = 0;
			prelist_remove(pr);
		}
	}
	if (V_nd6_defifindex == ifp->if_index)
		nd6_setdefaultiface(0);
	if (ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV) {
		defrouter_select();
	}
}
void nd6_purge ( struct ifnet * ifp ) { struct nd_drhead drq ; struct nd_defrouter * dr , * ndr ; struct nd_prefix * pr , * npr ; TAILQ_INIT ( & drq ) ; ND6_WLOCK ( ) ; TAILQ_FOREACH_SAFE ( dr , & V_nd_defrouter , dr_entry , ndr ) { if ( dr -> installed ) continue ; if ( dr -> ifp == ifp ) defrouter_unlink ( dr , & drq ) ; } TAILQ_FOREACH_SAFE ( dr , & V_nd_defrouter , dr_entry , ndr ) { if ( ! dr -> installed ) continue ; if ( dr -> ifp == ifp ) defrouter_unlink ( dr , & drq ) ; } ND6_WUNLOCK ( ) ; while ( ( dr = TAILQ_FIRST ( & drq ) ) != NULL ) { TAILQ_REMOVE ( & drq , dr , dr_entry ) ; defrouter_del ( dr ) ; } LIST_FOREACH_SAFE ( pr , & V_nd_prefix , ndpr_entry , npr ) { if ( pr -> ndpr_ifp == ifp ) { pr -> ndpr_refcnt = 0 ; prelist_remove ( pr ) ; } } if ( V_nd6_defifindex == ifp -> if_index ) nd6_setdefaultiface ( 0 ) ; if ( ND_IFINFO ( ifp ) -> flags & ND6_IFF_ACCEPT_RTADV ) { defrouter_select ( ) ; } }
Remove prefix and default router list entries corresponding to ifp.
Remove prefix and default router list entries corresponding to ifp .
/*
	 * Nuke default router list entries toward ifp.
	 * We defer removal of default router list entries that is installed
	 * in the routing table, in order to keep additional side effects as
	 * small as possible.
	 */ /* Nuke prefix list entries toward ifp */ /*
			 * Because if_detach() does *not* release prefixes
			 * while purging addresses the reference count will
			 * still be above zero. We therefore reset it to
			 * make sure that the prefix really gets purged.
			 */ /* cancel default outgoing interface setting */ /* Refresh default router list. */