From: patrick Date: Mon, 26 Jun 2017 09:08:00 +0000 (+0000) Subject: Split a part of tdb_delete() into tdb_unlink() so that we can remove X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1d4391f6136e775a788325c3ce7d2b4715160921;p=openbsd Split a part of tdb_delete() into tdb_unlink() so that we can remove a TDB from the hash table without actually free()ing it. That way we can modify the TDB and then put it back in using puttdb(). ok claudio@ --- diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c index 39daa184c51..085557cf2bd 100644 --- a/sys/netinet/ip_ipsp.c +++ b/sys/netinet/ip_ipsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipsp.c,v 1.224 2017/05/18 10:56:45 bluhm Exp $ */ +/* $OpenBSD: ip_ipsp.c,v 1.225 2017/06/26 09:08:00 patrick Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr), @@ -714,7 +714,7 @@ puttdb(struct tdb *tdbp) } void -tdb_delete(struct tdb *tdbp) +tdb_unlink(struct tdb *tdbp) { struct tdb *tdbpp; u_int32_t hashval; @@ -775,10 +775,18 @@ tdb_delete(struct tdb *tdbp) } tdbp->tdb_snext = NULL; - tdb_free(tdbp); tdb_count--; } +void +tdb_delete(struct tdb *tdbp) +{ + NET_ASSERT_LOCKED(); + + tdb_unlink(tdbp); + tdb_free(tdbp); +} + /* * Allocate a TDB and initialize a few basic fields. */ diff --git a/sys/netinet/ip_ipsp.h b/sys/netinet/ip_ipsp.h index 43bf0f8b66a..df145de2b64 100644 --- a/sys/netinet/ip_ipsp.h +++ b/sys/netinet/ip_ipsp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipsp.h,v 1.182 2017/05/22 22:23:11 bluhm Exp $ */ +/* $OpenBSD: ip_ipsp.h,v 1.183 2017/06/26 09:08:00 patrick Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr), @@ -468,6 +468,7 @@ void tdb_delete(struct tdb *); 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 *); int tdb_walk(u_int, int (*)(struct tdb *, void *, int), void *); /* XF_IP4 */