* A handler for network interface departure events. * Track departure of trunks here so that we don't access invalid * pointers or whatever if a trunk is ripped from under us, e.g., * by ejecting its hot-plug card. However, if an ifnet is simply * being renamed, then there's no need to tear down the state. */
| 679 | * being renamed, then there's no need to tear down the state. |
| 680 | */ |
| 681 | static void |
| 682 | vlan_ifdetach(void *arg __unused, struct ifnet *ifp) |
| 683 | { |
| 684 | struct ifvlan *ifv; |
| 685 | struct ifvlantrunk *trunk; |
| 686 | |
| 687 | /* If the ifnet is just being renamed, don't do anything. */ |
| 688 | if (ifp->if_flags & IFF_RENAMING) |
| 689 | return; |
| 690 | VLAN_XLOCK(); |
| 691 | trunk = ifp->if_vlantrunk; |
| 692 | if (trunk == NULL) { |
| 693 | VLAN_XUNLOCK(); |
| 694 | return; |
| 695 | } |
| 696 | |
| 697 | /* |
| 698 | * OK, it's a trunk. Loop over and detach all vlan's on it. |
| 699 | * Check trunk pointer after each vlan_unconfig() as it will |
| 700 | * free it and set to NULL after the last vlan was detached. |
| 701 | */ |
| 702 | VLAN_FOREACH_UNTIL_SAFE(ifv, ifp->if_vlantrunk, |
| 703 | ifp->if_vlantrunk == NULL) |
| 704 | vlan_unconfig_locked(ifv->ifv_ifp, 1); |
| 705 | |
| 706 | /* Trunk should have been destroyed in vlan_unconfig(). */ |
| 707 | KASSERT(ifp->if_vlantrunk == NULL, ("%s: purge failed", __func__)); |
| 708 | VLAN_XUNLOCK(); |
| 709 | } |
| 710 | |
| 711 | /* |
| 712 | * Return the trunk device for a virtual interface. |
nothing calls this directly
no test coverage detected