Index: sys/net/if.c =================================================================== --- sys/net/if.c +++ sys/net/if.c @@ -1090,10 +1090,9 @@ struct ifnet *iter; int found = 0; #ifdef VIMAGE - int shutdown; + bool shutdown; - shutdown = (ifp->if_vnet->vnet_state > SI_SUB_VNET && - ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? 1 : 0; + shutdown = !vnet_is_ready(ifp->if_vnet); #endif IFNET_WLOCK(); CK_STAILQ_FOREACH(iter, &V_ifnet, if_link) @@ -1334,7 +1333,7 @@ { struct prison *pr; struct ifnet *difp; - int shutdown; + bool shutdown; /* Try to find the prison within our visibility. */ sx_slock(&allprison_lock); @@ -1362,8 +1361,7 @@ } /* Make sure the VNET is stable. */ - shutdown = (ifp->if_vnet->vnet_state > SI_SUB_VNET && - ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? 1 : 0; + shutdown = !vnet_is_ready(ifp->if_vnet); if (shutdown) { CURVNET_RESTORE(); prison_free(pr); @@ -1387,7 +1385,7 @@ struct prison *pr; struct vnet *vnet_dst; struct ifnet *ifp; - int shutdown; + bool shutdown; /* Try to find the prison within our visibility. */ sx_slock(&allprison_lock); @@ -1416,8 +1414,7 @@ } /* Make sure the VNET is stable. */ - shutdown = (ifp->if_vnet->vnet_state > SI_SUB_VNET && - ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? 1 : 0; + shutdown = !vnet_is_ready(ifp->if_vnet); if (shutdown) { CURVNET_RESTORE(); prison_free(pr); @@ -3009,14 +3006,13 @@ int error; int oif_flags; #ifdef VIMAGE - int shutdown; + bool shutdown; #endif CURVNET_SET(so->so_vnet); #ifdef VIMAGE /* Make sure the VNET is stable. */ - shutdown = (so->so_vnet->vnet_state > SI_SUB_VNET && - so->so_vnet->vnet_state < SI_SUB_VNET_DONE) ? 1 : 0; + shutdown = !vnet_is_ready(so->so_vnet); if (shutdown) { CURVNET_RESTORE(); return (EBUSY); Index: sys/net/vnet.h =================================================================== --- sys/net/vnet.h +++ sys/net/vnet.h @@ -349,6 +349,11 @@ vnet_deregister_sysuninit, &ident ## _vnet_uninit) /* + * Check if VNET is ready. + */ +bool vnet_is_ready(struct vnet *); + +/* * Run per-vnet sysinits or sysuninits during vnet creation/destruction. */ void vnet_sysinit(void); Index: sys/net/vnet.c =================================================================== --- sys/net/vnet.c +++ sys/net/vnet.c @@ -225,6 +225,17 @@ #endif /* + * Check if VNET is in startup or shutdown phase. + */ +bool +vnet_is_ready(struct vnet *vnet) +{ + + return (vnet->vnet_state <= SI_SUB_VNET || + vnet->vnet_state >= SI_SUB_VNET_DONE); +} + +/* * Allocate a virtual network stack. */ struct vnet *