summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2022-03-08 22:30:39 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2022-03-08 22:30:39 +0000
commit92c1ff9981daef2a2466f2d57464a575c4cfceec (patch)
tree231dd39ae4d011103eb32875be7250f76556b9c8
parent02da191fa3d6571b8ce2b47a78b0bdad3c4439b9 (diff)
In IPsec policy replace integer refcount with atomic refcount.
OK tobhe@ mvs@
-rw-r--r--sys/net/pfkeyv2.c4
-rw-r--r--sys/netinet/ip_ipsp.h4
-rw-r--r--sys/netinet/ip_spd.c7
3 files changed, 7 insertions, 8 deletions
diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c
index f89f1449f1f..e578b67b942 100644
--- a/sys/net/pfkeyv2.c
+++ b/sys/net/pfkeyv2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkeyv2.c,v 1.231 2022/02/25 23:51:03 guenther Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.232 2022/03/08 22:30:38 bluhm Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
@@ -1996,7 +1996,7 @@ pfkeyv2_send(struct socket *so, void *message, int len)
TAILQ_INIT(&ipo->ipo_acquires);
ipo->ipo_rdomain = rdomain;
- ipo->ipo_ref_count = 1;
+ refcnt_init(&ipo->ipo_refcnt);
/* Add SPD entry */
if ((rnh = spd_table_get(rdomain)) == NULL ||
diff --git a/sys/netinet/ip_ipsp.h b/sys/netinet/ip_ipsp.h
index 3b9c82691d5..4610727bf04 100644
--- a/sys/netinet/ip_ipsp.h
+++ b/sys/netinet/ip_ipsp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.h,v 1.235 2022/03/02 20:16:43 bluhm Exp $ */
+/* $OpenBSD: ip_ipsp.h,v 1.236 2022/03/08 22:30:38 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -281,7 +281,7 @@ struct ipsec_policy {
u_int8_t ipo_sproto; /* ESP/AH; if zero, use system dflts */
u_int ipo_rdomain;
- int ipo_ref_count;
+ struct refcnt ipo_refcnt;
struct tdb *ipo_tdb; /* [p] Cached TDB entry */
diff --git a/sys/netinet/ip_spd.c b/sys/netinet/ip_spd.c
index 4f5b4f24dcc..a3eddb19b5d 100644
--- a/sys/netinet/ip_spd.c
+++ b/sys/netinet/ip_spd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_spd.c,v 1.113 2022/03/06 15:24:50 bluhm Exp $ */
+/* $OpenBSD: ip_spd.c,v 1.114 2022/03/08 22:30:38 bluhm Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -666,11 +666,10 @@ ipsec_delete_policy(struct ipsec_policy *ipo)
struct ipsec_acquire *ipa;
struct radix_node_head *rnh;
struct radix_node *rn = (struct radix_node *)ipo;
- int err = 0;
NET_ASSERT_LOCKED();
- if (--ipo->ipo_ref_count > 0)
+ if (refcnt_rele(&ipo->ipo_refcnt) == 0)
return 0;
/* Delete from SPD. */
@@ -699,7 +698,7 @@ ipsec_delete_policy(struct ipsec_policy *ipo)
pool_put(&ipsec_policy_pool, ipo);
- return err;
+ return 0;
}
void