diff --git a/sys/net/if.c b/sys/net/if.c index 7e9f800593bc..406c57c8efb4 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1088,10 +1088,9 @@ if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp) 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 = ifp->if_vnet->vnet_shutdown; #endif IFNET_WLOCK(); CK_STAILQ_FOREACH(iter, &V_ifnet, if_link) @@ -1341,7 +1340,6 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, char *ifname, int jid) { struct prison *pr; struct ifnet *difp; - int shutdown; /* Try to find the prison within our visibility. */ sx_slock(&allprison_lock); @@ -1369,9 +1367,7 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, char *ifname, int jid) } /* 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; - if (shutdown) { + if (ifp->if_vnet->vnet_shutdown) { CURVNET_RESTORE(); prison_free(pr); return (EBUSY); @@ -1394,7 +1390,6 @@ if_vmove_reclaim(struct thread *td, char *ifname, int jid) struct prison *pr; struct vnet *vnet_dst; struct ifnet *ifp; - int shutdown; /* Try to find the prison within our visibility. */ sx_slock(&allprison_lock); @@ -1423,9 +1418,7 @@ if_vmove_reclaim(struct thread *td, char *ifname, int jid) } /* 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; - if (shutdown) { + if (ifp->if_vnet->vnet_shutdown) { CURVNET_RESTORE(); prison_free(pr); return (EBUSY); @@ -2996,16 +2989,11 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td) struct ifreq *ifr; int error; int oif_flags; -#ifdef VIMAGE - int 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; - if (shutdown) { + if (so->so_vnet->vnet_shutdown) { CURVNET_RESTORE(); return (EBUSY); } diff --git a/sys/net/vnet.c b/sys/net/vnet.c index 9a4321a8409b..cbcc41557cee 100644 --- a/sys/net/vnet.c +++ b/sys/net/vnet.c @@ -235,7 +235,6 @@ vnet_alloc(void) SDT_PROBE1(vnet, functions, vnet_alloc, entry, __LINE__); vnet = malloc(sizeof(struct vnet), M_VNET, M_WAITOK | M_ZERO); vnet->vnet_magic_n = VNET_MAGIC_N; - vnet->vnet_state = 0; SDT_PROBE2(vnet, functions, vnet_alloc, alloc, __LINE__, vnet); /* @@ -280,6 +279,9 @@ vnet_destroy(struct vnet *vnet) LIST_REMOVE(vnet, vnet_le); VNET_LIST_WUNLOCK(); + /* Signal that VNET is being shutdown. */ + vnet->vnet_shutdown = 1; + CURVNET_SET_QUIET(vnet); vnet_sysuninit(); CURVNET_RESTORE(); @@ -573,10 +575,8 @@ vnet_sysinit(void) struct vnet_sysinit *vs; VNET_SYSINIT_RLOCK(); - TAILQ_FOREACH(vs, &vnet_constructors, link) { - curvnet->vnet_state = vs->subsystem; + TAILQ_FOREACH(vs, &vnet_constructors, link) vs->func(vs->arg); - } VNET_SYSINIT_RUNLOCK(); } @@ -592,10 +592,8 @@ vnet_sysuninit(void) VNET_SYSINIT_RLOCK(); TAILQ_FOREACH_REVERSE(vs, &vnet_destructors, vnet_sysuninit_head, - link) { - curvnet->vnet_state = vs->subsystem; + link) vs->func(vs->arg); - } VNET_SYSINIT_RUNLOCK(); } @@ -709,7 +707,7 @@ db_vnet_print(struct vnet *vnet) db_printf(" vnet_data_mem = %p\n", vnet->vnet_data_mem); db_printf(" vnet_data_base = %#jx\n", (uintmax_t)vnet->vnet_data_base); - db_printf(" vnet_state = %#08x\n", vnet->vnet_state); + db_printf(" vnet_shutdown = %#08x\n", vnet->vnet_shutdown); db_printf("\n"); } diff --git a/sys/net/vnet.h b/sys/net/vnet.h index a8c9887ed506..1b5fcd2e066f 100644 --- a/sys/net/vnet.h +++ b/sys/net/vnet.h @@ -72,7 +72,7 @@ struct vnet { u_int vnet_magic_n; u_int vnet_ifcnt; u_int vnet_sockcnt; - u_int vnet_state; /* SI_SUB_* */ + u_int vnet_shutdown; /* Shutdown in progress. */ void *vnet_data_mem; uintptr_t vnet_data_base; }; diff --git a/sys/sys/param.h b/sys/sys/param.h index 77dec5a34280..7d562a25030c 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300048 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300049 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,