Hi,
This fixes a panic mtx locking against myself I have introduced in
my previous commit.
ok?
bluhm
Index: net/pfkeyv2.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/pfkeyv2.c,v
retrieving revision 1.220
diff -u -p -r1.220 pfkeyv2.c
--- net/pfkeyv2.c 22 Oct 2021 12:30:53 -0000 1.220
+++ net/pfkeyv2.c 25 Oct 2021 17:49:21 -0000
@@ -1042,8 +1042,10 @@ int
pfkeyv2_sa_flush(struct tdb *tdb, void *satype_vp, int last)
{
if (!(*((u_int8_t *) satype_vp)) ||
- tdb->tdb_satype == *((u_int8_t *) satype_vp))
- tdb_delete(tdb);
+ tdb->tdb_satype == *((u_int8_t *) satype_vp)) {
+ tdb_unlink_locked(tdb);
+ tdb_free(tdb);
+ }
return (0);
}
Index: netinet/ip_ipsp.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_ipsp.c,v
retrieving revision 1.247
diff -u -p -r1.247 ip_ipsp.c
--- netinet/ip_ipsp.c 25 Oct 2021 16:00:12 -0000 1.247
+++ netinet/ip_ipsp.c 25 Oct 2021 17:50:58 -0000
@@ -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
Index: netinet/ip_ipsp.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_ipsp.h,v
retrieving revision 1.218
diff -u -p -r1.218 ip_ipsp.h
--- netinet/ip_ipsp.h 24 Oct 2021 23:33:37 -0000 1.218
+++ netinet/ip_ipsp.h 25 Oct 2021 17:50:57 -0000
@@ -558,6 +558,7 @@ struct tdb *tdb_alloc(u_int);
void tdb_free(struct tdb *);
int tdb_init(struct tdb *, u_int16_t, struct ipsecinit *);
void tdb_unlink(struct tdb *);
+void tdb_unlink_locked(struct tdb *);
int tdb_walk(u_int, int (*)(struct tdb *, void *, int), void *);
/* XF_IP4 */