summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/in6_src.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/netinet6/in6_src.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/netinet6/in6_src.c')
-rw-r--r--sys/netinet6/in6_src.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index f1ccca1..ffa6c3e 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -100,7 +100,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
-#include <netinet/vinet.h>
#include <netinet6/in6_var.h>
#include <netinet/ip6.h>
@@ -108,7 +107,6 @@ __FBSDID("$FreeBSD$");
#include <netinet6/ip6_var.h>
#include <netinet6/scope6_var.h>
#include <netinet6/nd6.h>
-#include <netinet6/vinet6.h>
static struct mtx addrsel_lock;
#define ADDRSEL_LOCK_INIT() mtx_init(&addrsel_lock, "addrsel_lock", NULL, MTX_DEF)
@@ -125,10 +123,10 @@ static struct sx addrsel_sxlock;
#define ADDR_LABEL_NOTAPP (-1)
-#ifdef VIMAGE_GLOBALS
-struct in6_addrpolicy defaultaddrpolicy;
-int ip6_prefer_tempaddr;
-#endif
+static VNET_DEFINE(struct in6_addrpolicy, defaultaddrpolicy);
+VNET_DEFINE(int, ip6_prefer_tempaddr);
+
+#define V_defaultaddrpolicy VNET_GET(defaultaddrpolicy)
static int selectroute __P((struct sockaddr_in6 *, struct ip6_pktopts *,
struct ip6_moptions *, struct route_in6 *, struct ifnet **,
@@ -184,7 +182,6 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
struct inpcb *inp, struct route_in6 *ro, struct ucred *cred,
struct ifnet **ifpp, struct in6_addr *srcp)
{
- INIT_VNET_INET6(curvnet);
struct in6_addr dst;
struct ifnet *ifp = NULL;
struct in6_ifaddr *ia = NULL, *ia_best = NULL;
@@ -488,7 +485,6 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
struct ip6_moptions *mopts, struct route_in6 *ro,
struct ifnet **retifp, struct rtentry **retrt, int norouteok)
{
- INIT_VNET_INET6(curvnet);
int error = 0;
struct ifnet *ifp = NULL;
struct rtentry *rt = NULL;
@@ -793,7 +789,6 @@ in6_selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
int
in6_selecthlim(struct inpcb *in6p, struct ifnet *ifp)
{
- INIT_VNET_INET6(curvnet);
if (in6p && in6p->in6p_hops >= 0)
return (in6p->in6p_hops);
@@ -826,7 +821,6 @@ in6_selecthlim(struct inpcb *in6p, struct ifnet *ifp)
int
in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred)
{
- INIT_VNET_INET(curvnet);
struct socket *so = inp->inp_socket;
u_int16_t lport = 0, first, last, *lastport;
int count, error, wild = 0, dorandom;
@@ -928,7 +922,6 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred)
void
addrsel_policy_init(void)
{
- INIT_VNET_INET6(curvnet);
V_ip6_prefer_tempaddr = 0;
@@ -948,7 +941,6 @@ addrsel_policy_init(void)
static struct in6_addrpolicy *
lookup_addrsel_policy(struct sockaddr_in6 *key)
{
- INIT_VNET_INET6(curvnet);
struct in6_addrpolicy *match = NULL;
ADDRSEL_LOCK();
@@ -1035,14 +1027,12 @@ struct addrsel_policyent {
TAILQ_HEAD(addrsel_policyhead, addrsel_policyent);
-#ifdef VIMAGE_GLOBALS
-struct addrsel_policyhead addrsel_policytab;
-#endif
+static VNET_DEFINE(struct addrsel_policyhead, addrsel_policytab);
+#define V_addrsel_policytab VNET_GET(addrsel_policytab)
static void
init_policy_queue(void)
{
- INIT_VNET_INET6(curvnet);
TAILQ_INIT(&V_addrsel_policytab);
}
@@ -1050,7 +1040,6 @@ init_policy_queue(void)
static int
add_addrsel_policyent(struct in6_addrpolicy *newpolicy)
{
- INIT_VNET_INET6(curvnet);
struct addrsel_policyent *new, *pol;
new = malloc(sizeof(*new), M_IFADDR,
@@ -1086,7 +1075,6 @@ add_addrsel_policyent(struct in6_addrpolicy *newpolicy)
static int
delete_addrsel_policyent(struct in6_addrpolicy *key)
{
- INIT_VNET_INET6(curvnet);
struct addrsel_policyent *pol;
ADDRSEL_XLOCK();
@@ -1118,7 +1106,6 @@ static int
walk_addrsel_policy(int (*callback)(struct in6_addrpolicy *, void *),
void *w)
{
- INIT_VNET_INET6(curvnet);
struct addrsel_policyent *pol;
int error = 0;
@@ -1147,7 +1134,6 @@ dump_addrsel_policyent(struct in6_addrpolicy *pol, void *arg)
static struct in6_addrpolicy *
match_addrsel_policy(struct sockaddr_in6 *key)
{
- INIT_VNET_INET6(curvnet);
struct addrsel_policyent *pent;
struct in6_addrpolicy *bestpol = NULL, *pol;
int matchlen, bestmatchlen = -1;
OpenPOWER on IntegriCloud