summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_ipsp.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2021-10-25 18:25:02 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2021-10-25 18:25:02 +0000
commitef4ace0cd1a164601a905c8cb67cc0e5151d65bb (patch)
tree1e4d5b8979eaa4d7d7b21145934039cb7ff43d5f /sys/netinet/ip_ipsp.c
parent172c70b6e2ece49a483eaf3f9097804f20220ce5 (diff)
Call a locked variant of tdb_unlink() from tdb_walk(). Fixes a
mutex locking against myself panic introduced by my previous commit. OK beck@ patrick@
Diffstat (limited to 'sys/netinet/ip_ipsp.c')
-rw-r--r--sys/netinet/ip_ipsp.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c
index 01dec0abc8f..25801a57df1 100644
--- a/sys/netinet/ip_ipsp.c
+++ b/sys/netinet/ip_ipsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.c,v 1.247 2021/10/25 16:00:12 bluhm Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.248 2021/10/25 18:25:01 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -733,10 +733,19 @@ puttdb(struct tdb *tdbp)
void
tdb_unlink(struct tdb *tdbp)
{
+ mtx_enter(&tdb_sadb_mtx);
+ tdb_unlink_locked(tdbp);
+ mtx_leave(&tdb_sadb_mtx);
+}
+
+void
+tdb_unlink_locked(struct tdb *tdbp)
+{
struct tdb *tdbpp;
u_int32_t hashval;
- mtx_enter(&tdb_sadb_mtx);
+ MUTEX_ASSERT_LOCKED(&tdb_sadb_mtx);
+
hashval = tdb_hash(tdbp->tdb_spi, &tdbp->tdb_dst, tdbp->tdb_sproto);
if (tdbh[hashval] == tdbp) {
@@ -793,7 +802,6 @@ tdb_unlink(struct tdb *tdbp)
ipsecstat_inc(ipsec_prevtunnels);
}
#endif /* IPSEC */
- mtx_leave(&tdb_sadb_mtx);
}
void