]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
if: Protect V_ifnet in vnet_if_return()
authorkp <kp@FreeBSD.org>
Wed, 25 Nov 2020 15:07:22 +0000 (15:07 +0000)
committerkp <kp@FreeBSD.org>
Wed, 25 Nov 2020 15:07:22 +0000 (15:07 +0000)
commite4b7f3eaebe5ac6e662c8a0af0e1528fc1dc1292
tree2235ade75168cd342a0fc1d613c91853107641a0
parent97f64194f0750f0d11566fca7247c13a1b67a69d
if: Protect V_ifnet in vnet_if_return()

When we terminate a vnet (i.e. jail) we move interfaces back to their home
vnet. We need to protect our access to the V_ifnet CK_LIST.

We could enter NET_EPOCH, but if_detach_internal() (called from if_vmove())
waits for net epoch callback completion. That's not possible from NET_EPOCH.
Instead, we take the IFNET_WLOCK, build a list of the interfaces that need to
move and, once we've released the lock, move them back to their home vnet.

We cannot hold the IFNET_WLOCK() during if_vmove(), because that results in a
LOR between ifnet_sx, in_multi_sx and iflib ctx lock.

Separate out moving the ifp into or out of V_ifnet, so we can hold the lock as
we do the list manipulation, but do not hold it as we if_vmove().

Reviewed by: melifaro
MFC after: 2 weeks
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D27279
sys/net/if.c