diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-07-14 22:48:30 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-07-14 22:48:30 +0000 |
commit | 57ca4583e728cab422fba8f15de10bd0b637b3dd (patch) | |
tree | 13848f891fb2f7a396281b31633563d0f764ff65 /sys/netinet6/nd6_rtr.c | |
parent | ef443476d9706035ac219f0280ef0b817dda7a6d (diff) | |
download | FreeBSD-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/netinet6/nd6_rtr.c')
-rw-r--r-- | sys/netinet6/nd6_rtr.c | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index c746fcd..86e8818 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$"); #include <netinet6/nd6.h> #include <netinet/icmp6.h> #include <netinet6/scope6_var.h> -#include <netinet6/vinet6.h> static int rtpref(struct nd_defrouter *); static struct nd_defrouter *defrtrlist_update(struct nd_defrouter *); @@ -88,18 +87,18 @@ static void in6_init_address_ltimes __P((struct nd_prefix *, static int rt6_deleteroute(struct radix_node *, void *); -#ifdef VIMAGE_GLOBALS -extern int nd6_recalc_reachtm_interval; +VNET_DECLARE(int, nd6_recalc_reachtm_interval); +#define V_nd6_recalc_reachtm_interval VNET_GET(nd6_recalc_reachtm_interval) -static struct ifnet *nd6_defifp; -int nd6_defifindex; +static VNET_DEFINE(struct ifnet *, nd6_defifp); +#define V_nd6_defifp VNET_GET(nd6_defifp) -int ip6_use_tempaddr; -int ip6_desync_factor; -u_int32_t ip6_temp_preferred_lifetime; -u_int32_t ip6_temp_valid_lifetime; -int ip6_temp_regen_advance; -#endif +VNET_DEFINE(int, nd6_defifindex); +VNET_DEFINE(int, ip6_use_tempaddr); +VNET_DEFINE(int, ip6_desync_factor); +VNET_DEFINE(u_int32_t, ip6_temp_preferred_lifetime); +VNET_DEFINE(u_int32_t, ip6_temp_valid_lifetime); +VNET_DEFINE(int, ip6_temp_regen_advance); /* RTPREF_MEDIUM has to be 0! */ #define RTPREF_HIGH 1 @@ -118,7 +117,6 @@ int ip6_temp_regen_advance; void nd6_rs_input(struct mbuf *m, int off, int icmp6len) { - INIT_VNET_INET6(curvnet); struct ifnet *ifp = m->m_pkthdr.rcvif; struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct nd_router_solicit *nd_rs; @@ -203,7 +201,6 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len) void nd6_ra_input(struct mbuf *m, int off, int icmp6len) { - INIT_VNET_INET6(curvnet); struct ifnet *ifp = m->m_pkthdr.rcvif; struct nd_ifinfo *ndi = ND_IFINFO(ifp); struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); @@ -491,7 +488,6 @@ defrouter_addreq(struct nd_defrouter *new) struct nd_defrouter * defrouter_lookup(struct in6_addr *addr, struct ifnet *ifp) { - INIT_VNET_INET6(ifp->if_vnet); struct nd_defrouter *dr; for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; @@ -540,7 +536,6 @@ defrouter_delreq(struct nd_defrouter *dr) void defrouter_reset(void) { - INIT_VNET_INET6(curvnet); struct nd_defrouter *dr; for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; @@ -556,7 +551,6 @@ defrouter_reset(void) void defrtrlist_del(struct nd_defrouter *dr) { - INIT_VNET_INET6(curvnet); struct nd_defrouter *deldr = NULL; struct nd_prefix *pr; @@ -618,7 +612,6 @@ defrtrlist_del(struct nd_defrouter *dr) void defrouter_select(void) { - INIT_VNET_INET6(curvnet); int s = splnet(); struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL; struct llentry *ln = NULL; @@ -743,7 +736,6 @@ rtpref(struct nd_defrouter *dr) static struct nd_defrouter * defrtrlist_update(struct nd_defrouter *new) { - INIT_VNET_INET6(curvnet); struct nd_defrouter *dr, *n; int s = splnet(); @@ -865,7 +857,6 @@ pfxrtr_del(struct nd_pfxrouter *pfr) struct nd_prefix * nd6_prefix_lookup(struct nd_prefixctl *key) { - INIT_VNET_INET6(curvnet); struct nd_prefix *search; for (search = V_nd_prefix.lh_first; @@ -885,7 +876,6 @@ int nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr, struct nd_prefix **newp) { - INIT_VNET_INET6(curvnet); struct nd_prefix *new = NULL; int error = 0; int i, s; @@ -944,7 +934,6 @@ nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr, void prelist_remove(struct nd_prefix *pr) { - INIT_VNET_INET6(curvnet); struct nd_pfxrouter *pfr, *next; int e, s; char ip6buf[INET6_ADDRSTRLEN]; @@ -997,7 +986,6 @@ static int prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr, struct mbuf *m, int mcast) { - INIT_VNET_INET6(curvnet); struct in6_ifaddr *ia6 = NULL, *ia6_match = NULL; struct ifaddr *ifa; struct ifnet *ifp = new->ndpr_ifp; @@ -1374,7 +1362,6 @@ find_pfxlist_reachable_router(struct nd_prefix *pr) void pfxlist_onlink_check() { - INIT_VNET_INET6(curvnet); struct nd_prefix *pr; struct in6_ifaddr *ifa; struct nd_defrouter *dr; @@ -1556,7 +1543,6 @@ pfxlist_onlink_check() int nd6_prefix_onlink(struct nd_prefix *pr) { - INIT_VNET_INET6(curvnet); struct ifaddr *ifa; struct ifnet *ifp = pr->ndpr_ifp; struct sockaddr_in6 mask6; @@ -1682,7 +1668,6 @@ nd6_prefix_onlink(struct nd_prefix *pr) int nd6_prefix_offlink(struct nd_prefix *pr) { - INIT_VNET_INET6(curvnet); int error = 0; struct ifnet *ifp = pr->ndpr_ifp; struct nd_prefix *opr; @@ -1774,7 +1759,6 @@ nd6_prefix_offlink(struct nd_prefix *pr) static struct in6_ifaddr * in6_ifadd(struct nd_prefixctl *pr, int mcast) { - INIT_VNET_INET6(curvnet); struct ifnet *ifp = pr->ndpr_ifp; struct ifaddr *ifa; struct in6_aliasreq ifra; @@ -1912,7 +1896,6 @@ in6_ifadd(struct nd_prefixctl *pr, int mcast) int in6_tmpifadd(const struct in6_ifaddr *ia0, int forcegen, int delay) { - INIT_VNET_INET6(curvnet); struct ifnet *ifp = ia0->ia_ifa.ifa_ifp; struct in6_ifaddr *newia, *ia; struct in6_aliasreq ifra; @@ -2141,8 +2124,6 @@ rt6_deleteroute(struct radix_node *rn, void *arg) int nd6_setdefaultiface(int ifindex) { - INIT_VNET_NET(curvnet); - INIT_VNET_INET6(curvnet); int error = 0; if (ifindex < 0 || V_if_index < ifindex) |