This pushes us towards a mode of operation similar to other teardown routines, where we're guaranteed to be free of clashing operations after if_detach/ether_ifdetach returns.
The current version of this starts to touch on related vnet issues, as well- ensuring that we block on detach if a vnet's already started shutdown until the ifnet's been properly rehomed to the parent vnet, and making sure any in-progress if_vmove is finished and blocked prior to detaching.
Not addressed here is that a vnet can commence shutdown while we were already in the middle of if_detach_internal and the vnet state can get torn down partially, leading to a panic in in_ifdetach. The read of ifp->if_vnet->vnet_shutdown has been deferred until as late as possible in if_detach_internal, with the hopes of minimizing this race window... but it really needs proper resolution.