pfkey_flush().
ok bluhm@ mvs@
-/* $OpenBSD: pfkeyv2.c,v 1.225 2021/12/01 22:34:31 bluhm Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.226 2021/12/03 19:04:49 tobhe Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
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)) {
- /* keep in sync with tdb_delete() */
- NET_ASSERT_LOCKED();
-
- if (tdb->tdb_flags & TDBF_DELETED)
- return (0);
- tdb->tdb_flags |= TDBF_DELETED;
- tdb_unlink_locked(tdb);
- tdb_unbundle(tdb);
- tdb_deltimeouts(tdb);
- tdb_unref(tdb);
- }
+ tdb->tdb_satype == *((u_int8_t *) satype_vp))
+ tdb_delete_locked(tdb);
return (0);
}
-/* $OpenBSD: ip_ipsp.c,v 1.260 2021/12/02 12:39:15 bluhm Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.261 2021/12/03 19:04:49 tobhe Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
void tdb_soft_timeout(void *);
void tdb_soft_firstuse(void *);
int tdb_hash(u_int32_t, union sockaddr_union *, u_int8_t);
+void tdb_dodelete(struct tdb *, int locked);
int ipsec_in_use = 0;
u_int64_t ipsec_last_added = 0;
void
tdb_delete(struct tdb *tdbp)
{
- /* keep in sync with pfkeyv2_sa_flush() */
+ tdb_dodelete(tdbp, 0);
+}
+
+void
+tdb_delete_locked(struct tdb *tdbp)
+{
+ MUTEX_ASSERT_LOCKED(&tdb_sadb_mtx);
+ tdb_dodelete(tdbp, 1);
+}
+
+void
+tdb_dodelete(struct tdb *tdbp, int locked)
+{
NET_ASSERT_LOCKED();
if (tdbp->tdb_flags & TDBF_DELETED)
return;
tdbp->tdb_flags |= TDBF_DELETED;
- tdb_unlink(tdbp);
+ if (locked)
+ tdb_unlink_locked(tdbp);
+ else
+ tdb_unlink(tdbp);
+
/* release tdb_onext/tdb_inext references */
tdb_unbundle(tdbp);
/* delete timeouts and release references */
-/* $OpenBSD: ip_ipsp.h,v 1.226 2021/12/01 22:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_ipsp.h,v 1.227 2021/12/03 19:04:49 tobhe Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
void puttdb(struct tdb *);
void puttdb_locked(struct tdb *);
void tdb_delete(struct tdb *);
+void tdb_delete_locked(struct tdb *);
struct tdb *tdb_alloc(u_int);
struct tdb *tdb_ref(struct tdb *);
void tdb_unref(struct tdb *);