ifp->if_sadl = NULL;
if_free_sadl(ifp);  free(ifnet_addrs[ifp->if_index], M_IFADDR);
if_detach(ifp)	struct ifnet *ifp;{	struct ifaddr *ifa;	int i, s = splimp();	struct radix_node_head *rnh;	struct domain *dp;	ifp->if_flags &= ~IFF_OACTIVE;	ifp->if_start = if_detached_start;	ifp->if_ioctl = if_detached_ioctl;	ifp->if_init = if_detached_init;	ifp->if_watchdog = if_detached_watchdog;#if NPF > 0	pfi_detach_ifnet(ifp);#endif#if NBRIDGE > 0	/* Remove the interface from any bridge it is part of.  */	if (ifp->if_bridge)		bridge_ifdetach(ifp);#endif#if NCARP > 0	/* Remove the interface from any carp group it is a part of.  */	if (ifp->if_carp)		carp_ifdetach(ifp);#endif#if NBPFILTER > 0	/* If there is a bpf device attached, detach from it.  */	if (ifp->if_bpf)		bpfdetach(ifp);#endif#ifdef ALTQ	if (ALTQ_IS_ENABLED(&ifp->if_snd))		altq_disable(&ifp->if_snd);	if (ALTQ_IS_ATTACHED(&ifp->if_snd))		altq_detach(&ifp->if_snd);#endif	/*	 * Find and remove all routes which is using this interface.	 * XXX Factor out into a route.c function?	 */	for (i = 1; i <= AF_MAX; i++) {		rnh = rt_tables[i];		if (rnh)			(*rnh->rnh_walktree)(rnh, if_detach_rtdelete, ifp);	}#ifdef INET	rti_delete(ifp);#if NETHER > 0	myip_ifp = NULL;#endif#ifdef MROUTING	vif_delete(ifp);#endif#endif#ifdef INET6	in6_ifdetach(ifp);#endif	/*	 * remove packets came from ifp, from software interrupt queues.	 * net/netisr_dispatch.h is not usable, as some of them use	 * strange queue names.	 */#define IF_DETACH_QUEUES(x) \do { \	extern struct ifqueue x; \	if_detach_queues(ifp, & x); \} while (0)#ifdef INET	IF_DETACH_QUEUES(arpintrq);	IF_DETACH_QUEUES(ipintrq);#endif#ifdef INET6	IF_DETACH_QUEUES(ip6intrq);#endif#ifdef IPX	IF_DETACH_QUEUES(ipxintrq);#endif#ifdef NS	IF_DETACH_QUEUES(nsintrq);#endif#ifdef NETATALK	IF_DETACH_QUEUES(atintrq1);	IF_DETACH_QUEUES(atintrq2);#endif#ifdef ISO	IF_DETACH_QUEUES(clnlintrq);#endif#ifdef CCITT	IF_DETACH_QUEUES(llcintrq);#endif#ifdef NATM	IF_DETACH_QUEUES(natmintrq);#endif#ifdef DECNET	IF_DETACH_QUEUES(decnetintrq);#endif#undef IF_DETACH_QUEUES	/*	 * XXX transient ifp refs?  inpcb.ip_moptions.imo_multicast_ifp?	 * Other network stacks than INET?	 */	/* Remove the interface from the list of all interfaces.  */	TAILQ_REMOVE(&ifnet, ifp, if_list);	/*	 * Deallocate private resources.	 * XXX should consult refcnt and use IFAFREE	 */	for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa;	    ifa = TAILQ_FIRST(&ifp->if_addrlist)) {		TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list);#ifdef INET		if (ifa->ifa_addr->sa_family == AF_INET)			TAILQ_REMOVE(&in_ifaddr, (struct in_ifaddr *)ifa,			    ia_list);#endif		free(ifa, M_IFADDR);	}	ifp->if_sadl = NULL;	ifnet_addrs[ifp->if_index] = NULL;	free(ifp->if_addrhooks, M_TEMP);	for (dp = domains; dp; dp = dp->dom_next) {		if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family])			(*dp->dom_ifdetach)(ifp,			    ifp->if_afdata[dp->dom_family]);	}	splx(s);}