From owner-svn-src-all@FreeBSD.ORG Sat Aug 1 21:54:16 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 034A01065673; Sat, 1 Aug 2009 21:54:16 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DC4908FC0A; Sat, 1 Aug 2009 21:54:15 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n71LsFlY093649; Sat, 1 Aug 2009 21:54:15 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n71LsFBT093646; Sat, 1 Aug 2009 21:54:15 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200908012154.n71LsFBT093646@svn.freebsd.org> From: Robert Watson Date: Sat, 1 Aug 2009 21:54:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196024 - head/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Aug 2009 21:54:16 -0000 Author: rwatson Date: Sat Aug 1 21:54:15 2009 New Revision: 196024 URL: http://svn.freebsd.org/changeset/base/196024 Log: 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) Modified: head/sys/net/vnet.c head/sys/net/vnet.h Modified: head/sys/net/vnet.c ============================================================================== --- head/sys/net/vnet.c Sat Aug 1 21:46:55 2009 (r196023) +++ head/sys/net/vnet.c Sat Aug 1 21:54:15 2009 (r196024) @@ -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 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 Modified: head/sys/net/vnet.h ============================================================================== --- head/sys/net/vnet.h Sat Aug 1 21:46:55 2009 (r196023) +++ head/sys/net/vnet.h Sat Aug 1 21:54:15 2009 (r196024) @@ -217,13 +217,6 @@ void vnet_data_copy(void *start, int si 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 * to expose these definitions. *