summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_ipsp.c
diff options
context:
space:
mode:
authortobhe <tobhe@cvs.openbsd.org>2021-02-23 19:43:55 +0000
committertobhe <tobhe@cvs.openbsd.org>2021-02-23 19:43:55 +0000
commit3c89907391ada1ea2cb70a84f0e2d4096b315088 (patch)
tree83420dd6c377967bf7977db46ffd06d4ddf97c6e /sys/netinet/ip_ipsp.c
parent276885b095914be7f6aacedbddb8b1eab4cf2c42 (diff)
Use pool to allocate tdbs.
ok patrick@ bluhm@
Diffstat (limited to 'sys/netinet/ip_ipsp.c')
-rw-r--r--sys/netinet/ip_ipsp.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c
index 1755056a647..6b52787c7aa 100644
--- a/sys/netinet/ip_ipsp.c
+++ b/sys/netinet/ip_ipsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.c,v 1.236 2020/06/24 22:03:43 cheloha Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.237 2021/02/23 19:43:54 tobhe Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -46,6 +46,7 @@
#include <sys/socket.h>
#include <sys/kernel.h>
#include <sys/timeout.h>
+#include <sys/pool.h>
#include <net/if.h>
#include <net/route.h>
@@ -90,6 +91,8 @@ int ipsec_in_use = 0;
u_int64_t ipsec_last_added = 0;
int ipsec_ids_idle = 100; /* keep free ids for 100s */
+struct pool tdb_pool;
+
/* Protected by the NET_LOCK(). */
u_int32_t ipsec_ids_next_flow = 1; /* may not be zero */
struct ipsec_ids_tree ipsec_ids_tree;
@@ -796,10 +799,16 @@ struct tdb *
tdb_alloc(u_int rdomain)
{
struct tdb *tdbp;
+ static int initialized = 0;
NET_ASSERT_LOCKED();
- tdbp = malloc(sizeof(*tdbp), M_TDB, M_WAITOK | M_ZERO);
+ 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);
@@ -879,7 +888,7 @@ tdb_reaper(void *xtdbp)
{
struct tdb *tdbp = xtdbp;
- free(tdbp, M_TDB, 0);
+ pool_put(&tdb_pool, tdbp);
}
/*