summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_eiface.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-07-14 22:48:30 +0000
committerrwatson <rwatson@FreeBSD.org>2009-07-14 22:48:30 +0000
commit57ca4583e728cab422fba8f15de10bd0b637b3dd (patch)
tree13848f891fb2f7a396281b31633563d0f764ff65 /sys/netgraph/ng_eiface.c
parentef443476d9706035ac219f0280ef0b817dda7a6d (diff)
downloadFreeBSD-src-57ca4583e728cab422fba8f15de10bd0b637b3dd.zip
FreeBSD-src-57ca4583e728cab422fba8f15de10bd0b637b3dd.tar.gz
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual network stack memory allocator. Modify vnet to use the allocator instead of monolithic global container structures (vinet, ...). This change solves many binary compatibility problems associated with VIMAGE, and restores ELF symbols for virtualized global variables. Each virtualized global variable exists as a "reference copy", and also once per virtual network stack. Virtualized global variables are tagged at compile-time, placing the in a special linker set, which is loaded into a contiguous region of kernel memory. Virtualized global variables in the base kernel are linked as normal, but those in modules are copied and relocated to a reserved portion of the kernel's vnet region with the help of a the kernel linker. Virtualized global variables exist in per-vnet memory set up when the network stack instance is created, and are initialized statically from the reference copy. Run-time access occurs via an accessor macro, which converts from the current vnet and requested symbol to a per-vnet address. When "options VIMAGE" is not compiled into the kernel, normal global ELF symbols will be used instead and indirection is avoided. This change restores static initialization for network stack global variables, restores support for non-global symbols and types, eliminates the need for many subsystem constructors, eliminates large per-subsystem structures that caused many binary compatibility issues both for monitoring applications (netstat) and kernel modules, removes the per-function INIT_VNET_*() macros throughout the stack, eliminates the need for vnet_symmap ksym(2) munging, and eliminates duplicate definitions of virtualized globals under VIMAGE_GLOBALS. Bump __FreeBSD_version and update UPDATING. Portions submitted by: bz Reviewed by: bz, zec Discussed with: gnn, jamie, jeff, jhb, julian, sam Suggested by: peter Approved by: re (kensmith)
Diffstat (limited to 'sys/netgraph/ng_eiface.c')
-rw-r--r--sys/netgraph/ng_eiface.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c
index 27b4b45..9969924 100644
--- a/sys/netgraph/ng_eiface.c
+++ b/sys/netgraph/ng_eiface.c
@@ -116,11 +116,10 @@ NETGRAPH_INIT(eiface, &typestruct);
static vnet_attach_fn ng_eiface_iattach;
static vnet_detach_fn ng_eiface_idetach;
-#ifdef VIMAGE_GLOBALS
-static struct unrhdr *ng_eiface_unit;
-#endif
+static VNET_DEFINE(struct unrhdr *, ng_eiface_unit);
+#define V_ng_eiface_unit VNET_GET(ng_eiface_unit)
-#ifndef VIMAGE_GLOBALS
+#ifdef VIMAGE
static vnet_modinfo_t vnet_ng_eiface_modinfo = {
.vmi_id = VNET_MOD_NG_EIFACE,
.vmi_name = "ng_eiface",
@@ -351,7 +350,6 @@ ng_eiface_print_ioctl(struct ifnet *ifp, int command, caddr_t data)
static int
ng_eiface_constructor(node_p node)
{
- INIT_VNET_NETGRAPH(curvnet);
struct ifnet *ifp;
priv_p priv;
u_char eaddr[6] = {0,0,0,0,0,0};
@@ -563,7 +561,6 @@ ng_eiface_rcvdata(hook_p hook, item_p item)
static int
ng_eiface_rmnode(node_p node)
{
- INIT_VNET_NETGRAPH(curvnet);
const priv_p priv = NG_NODE_PRIVATE(node);
struct ifnet *const ifp = priv->ifp;
@@ -604,14 +601,14 @@ ng_eiface_mod_event(module_t mod, int event, void *data)
switch (event) {
case MOD_LOAD:
-#ifndef VIMAGE_GLOBALS
+#ifdef VIMAGE
vnet_mod_register(&vnet_ng_eiface_modinfo);
#else
ng_eiface_iattach(NULL);
#endif
break;
case MOD_UNLOAD:
-#ifndef VIMAGE_GLOBALS
+#ifdef VIMAGE
vnet_mod_deregister(&vnet_ng_eiface_modinfo);
#else
ng_eiface_idetach(NULL);
@@ -626,7 +623,6 @@ ng_eiface_mod_event(module_t mod, int event, void *data)
static int ng_eiface_iattach(const void *unused)
{
- INIT_VNET_NETGRAPH(curvnet);
V_ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
@@ -635,7 +631,6 @@ static int ng_eiface_iattach(const void *unused)
static int ng_eiface_idetach(const void *unused)
{
- INIT_VNET_NETGRAPH(curvnet);
delete_unrhdr(V_ng_eiface_unit);
OpenPOWER on IntegriCloud