From 57ca4583e728cab422fba8f15de10bd0b637b3dd Mon Sep 17 00:00:00 2001 From: rwatson Date: Tue, 14 Jul 2009 22:48:30 +0000 Subject: 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) --- sys/netinet6/nd6.h | 56 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 20 deletions(-) (limited to 'sys/netinet6/nd6.h') diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index 0730d84..f54e02e 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -318,28 +318,44 @@ struct nd_pfxrouter { LIST_HEAD(nd_prhead, nd_prefix); /* nd6.c */ -#ifdef VIMAGE_GLOBALS -extern int nd6_prune; -extern int nd6_delay; -extern int nd6_umaxtries; -extern int nd6_mmaxtries; -extern int nd6_useloopback; -extern int nd6_maxnudhint; -extern int nd6_gctimer; -extern struct nd_drhead nd_defrouter; -extern struct nd_prhead nd_prefix; -extern int nd6_debug; -extern int nd6_onlink_ns_rfc4861; - -extern struct callout nd6_timer_ch; +VNET_DECLARE(int, nd6_prune); +VNET_DECLARE(int, nd6_delay); +VNET_DECLARE(int, nd6_umaxtries); +VNET_DECLARE(int, nd6_mmaxtries); +VNET_DECLARE(int, nd6_useloopback); +VNET_DECLARE(int, nd6_maxnudhint); +VNET_DECLARE(int, nd6_gctimer); +VNET_DECLARE(struct nd_drhead, nd_defrouter); +VNET_DECLARE(struct nd_prhead, nd_prefix); +VNET_DECLARE(int, nd6_debug); +VNET_DECLARE(int, nd6_onlink_ns_rfc4861); +VNET_DECLARE(struct callout, nd6_timer_ch); + +#define V_nd6_prune VNET_GET(nd6_prune) +#define V_nd6_delay VNET_GET(nd6_delay) +#define V_nd6_umaxtries VNET_GET(nd6_umaxtries) +#define V_nd6_mmaxtries VNET_GET(nd6_mmaxtries) +#define V_nd6_useloopback VNET_GET(nd6_useloopback) +#define V_nd6_maxnudhint VNET_GET(nd6_maxnudhint) +#define V_nd6_gctimer VNET_GET(nd6_gctimer) +#define V_nd_defrouter VNET_GET(nd_defrouter) +#define V_nd_prefix VNET_GET(nd_prefix) +#define V_nd6_debug VNET_GET(nd6_debug) +#define V_nd6_onlink_ns_rfc4861 VNET_GET(nd6_onlink_ns_rfc4861) +#define V_nd6_timer_ch VNET_GET(nd6_timer_ch) /* nd6_rtr.c */ -extern int nd6_defifindex; -extern int ip6_desync_factor; /* seconds */ -extern u_int32_t ip6_temp_preferred_lifetime; /* seconds */ -extern u_int32_t ip6_temp_valid_lifetime; /* seconds */ -extern int ip6_temp_regen_advance; /* seconds */ -#endif /* VIMAGE_GLOBALS */ +VNET_DECLARE(int, nd6_defifindex); +VNET_DECLARE(int, ip6_desync_factor); /* seconds */ +VNET_DECLARE(u_int32_t, ip6_temp_preferred_lifetime); /* seconds */ +VNET_DECLARE(u_int32_t, ip6_temp_valid_lifetime); /* seconds */ +VNET_DECLARE(int, ip6_temp_regen_advance); /* seconds */ + +#define V_nd6_defifindex VNET_GET(nd6_defifindex) +#define V_ip6_desync_factor VNET_GET(ip6_desync_factor) +#define V_ip6_temp_preferred_lifetime VNET_GET(ip6_temp_preferred_lifetime) +#define V_ip6_temp_valid_lifetime VNET_GET(ip6_temp_valid_lifetime) +#define V_ip6_temp_regen_advance VNET_GET(ip6_temp_regen_advance) #define nd6log(x) do { if (V_nd6_debug) log x; } while (/*CONSTCOND*/ 0) -- cgit v1.1