summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2021-09-29 22:08:14 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2021-09-29 22:08:14 +0000
commitf94d137f226049589995eeeba26ba31c2c888ee4 (patch)
treeadb42dd016533a8b3268e2726ee34750f616cd2b /sys/netinet
parent88f029b53cb158d8d142311c47ade857339f1935 (diff)
Global variables to track initialisation behave poorly with MP.
Move the tdb pool init into an init function. OK mvs@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/ip_ipsp.c15
-rw-r--r--sys/netinet/ip_ipsp.h3
-rw-r--r--sys/netinet/ipsec_input.c3
3 files changed, 12 insertions, 9 deletions
diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c
index 8140f464c5d..ec8769ff0b7 100644
--- a/sys/netinet/ip_ipsp.c
+++ b/sys/netinet/ip_ipsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.c,v 1.244 2021/07/27 17:13:03 mvs Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.245 2021/09/29 22:08:13 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -194,6 +194,13 @@ static struct tdb **tdbsrc = NULL;
static u_int tdb_hashmask = TDB_HASHSIZE_INIT - 1;
static int tdb_count;
+void
+ipsp_init(void)
+{
+ pool_init(&tdb_pool, sizeof(struct tdb), 0, IPL_SOFTNET, 0,
+ "tdb", NULL);
+}
+
/*
* Our hashing function needs to stir things with a non-zero random multiplier
* so we cannot be DoS-attacked via choosing of the data to hash.
@@ -810,15 +817,9 @@ struct tdb *
tdb_alloc(u_int rdomain)
{
struct tdb *tdbp;
- static int initialized = 0;
NET_ASSERT_LOCKED();
- if (!initialized) {
- pool_init(&tdb_pool, sizeof(struct tdb), 0, IPL_SOFTNET, 0,
- "tdb", NULL);
- initialized = 1;
- }
tdbp = pool_get(&tdb_pool, PR_WAITOK | PR_ZERO);
TAILQ_INIT(&tdbp->tdb_policy_head);
diff --git a/sys/netinet/ip_ipsp.h b/sys/netinet/ip_ipsp.h
index 48f5998473a..ab38673996f 100644
--- a/sys/netinet/ip_ipsp.h
+++ b/sys/netinet/ip_ipsp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.h,v 1.206 2021/08/10 21:29:53 mvs Exp $ */
+/* $OpenBSD: ip_ipsp.h,v 1.207 2021/09/29 22:08:13 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -640,6 +640,7 @@ struct ipsec_ids *ipsp_ids_insert(struct ipsec_ids *);
struct ipsec_ids *ipsp_ids_lookup(u_int32_t);
void ipsp_ids_free(struct ipsec_ids *);
+void ipsp_init(void);
void ipsec_init(void);
int ipsec_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int ipsec_common_input(struct mbuf *, int, int, int, int, int);
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c
index eb0fd6f7b6e..e079fa2abfe 100644
--- a/sys/netinet/ipsec_input.c
+++ b/sys/netinet/ipsec_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_input.c,v 1.179 2021/07/27 17:13:03 mvs Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.180 2021/09/29 22:08:13 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -166,6 +166,7 @@ ipsec_init(void)
strlcpy(ipsec_def_auth, IPSEC_DEFAULT_DEF_AUTH, sizeof(ipsec_def_auth));
strlcpy(ipsec_def_comp, IPSEC_DEFAULT_DEF_COMP, sizeof(ipsec_def_comp));
+ ipsp_init();
}
/*