* Deregister an interface and free the associated storage. */
| 712 | * Deregister an interface and free the associated storage. |
| 713 | */ |
| 714 | void |
| 715 | if_free(struct ifnet *ifp) |
| 716 | { |
| 717 | |
| 718 | ifp->if_flags |= IFF_DYING; /* XXX: Locking */ |
| 719 | |
| 720 | CURVNET_SET_QUIET(ifp->if_vnet); |
| 721 | IFNET_WLOCK(); |
| 722 | KASSERT(ifp == ifnet_byindex(ifp->if_index), |
| 723 | ("%s: freeing unallocated ifnet", ifp->if_xname)); |
| 724 | |
| 725 | ifindex_free_locked(ifp->if_index); |
| 726 | IFNET_WUNLOCK(); |
| 727 | |
| 728 | if (refcount_release(&ifp->if_refcount)) |
| 729 | NET_EPOCH_CALL(if_destroy, &ifp->if_epoch_ctx); |
| 730 | CURVNET_RESTORE(); |
| 731 | } |
| 732 | |
| 733 | /* |
| 734 | * Interfaces to keep an ifnet type-stable despite the possibility of the |
no test coverage detected