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_running(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_running(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_running(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_running(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_running(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 @@ -362,6 +362,16 @@ vnet_sysinit_done, NULL); /* + * Check if VNET is running. + */ +bool +vnet_is_running(struct vnet *vnet) +{ + + return (vnet->vnet_state == SI_SUB_VNET_DONE); +} + +/* * When a module is loaded and requires storage for a virtualized global * variable, allocate space from the modspace free list. This interface * should be used only by the kernel linker.