summaryrefslogtreecommitdiffstats
path: root/sys/netipsec/xform_ipip.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/netipsec/xform_ipip.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/netipsec/xform_ipip.c')
-rw-r--r--sys/netipsec/xform_ipip.c40
1 files changed, 9 insertions, 31 deletions
diff --git a/sys/netipsec/xform_ipip.c b/sys/netipsec/xform_ipip.c
index d9cf8c6..8de23ec 100644
--- a/sys/netipsec/xform_ipip.c
+++ b/sys/netipsec/xform_ipip.c
@@ -68,7 +68,6 @@
#ifdef MROUTING
#include <netinet/ip_mroute.h>
#endif
-#include <netinet/vinet.h>
#include <netipsec/ipsec.h>
#include <netipsec/xform.h>
@@ -92,31 +91,27 @@
* We can control the acceptance of IP4 packets by altering the sysctl
* net.inet.ipip.allow value. Zero means drop them, all else is acceptance.
*/
-#ifdef VIMAGE_GLOBALS
-int ipip_allow;
-struct ipipstat ipipstat;
-#endif
+VNET_DEFINE(int, ipip_allow) = 0;
+VNET_DEFINE(struct ipipstat, ipipstat);
SYSCTL_DECL(_net_inet_ipip);
-SYSCTL_V_INT(V_NET, vnet_ipsec, _net_inet_ipip, OID_AUTO,
- ipip_allow, CTLFLAG_RW, ipip_allow, 0, "");
-SYSCTL_V_STRUCT(V_NET, vnet_ipsec, _net_inet_ipip, IPSECCTL_STATS,
- stats, CTLFLAG_RD, ipipstat, ipipstat, "");
+SYSCTL_VNET_INT(_net_inet_ipip, OID_AUTO,
+ ipip_allow, CTLFLAG_RW, &VNET_NAME(ipip_allow), 0, "");
+SYSCTL_VNET_STRUCT(_net_inet_ipip, IPSECCTL_STATS,
+ stats, CTLFLAG_RD, &VNET_NAME(ipipstat), ipipstat, "");
/* XXX IPCOMP */
#define M_IPSEC (M_AUTHIPHDR|M_AUTHIPDGM|M_DECRYPTED)
static void _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp);
-static int ipe4_iattach(const void *);
-#ifndef VIMAGE_GLOBALS
+#ifdef VIMAGE
static const vnet_modinfo_t vnet_ipip_modinfo = {
.vmi_id = VNET_MOD_IPIP,
.vmi_name = "ipsec_ipip",
.vmi_dependson = VNET_MOD_IPSEC,
- .vmi_iattach = ipe4_iattach
};
-#endif /* !VIMAGE_GLOBALS */
+#endif
#ifdef INET6
/*
@@ -169,8 +164,6 @@ ip4_input(struct mbuf *m, int off)
static void
_ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
{
- INIT_VNET_NET(curvnet);
- INIT_VNET_IPSEC(curvnet);
#ifdef INET
register struct sockaddr_in *sin;
#endif
@@ -424,10 +417,6 @@ ipip_output(
int protoff
)
{
- INIT_VNET_IPSEC(curvnet);
-#ifdef INET
- INIT_VNET_INET(curvnet);
-#endif /* INET */
struct secasvar *sav;
u_int8_t tp, otos;
struct secasindex *saidx;
@@ -708,15 +697,6 @@ ipe4_encapcheck(const struct mbuf *m, int off, int proto, void *arg)
return ((m->m_flags & M_IPSEC) != 0 ? 1 : 0);
}
-static int
-ipe4_iattach(const void *unused __unused)
-{
- INIT_VNET_IPSEC(curvnet);
-
- V_ipip_allow = 0;
- return (0);
-}
-
static void
ipe4_attach(void)
{
@@ -730,10 +710,8 @@ ipe4_attach(void)
(void) encap_attach_func(AF_INET6, -1,
ipe4_encapcheck, (struct protosw *)&ipe6_protosw, NULL);
#endif
-#ifndef VIMAGE_GLOBALS
+#ifdef VIMAGE
vnet_mod_register(&vnet_ipip_modinfo);
-#else
- ipe4_iattach(NULL);
#endif
}
SYSINIT(ipe4_xform_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_MIDDLE, ipe4_attach, NULL);
OpenPOWER on IntegriCloud