Hi, These global initialized variables behave poorly with MP. I would like to put the tdb pool init into an init function.
ok? bluhm Index: netinet/ip_ipsp.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_ipsp.c,v retrieving revision 1.244 diff -u -p -r1.244 ip_ipsp.c --- netinet/ip_ipsp.c 27 Jul 2021 17:13:03 -0000 1.244 +++ netinet/ip_ipsp.c 28 Sep 2021 22:26:54 -0000 @@ -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); Index: netinet/ip_ipsp.h =================================================================== RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_ipsp.h,v retrieving revision 1.206 diff -u -p -r1.206 ip_ipsp.h --- netinet/ip_ipsp.h 10 Aug 2021 21:29:53 -0000 1.206 +++ netinet/ip_ipsp.h 28 Sep 2021 22:26:28 -0000 @@ -640,6 +640,7 @@ struct ipsec_ids *ipsp_ids_insert(struct 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); Index: netinet/ipsec_input.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ipsec_input.c,v retrieving revision 1.179 diff -u -p -r1.179 ipsec_input.c --- netinet/ipsec_input.c 27 Jul 2021 17:13:03 -0000 1.179 +++ netinet/ipsec_input.c 28 Sep 2021 22:27:40 -0000 @@ -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(); } /*