summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-08-01 21:54:15 +0000
committerrwatson <rwatson@FreeBSD.org>2009-08-01 21:54:15 +0000
commit648ff244308cdbfdfbafe6cae0d808d8ee29cb4b (patch)
tree58f25081dd4f020d6ef4ddca19dec5bc30b7c940
parente3917e768dd62864bffbab302c81220b6903a864 (diff)
downloadFreeBSD-src-648ff244308cdbfdfbafe6cae0d808d8ee29cb4b.zip
FreeBSD-src-648ff244308cdbfdfbafe6cae0d808d8ee29cb4b.tar.gz
Make the vnet alloc/destroy paths a bit easier to followg by merging
vnet_data_init/vnet_data_destroy into vnet_alloc/vnet_destroy. Reviewed by: bz, zec Approved by: re (vimage blanket)
-rw-r--r--sys/net/vnet.c54
-rw-r--r--sys/net/vnet.h7
2 files changed, 20 insertions, 41 deletions
diff --git a/sys/net/vnet.c b/sys/net/vnet.c
index a7b23b1..f5d336a 100644
--- a/sys/net/vnet.c
+++ b/sys/net/vnet.c
@@ -211,7 +211,20 @@ vnet_alloc(void)
vnet = malloc(sizeof(struct vnet), M_VNET, M_WAITOK | M_ZERO);
vnet->vnet_magic_n = VNET_MAGIC_N;
- vnet_data_init(vnet);
+
+ /*
+ * Allocate storage for virtualized global variables and copy in
+ * initial values form our 'master' copy.
+ */
+ vnet->vnet_data_mem = malloc(VNET_SIZE, M_VNET_DATA, M_WAITOK);
+ memcpy(vnet->vnet_data_mem, (void *)VNET_START, VNET_BYTES);
+
+ /*
+ * All use of vnet-specific data will immediately subtract VNET_START
+ * from the base memory pointer, so pre-calculate that now to avoid
+ * it on each use.
+ */
+ vnet->vnet_data_base = (uintptr_t)vnet->vnet_data_mem - VNET_START;
/* Initialize / attach vnet module instances. */
CURVNET_SET_QUIET(vnet);
@@ -255,8 +268,12 @@ vnet_destroy(struct vnet *vnet)
CURVNET_RESTORE();
- /* Hopefully, we are OK to free the vnet container itself. */
- vnet_data_destroy(vnet);
+ /*
+ * Release storage for the virtual network stack instance.
+ */
+ free(vnet->vnet_data_mem, M_VNET_DATA);
+ vnet->vnet_data_mem = NULL;
+ vnet->vnet_data_base = 0;
vnet->vnet_magic_n = 0xdeadbeef;
free(vnet, M_VNET);
}
@@ -299,37 +316,6 @@ SYSINIT(vnet_init_done, SI_SUB_VNET_DONE, SI_ORDER_FIRST, vnet_init_done,
NULL);
/*
- * Allocate storage for virtualized global variables in a new virtual network
- * stack instance, and copy in initial values from our 'master' copy.
- */
-void
-vnet_data_init(struct vnet *vnet)
-{
-
- vnet->vnet_data_mem = malloc(VNET_SIZE, M_VNET_DATA, M_WAITOK);
- memcpy(vnet->vnet_data_mem, (void *)VNET_START, VNET_BYTES);
-
- /*
- * All use of vnet-specific data will immediately subtract VNET_START
- * from the base memory pointer, so pre-calculate that now to avoid
- * it on each use.
- */
- vnet->vnet_data_base = (uintptr_t)vnet->vnet_data_mem - VNET_START;
-}
-
-/*
- * Release storage for a virtual network stack instance.
- */
-void
-vnet_data_destroy(struct vnet *vnet)
-{
-
- free(vnet->vnet_data_mem, M_VNET_DATA);
- vnet->vnet_data_mem = NULL;
- vnet->vnet_data_base = 0;
-}
-
-/*
* Once on boot, initialize the modspace freelist to entirely cover modspace.
*/
static void
diff --git a/sys/net/vnet.h b/sys/net/vnet.h
index 47dc7ac..01d824d 100644
--- a/sys/net/vnet.h
+++ b/sys/net/vnet.h
@@ -217,13 +217,6 @@ void vnet_data_copy(void *start, int size);
void vnet_data_free(void *start_arg, int size);
/*
- * Virtual network stack allocator interfaces for vnet setup/teardown.
- */
-struct vnet;
-void vnet_data_init(struct vnet *vnet);
-void vnet_data_destroy(struct vnet *vnet);
-
-/*
* Sysctl variants for vnet-virtualized global variables. Include
* <sys/sysctl.h> to expose these definitions.
*
OpenPOWER on IntegriCloud