Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143329381
D20051.id57256.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D20051.id57256.diff
View Options
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
@@ -329,7 +329,7 @@
static void
vnet_init_done(void *unused __unused)
{
-
+ curvnet->vnet_state = SI_SUB_VNET_DONE;
curvnet = NULL;
}
SYSINIT(vnet_init_done, SI_SUB_VNET_DONE, SI_ORDER_ANY, vnet_init_done,
@@ -362,6 +362,19 @@
vnet_sysinit_done, NULL);
/*
+ * Check if VNET is running.
+ */
+bool
+vnet_is_running(struct vnet *vnet)
+{
+
+ KASSERT(vnet->vnet_state <= SI_SUB_VNET_DONE,
+ ("Invalid VNET state 0x%08x > 0x%08x",
+ vnet->vnet_state, SI_SUB_VNET_DONE));
+ 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.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 29, 11:49 PM (17 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28091583
Default Alt Text
D20051.id57256.diff (3 KB)
Attached To
Mode
D20051: Define and use functions to test specific VNET states during shutdown
Attached
Detach File
Event Timeline
Log In to Comment