MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tun_destroy

Function tun_destroy

freebsd/net/if_tuntap.c:616–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614}
615
616static void
617tun_destroy(struct tuntap_softc *tp)
618{
619
620 TUN_LOCK(tp);
621 tp->tun_flags |= TUN_DYING;
622 if (tp->tun_busy != 0)
623 cv_wait_unlock(&tp->tun_cv, &tp->tun_mtx);
624 else
625 TUN_UNLOCK(tp);
626
627 CURVNET_SET(TUN2IFP(tp)->if_vnet);
628
629 /* destroy_dev will take care of any alias. */
630 destroy_dev(tp->tun_dev);
631 seldrain(&tp->tun_rsel);
632 knlist_clear(&tp->tun_rsel.si_note, 0);
633 knlist_destroy(&tp->tun_rsel.si_note);
634 if ((tp->tun_flags & TUN_L2) != 0) {
635 ether_ifdetach(TUN2IFP(tp));
636 } else {
637 bpfdetach(TUN2IFP(tp));
638 if_detach(TUN2IFP(tp));
639 }
640 sx_xlock(&tun_ioctl_sx);
641 TUN2IFP(tp)->if_softc = NULL;
642 sx_xunlock(&tun_ioctl_sx);
643 free_unr(tp->tun_drv->unrhdr, TUN2IFP(tp)->if_dunit);
644 if_free(TUN2IFP(tp));
645 mtx_destroy(&tp->tun_mtx);
646 cv_destroy(&tp->tun_cv);
647 free(tp, M_TUN);
648 CURVNET_RESTORE();
649}
650
651static int
652tun_clone_destroy(struct if_clone *ifc __unused, struct ifnet *ifp)

Callers 2

tun_clone_destroyFunction · 0.85
tun_uninitFunction · 0.85

Calls 10

destroy_devFunction · 0.85
seldrainFunction · 0.85
knlist_destroyFunction · 0.85
ether_ifdetachFunction · 0.85
bpfdetachFunction · 0.85
if_detachFunction · 0.85
free_unrFunction · 0.85
if_freeFunction · 0.85
cv_destroyFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected