summaryrefslogtreecommitdiffstats
path: root/sys/netipsec/xform_ah.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_ah.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_ah.c')
-rw-r--r--sys/netipsec/xform_ah.c54
1 files changed, 10 insertions, 44 deletions
diff --git a/sys/netipsec/xform_ah.c b/sys/netipsec/xform_ah.c
index 07d7001..658c92c 100644
--- a/sys/netipsec/xform_ah.c
+++ b/sys/netipsec/xform_ah.c
@@ -49,6 +49,7 @@
#include <sys/vimage.h>
#include <net/if.h>
+#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -73,17 +74,6 @@
#include <opencrypto/cryptodev.h>
-static int ah_iattach(const void *);
-
-#ifndef VIMAGE_GLOBALS
-static const vnet_modinfo_t vnet_ah_modinfo = {
- .vmi_id = VNET_MOD_AH,
- .vmi_name = "ipsec_ah",
- .vmi_dependson = VNET_MOD_IPSEC,
- .vmi_iattach = ah_iattach
-};
-#endif /* !VIMAGE_GLOBALS */
-
/*
* Return header size in bytes. The old protocol did not support
* the replay counter; the new protocol always includes the counter.
@@ -99,19 +89,17 @@ static const vnet_modinfo_t vnet_ah_modinfo = {
#define AUTHSIZE(sav) \
((sav->flags & SADB_X_EXT_OLD) ? 16 : AH_HMAC_HASHLEN)
-#ifdef VIMAGE_GLOBALS
-int ah_enable;
-int ah_cleartos;
-struct ahstat ahstat;
-#endif
+VNET_DEFINE(int, ah_enable) = 1; /* control flow of packets with AH */
+VNET_DEFINE(int, ah_cleartos) = 1; /* clear ip_tos when doing AH calc */
+VNET_DEFINE(struct ahstat, ahstat);
SYSCTL_DECL(_net_inet_ah);
-SYSCTL_V_INT(V_NET, vnet_ipsec, _net_inet_ah, OID_AUTO,
- ah_enable, CTLFLAG_RW, ah_enable, 0, "");
-SYSCTL_V_INT(V_NET, vnet_ipsec, _net_inet_ah, OID_AUTO,
- ah_cleartos, CTLFLAG_RW, ah_cleartos, 0, "");
-SYSCTL_V_STRUCT(V_NET, vnet_ipsec, _net_inet_ah, IPSECCTL_STATS,
- stats, CTLFLAG_RD, ahstat, ahstat, "");
+SYSCTL_VNET_INT(_net_inet_ah, OID_AUTO,
+ ah_enable, CTLFLAG_RW, &VNET_NAME(ah_enable), 0, "");
+SYSCTL_VNET_INT(_net_inet_ah, OID_AUTO,
+ ah_cleartos, CTLFLAG_RW, &VNET_NAME(ah_cleartos), 0, "");
+SYSCTL_VNET_STRUCT(_net_inet_ah, IPSECCTL_STATS,
+ stats, CTLFLAG_RD, &VNET_NAME(ahstat), ahstat, "");
static unsigned char ipseczeroes[256]; /* larger than an ip6 extension hdr */
@@ -173,7 +161,6 @@ ah_hdrsiz(struct secasvar *sav)
int
ah_init0(struct secasvar *sav, struct xformsw *xsp, struct cryptoini *cria)
{
- INIT_VNET_IPSEC(curvnet);
struct auth_hash *thash;
int keylen;
@@ -228,7 +215,6 @@ ah_init0(struct secasvar *sav, struct xformsw *xsp, struct cryptoini *cria)
static int
ah_init(struct secasvar *sav, struct xformsw *xsp)
{
- INIT_VNET_IPSEC(curvnet);
struct cryptoini cria;
int error;
@@ -263,7 +249,6 @@ ah_zeroize(struct secasvar *sav)
static int
ah_massage_headers(struct mbuf **m0, int proto, int skip, int alg, int out)
{
- INIT_VNET_IPSEC(curvnet);
struct mbuf *m = *m0;
unsigned char *ptr;
int off, count;
@@ -568,7 +553,6 @@ ah_massage_headers(struct mbuf **m0, int proto, int skip, int alg, int out)
static int
ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
{
- INIT_VNET_IPSEC(curvnet);
struct auth_hash *ahx;
struct tdb_ident *tdbi;
struct tdb_crypto *tc;
@@ -738,7 +722,6 @@ ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
static int
ah_input_cb(struct cryptop *crp)
{
- INIT_VNET_IPSEC(curvnet);
int rplen, error, skip, protoff;
unsigned char calc[AH_ALEN_MAX];
struct mbuf *m;
@@ -901,7 +884,6 @@ ah_output(
int skip,
int protoff)
{
- INIT_VNET_IPSEC(curvnet);
struct secasvar *sav;
struct auth_hash *ahx;
struct cryptodesc *crda;
@@ -1128,7 +1110,6 @@ bad:
static int
ah_output_cb(struct cryptop *crp)
{
- INIT_VNET_IPSEC(curvnet);
int skip, protoff, error;
struct tdb_crypto *tc;
struct ipsecrequest *isr;
@@ -1232,21 +1213,6 @@ ah_attach(void)
{
xform_register(&ah_xformsw);
-#ifndef VIMAGE_GLOBALS
- vnet_mod_register(&vnet_ah_modinfo);
-#else
- ah_iattach(NULL);
-#endif
}
-static int
-ah_iattach(const void *unused __unused)
-{
- INIT_VNET_IPSEC(curvnet);
-
- V_ah_enable = 1; /* control flow of packets with AH */
- V_ah_cleartos = 1; /* clear ip_tos when doing AH calc */
-
- return (0);
-}
SYSINIT(ah_xform_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_MIDDLE, ah_attach, NULL);
OpenPOWER on IntegriCloud