diff options
author | zec <zec@FreeBSD.org> | 2008-12-10 23:12:39 +0000 |
---|---|---|
committer | zec <zec@FreeBSD.org> | 2008-12-10 23:12:39 +0000 |
commit | 7b573d1496799fd4543bfa925fd691d650b3c628 (patch) | |
tree | 69ada7d351f2f4e8f7205f24e4f8473aad40573d /sys/netgraph | |
parent | f30a0a94fe04dfbd42fcd3337a2bed2f65bd9c4c (diff) | |
download | FreeBSD-src-7b573d1496799fd4543bfa925fd691d650b3c628.zip FreeBSD-src-7b573d1496799fd4543bfa925fd691d650b3c628.tar.gz |
Conditionally compile out V_ globals while instantiating the appropriate
container structures, depending on VIMAGE_GLOBALS compile time option.
Make VIMAGE_GLOBALS a new compile-time option, which by default will not
be defined, resulting in instatiations of global variables selected for
V_irtualization (enclosed in #ifdef VIMAGE_GLOBALS blocks) to be
effectively compiled out. Instantiate new global container structures
to hold V_irtualized variables: vnet_net_0, vnet_inet_0, vnet_inet6_0,
vnet_ipsec_0, vnet_netgraph_0, and vnet_gif_0.
Update the VSYM() macro so that depending on VIMAGE_GLOBALS the V_
macros resolve either to the original globals, or to fields inside
container structures, i.e. effectively
#ifdef VIMAGE_GLOBALS
#define V_rt_tables rt_tables
#else
#define V_rt_tables vnet_net_0._rt_tables
#endif
Update SYSCTL_V_*() macros to operate either on globals or on fields
inside container structs.
Extend the internal kldsym() lookups with the ability to resolve
selected fields inside the virtualization container structs. This
applies only to the fields which are explicitly registered for kldsym()
visibility via VNET_MOD_DECLARE() and vnet_mod_register(), currently
this is done only in sys/net/if.c.
Fix a few broken instances of MODULE_GLOBAL() macro use in SCTP code,
and modify the MODULE_GLOBAL() macro to resolve to V_ macros, which in
turn result in proper code being generated depending on VIMAGE_GLOBALS.
De-virtualize local static variables in sys/contrib/pf/net/pf_subr.c
which were prematurely V_irtualized by automated V_ prepending scripts
during earlier merging steps. PF virtualization will be done
separately, most probably after next PF import.
Convert a few variable initializations at instantiation to
initialization in init functions, most notably in ipfw. Also convert
TUNABLE_INT() initializers for V_ variables to TUNABLE_FETCH_INT() in
initializer functions.
Discussed at: devsummit Strassburg
Reviewed by: bz, julian
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
Diffstat (limited to 'sys/netgraph')
-rw-r--r-- | sys/netgraph/netgraph.h | 6 | ||||
-rw-r--r-- | sys/netgraph/ng_base.c | 15 | ||||
-rw-r--r-- | sys/netgraph/ng_bridge.c | 2 | ||||
-rw-r--r-- | sys/netgraph/ng_eiface.c | 2 | ||||
-rw-r--r-- | sys/netgraph/ng_iface.c | 2 | ||||
-rw-r--r-- | sys/netgraph/ng_ipfw.c | 2 |
6 files changed, 28 insertions, 1 deletions
diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h index 0def641..4072f76 100644 --- a/sys/netgraph/netgraph.h +++ b/sys/netgraph/netgraph.h @@ -1205,6 +1205,12 @@ struct vnet_netgraph { struct unrhdr *_ng_wormhole_unit; }; +#ifndef VIMAGE +#ifndef VIMAGE_GLOBALS +extern struct vnet_netgraph vnet_netgraph_0; +#endif +#endif + /* Symbol translation macros */ #define V_nextID VNET_NETGRAPH(nextID) #define V_ng_ID_hash VNET_NETGRAPH(ng_ID_hash) diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index 24ed885..0406da1 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -72,6 +72,12 @@ MODULE_VERSION(netgraph, NG_ABI_VERSION); +#ifndef VIMAGE +#ifndef VIMAGE_GLOBALS +struct vnet_netgraph vnet_netgraph_0; +#endif +#endif + /* Mutex to protect topology events. */ static struct mtx ng_topo_mtx; @@ -167,7 +173,9 @@ static struct mtx ng_typelist_mtx; /* Hash related definitions */ /* XXX Don't need to initialise them because it's a LIST */ +#ifdef VIMAGE_GLOBALS static LIST_HEAD(, ng_node) ng_ID_hash[NG_ID_HASH_SIZE]; +#endif static struct mtx ng_idhash_mtx; /* Method to find a node.. used twice so do it here */ #define NG_IDHASH_FN(ID) ((ID) % (NG_ID_HASH_SIZE)) @@ -183,7 +191,9 @@ static struct mtx ng_idhash_mtx; } \ } while (0) +#ifdef VIMAGE_GLOBALS static LIST_HEAD(, ng_node) ng_name_hash[NG_NAME_HASH_SIZE]; +#endif static struct mtx ng_namehash_mtx; #define NG_NAMEHASH(NAME, HASH) \ do { \ @@ -348,7 +358,9 @@ ng_alloc_node(void) #define TRAP_ERROR() #endif -static ng_ID_t nextID = 1; +#ifdef VIMAGE_GLOBALS +static ng_ID_t nextID; +#endif #ifdef INVARIANTS #define CHECK_DATA_MBUF(m) do { \ @@ -3063,6 +3075,7 @@ ngb_mod_event(module_t mod, int event, void *data) switch (event) { case MOD_LOAD: /* Initialize everything. */ + V_nextID = 1; NG_WORKLIST_LOCK_INIT(); mtx_init(&ng_typelist_mtx, "netgraph types mutex", NULL, MTX_DEF); diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index c033a55..d998f1e 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -61,9 +61,11 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/lock.h> #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/errno.h> +#include <sys/rwlock.h> #include <sys/syslog.h> #include <sys/socket.h> #include <sys/ctype.h> diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c index 3d92e5f..542eaad 100644 --- a/sys/netgraph/ng_eiface.c +++ b/sys/netgraph/ng_eiface.c @@ -113,7 +113,9 @@ static struct ng_type typestruct = { }; NETGRAPH_INIT(eiface, &typestruct); +#ifdef VIMAGE_GLOBALS static struct unrhdr *ng_eiface_unit; +#endif /************************************************************************ INTERFACE STUFF diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 35fc1cc8..2295004 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -208,7 +208,9 @@ static struct ng_type typestruct = { }; NETGRAPH_INIT(iface, &typestruct); +#ifdef VIMAGE_GLOBALS static struct unrhdr *ng_iface_unit; +#endif /************************************************************************ HELPER STUFF diff --git a/sys/netgraph/ng_ipfw.c b/sys/netgraph/ng_ipfw.c index 91af215..cce623b 100644 --- a/sys/netgraph/ng_ipfw.c +++ b/sys/netgraph/ng_ipfw.c @@ -29,10 +29,12 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/lock.h> #include <sys/mbuf.h> #include <sys/malloc.h> #include <sys/ctype.h> #include <sys/errno.h> +#include <sys/rwlock.h> #include <sys/socket.h> #include <sys/syslog.h> |