-/* $OpenBSD: ip_ipsp.c,v 1.261 2021/12/03 19:04:49 tobhe Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.262 2021/12/07 17:28:46 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
#endif /* IPSEC */
}
+void
+tdb_cleanspd(struct tdb *tdbp)
+{
+ struct ipsec_policy *ipo;
+
+ while ((ipo = TAILQ_FIRST(&tdbp->tdb_policy_head)) != NULL) {
+ TAILQ_REMOVE(&tdbp->tdb_policy_head, ipo, ipo_tdb_next);
+ tdb_unref(ipo->ipo_tdb);
+ ipo->ipo_tdb = NULL;
+ ipo->ipo_last_searched = 0; /* Force a re-search. */
+ }
+}
+
void
tdb_unbundle(struct tdb *tdbp)
{
else
tdb_unlink(tdbp);
+ /* cleanup SPD references */
+ tdb_cleanspd(tdbp);
/* release tdb_onext/tdb_inext references */
tdb_unbundle(tdbp);
/* delete timeouts and release references */
void
tdb_free(struct tdb *tdbp)
{
- struct ipsec_policy *ipo;
-
NET_ASSERT_LOCKED();
if (tdbp->tdb_xform) {
pfsync_delete_tdb(tdbp);
#endif
- /* Cleanup SPD references. */
- while ((ipo = TAILQ_FIRST(&tdbp->tdb_policy_head)) != NULL) {
- TAILQ_REMOVE(&tdbp->tdb_policy_head, ipo, ipo_tdb_next);
- tdb_unref(ipo->ipo_tdb);
- ipo->ipo_tdb = NULL;
- ipo->ipo_last_searched = 0; /* Force a re-search. */
- }
+ KASSERT(TAILQ_EMPTY(&tdbp->tdb_policy_head));
if (tdbp->tdb_ids) {
ipsp_ids_free(tdbp->tdb_ids);
-/* $OpenBSD: ip_ipsp.h,v 1.227 2021/12/03 19:04:49 tobhe Exp $ */
+/* $OpenBSD: ip_ipsp.h,v 1.228 2021/12/07 17:28:46 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
int tdb_init(struct tdb *, u_int16_t, struct ipsecinit *);
void tdb_unlink(struct tdb *);
void tdb_unlink_locked(struct tdb *);
+void tdb_cleanspd(struct tdb *);
void tdb_unbundle(struct tdb *);
void tdb_deltimeouts(struct tdb *);
int tdb_walk(u_int, int (*)(struct tdb *, void *, int), void *);