summaryrefslogtreecommitdiff
path: root/sys/net/pfkeyv2.c
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-26 18:56:32 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-26 18:56:32 +0000
commitf0fe9f395caae06c5f4ca2fe8b5534d6bd97fcb4 (patch)
tree09e7fcacc40abb00df4c0ef8b460dbc027df2eab /sys/net/pfkeyv2.c
parentbad460060180064bc08a00c589581bf5f43ebfa8 (diff)
Use pool(9) for IPsec policy structures.
Diffstat (limited to 'sys/net/pfkeyv2.c')
-rw-r--r--sys/net/pfkeyv2.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c
index a628e7ee10a..cb37ee43350 100644
--- a/sys/net/pfkeyv2.c
+++ b/sys/net/pfkeyv2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkeyv2.c,v 1.69 2001/06/26 18:34:41 angelos Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.70 2001/06/26 18:56:31 angelos Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
@@ -112,6 +112,8 @@ static struct sadb_alg aalgs[] =
extern uint32_t sadb_exts_allowed_out[SADB_MAX+1];
extern uint32_t sadb_exts_required_out[SADB_MAX+1];
+extern struct pool ipsec_policy_pool;
+
/*
* Wrapper around m_devget(); copy data from contiguous buffer to mbuf
* chain.
@@ -1494,9 +1496,16 @@ pfkeyv2_send(struct socket *socket, void *message, int len)
if (!exists)
{
+ if (ipsec_policy_pool_initialized == 0)
+ {
+ ipsec_policy_pool_initialized = 1;
+ pool_init(&ipsec_policy_pool, sizeof(struct ipsec_policy),
+ 0, 0, PR_FREEHEADER, "ipsec policy", 0, NULL,
+ NULL, M_IPSEC_POLICY);
+ }
+
/* Allocate policy entry */
- MALLOC(ipo, struct ipsec_policy *, sizeof(struct ipsec_policy),
- M_IPSEC_POLICY, M_NOWAIT);
+ ipo = pool_get(&ipsec_policy_pool, 0);
if (ipo == NULL)
{
splx(s);
@@ -1547,7 +1556,7 @@ pfkeyv2_send(struct socket *socket, void *message, int len)
default:
if (!exists)
- FREE(ipo, M_IPSEC_POLICY);
+ pool_put(&ipsec_policy_pool, ipo);
else
ipsec_delete_policy(ipo);
@@ -1607,7 +1616,7 @@ pfkeyv2_send(struct socket *socket, void *message, int len)
if (exists)
ipsec_delete_policy(ipo);
else
- FREE(ipo, M_IPSEC_POLICY);
+ pool_put(&ipsec_policy_pool, ipo);
splx(s);
rval = ENOBUFS;
goto ret;
@@ -1636,7 +1645,7 @@ pfkeyv2_send(struct socket *socket, void *message, int len)
{
if (ipo->ipo_dstid)
ipsp_reffree(ipo->ipo_dstid);
- FREE(ipo, M_IPSEC_POLICY);
+ pool_put(&ipsec_policy_pool, ipo);
}
splx(s);
@@ -1666,7 +1675,7 @@ pfkeyv2_send(struct socket *socket, void *message, int len)
ipsp_reffree(ipo->ipo_srcid);
if (ipo->ipo_dstid)
ipsp_reffree(ipo->ipo_dstid);
- FREE(ipo, M_IPSEC_POLICY); /* Free policy entry */
+ pool_put(&ipsec_policy_pool, ipo);
splx(s);
goto ret;