summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/ip6_input.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/ip6_input.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/ip6_input.c')
-rw-r--r--sys/netinet6/ip6_input.c60
1 files changed, 26 insertions, 34 deletions
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index b9d594c..78c0901 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -96,7 +96,6 @@ __FBSDID("$FreeBSD$");
#ifdef INET
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
-#include <netinet/vinet.h>
#endif /* INET */
#include <netinet/ip6.h>
#include <netinet6/in6_var.h>
@@ -106,7 +105,6 @@ __FBSDID("$FreeBSD$");
#include <netinet6/scope6_var.h>
#include <netinet6/in6_ifattach.h>
#include <netinet6/nd6.h>
-#include <netinet6/vinet6.h>
#ifdef IPSEC
#include <netipsec/ipsec.h>
@@ -127,28 +125,30 @@ static struct netisr_handler ip6_nh = {
.nh_policy = NETISR_POLICY_FLOW,
};
-#ifndef VIMAGE
-#ifndef VIMAGE_GLOBALS
-struct vnet_inet6 vnet_inet6_0;
-#endif
-#endif
-
-#ifdef VIMAGE_GLOBALS
-struct in6_ifaddrhead in6_ifaddrhead;
-struct ip6stat ip6stat;
-
-extern struct callout in6_tmpaddrtimer_ch;
-
-extern int dad_init;
-extern int pmtu_expire;
-extern int pmtu_probe;
-extern u_long rip6_sendspace;
-extern u_long rip6_recvspace;
-extern int icmp6errppslim;
-extern int icmp6_nodeinfo;
-extern int udp6_sendspace;
-extern int udp6_recvspace;
-#endif
+VNET_DEFINE(struct in6_ifaddrhead, in6_ifaddrhead);
+VNET_DEFINE(struct ip6stat, ip6stat);
+
+VNET_DECLARE(struct callout, in6_tmpaddrtimer_ch);
+VNET_DECLARE(int, dad_init);
+VNET_DECLARE(int, pmtu_expire);
+VNET_DECLARE(int, pmtu_probe);
+VNET_DECLARE(u_long, rip6_sendspace);
+VNET_DECLARE(u_long, rip6_recvspace);
+VNET_DECLARE(int, icmp6errppslim);
+VNET_DECLARE(int, icmp6_nodeinfo);
+VNET_DECLARE(int, udp6_sendspace);
+VNET_DECLARE(int, udp6_recvspace);
+
+#define V_in6_tmpaddrtimer_ch VNET_GET(in6_tmpaddrtimer_ch)
+#define V_dad_init VNET_GET(dad_init)
+#define V_pmtu_expire VNET_GET(pmtu_expire)
+#define V_pmtu_probe VNET_GET(pmtu_probe)
+#define V_rip6_sendspace VNET_GET(rip6_sendspace)
+#define V_rip6_recvspace VNET_GET(rip6_recvspace)
+#define V_icmp6errppslim VNET_GET(icmp6errppslim)
+#define V_icmp6_nodeinfo VNET_GET(icmp6_nodeinfo)
+#define V_udp6_sendspace VNET_GET(udp6_sendspace)
+#define V_udp6_recvspace VNET_GET(udp6_recvspace)
struct rwlock in6_ifaddr_lock;
RW_SYSINIT(in6_ifaddr_lock, &in6_ifaddr_lock, "in6_ifaddr_lock");
@@ -162,13 +162,13 @@ static int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *);
static struct mbuf *ip6_pullexthdr(struct mbuf *, size_t, int);
#endif
-#ifndef VIMAGE_GLOBALS
+#ifdef VIMAGE
+/* XXX only has to stay for .vmi_dependson elsewhere. */
static void vnet_inet6_register(void);
static const vnet_modinfo_t vnet_inet6_modinfo = {
.vmi_id = VNET_MOD_INET6,
.vmi_name = "inet6",
- .vmi_size = sizeof(struct vnet_inet6),
.vmi_dependson = VNET_MOD_INET /* XXX revisit - TCP/UDP needs this? */
};
@@ -189,7 +189,6 @@ SYSINIT(inet6, SI_SUB_PROTO_BEGIN, SI_ORDER_FIRST, vnet_inet6_register, 0);
void
ip6_init(void)
{
- INIT_VNET_INET6(curvnet);
struct ip6protosw *pr;
int i;
@@ -311,7 +310,6 @@ ip6_init(void)
void
ip6_destroy()
{
- INIT_VNET_INET6(curvnet);
nd6_destroy();
callout_drain(&V_in6_tmpaddrtimer_ch);
@@ -321,7 +319,6 @@ ip6_destroy()
static int
ip6_init2_vnet(const void *unused __unused)
{
- INIT_VNET_INET6(curvnet);
/* nd6_timer_init */
callout_init(&V_nd6_timer_ch, 0);
@@ -351,8 +348,6 @@ SYSINIT(netinet6init2, SI_SUB_PROTO_DOMAIN, SI_ORDER_MIDDLE, ip6_init2, NULL);
void
ip6_input(struct mbuf *m)
{
- INIT_VNET_NET(curvnet);
- INIT_VNET_INET6(curvnet);
struct ip6_hdr *ip6;
int off = sizeof(struct ip6_hdr), nest;
u_int32_t plen;
@@ -967,7 +962,6 @@ static int
ip6_hopopts_input(u_int32_t *plenp, u_int32_t *rtalertp,
struct mbuf **mp, int *offp)
{
- INIT_VNET_INET6(curvnet);
struct mbuf *m = *mp;
int off = *offp, hbhlen;
struct ip6_hbh *hbh;
@@ -1023,7 +1017,6 @@ int
ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
u_int32_t *rtalertp, u_int32_t *plenp)
{
- INIT_VNET_INET6(curvnet);
struct ip6_hdr *ip6;
int optlen = 0;
u_int8_t *opt = opthead;
@@ -1156,7 +1149,6 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
int
ip6_unknown_opt(u_int8_t *optp, struct mbuf *m, int off)
{
- INIT_VNET_INET6(curvnet);
struct ip6_hdr *ip6;
switch (IP6OPT_TYPE(*optp)) {
OpenPOWER on IntegriCloud