summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_ipsp.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2004-01-27 09:29:23 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2004-01-27 09:29:23 +0000
commit0f8e79ca2928e831d9efe02766a0584846a3cc49 (patch)
tree0a2288d71ef9e50b9af269f0e865477368c18ea0 /sys/netinet/ip_ipsp.c
parenta184ccbad77120d0a4ecedb1f1235243f79ef56f (diff)
in gettdbbysrcdst(): hash by SRC and lookup SA in the tdbsrc[] hash table
with hshoexer@
Diffstat (limited to 'sys/netinet/ip_ipsp.c')
-rw-r--r--sys/netinet/ip_ipsp.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c
index e643b6f3d8b..a0992060fae 100644
--- a/sys/netinet/ip_ipsp.c
+++ b/sys/netinet/ip_ipsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.c,v 1.154 2004/01/22 14:38:28 markus Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.155 2004/01/27 09:29:22 markus Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -301,7 +301,9 @@ gettdb(u_int32_t spi, union sockaddr_union *dst, u_int8_t proto)
#ifdef TCP_SIGNATURE
/*
- * Same as gettdb() but compare SRC as well.
+ * Same as gettdb() but compare SRC as well, so we
+ * use the tdbsrc[] hash table. Setting spi to 0
+ * matches all SPIs.
*/
struct tdb *
gettdbbysrcdst(u_int32_t spi, union sockaddr_union *src,
@@ -310,13 +312,13 @@ gettdbbysrcdst(u_int32_t spi, union sockaddr_union *src,
u_int32_t hashval;
struct tdb *tdbp;
- if (tdbh == NULL)
+ if (tdbsrc == NULL)
return (struct tdb *) NULL;
- hashval = tdb_hash(spi, dst, proto);
+ hashval = tdb_hash(0, src, proto);
- for (tdbp = tdbh[hashval]; tdbp != NULL; tdbp = tdbp->tdb_hnext)
- if ((tdbp->tdb_spi == spi) &&
+ for (tdbp = tdbsrc[hashval]; tdbp != NULL; tdbp = tdbp->tdb_snext)
+ if ((spi == 0 || tdbp->tdb_spi == spi) &&
!bcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa)) &&
!bcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa)) &&
(tdbp->tdb_sproto == proto))