summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2021-02-24 23:44:04 +0000
committerdlg <dlg@openbsd.org>2021-02-24 23:44:04 +0000
commita9e44c50d77196db35f047796469e2d1990950f4 (patch)
treeefe9120ccde5998eaf17a5abdd0b31a1112bd488 /sys/net
parentsync (diff)
downloadwireguard-openbsd-a9e44c50d77196db35f047796469e2d1990950f4.tar.xz
wireguard-openbsd-a9e44c50d77196db35f047796469e2d1990950f4.zip
add support for hashing 64 and 32 bit numbers in host byte order.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/toeplitz.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/net/toeplitz.h b/sys/net/toeplitz.h
index 0fbc8a23eed..3f30fd4b739 100644
--- a/sys/net/toeplitz.h
+++ b/sys/net/toeplitz.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: toeplitz.h,v 1.7 2021/02/24 12:33:50 dlg Exp $ */
+/* $OpenBSD: toeplitz.h,v 1.8 2021/02/24 23:44:04 dlg Exp $ */
/*
* Copyright (c) 2019 David Gwynne <dlg@openbsd.org>
@@ -91,6 +91,18 @@ stoeplitz_hash_h16(const struct stoeplitz_cache *scache, uint16_t h16)
#endif
}
+static __unused inline uint16_t
+stoeplitz_hash_h32(const struct stoeplitz_cache *scache, uint64_t h32)
+{
+ return (stoeplitz_hash_h16(scache, h32 & (h32 >> 16)));
+}
+
+static __unused inline uint16_t
+stoeplitz_hash_h64(const struct stoeplitz_cache *scache, uint64_t h64)
+{
+ return (stoeplitz_hash_h32(scache, h64 ^ (h64 >> 32)));
+}
+
/*
* system provided symmetric toeplitz
*/
@@ -108,6 +120,10 @@ extern const struct stoeplitz_cache *const stoeplitz_cache;
stoeplitz_hash_n16(stoeplitz_cache, (_n16))
#define stoeplitz_h16(_h16) \
stoeplitz_hash_h16(stoeplitz_cache, (_h16))
+#define stoeplitz_h32(_h32) \
+ stoeplitz_hash_h32(stoeplitz_cache, (_h32))
+#define stoeplitz_h64(_h64) \
+ stoeplitz_hash_h64(stoeplitz_cache, (_h64))
#define stoeplitz_port(_p) stoeplitz_n16((_p))
#define stoeplitz_ip4(_sa4, _da4) \
stoeplitz_hash_ip4(stoeplitz_cache, (_sa4), (_da4))