aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2018-08-02 18:54:03 +0200
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>2018-08-02 22:00:57 +0200
commit6f450b7f8f722dec835fe96ff5b99be98cd5622e (patch)
treecd3b05ccb6e376cf8c485ac444012471913f18f2
parentrhashtable: Introduce wrapper for SipHash (diff)
downloadlinux-dev-jn/rhashtable-next.tar.xz
linux-dev-jn/rhashtable-next.zip
rhashtable: Introduce wrapper for HalfSipHashjn/rhashtable-next
HalfSipHash was intruduced into the kernel in commit 1ae2324f732c ("siphash: implement HalfSipHash1-3 for hash tables"), and presents a faster and weaker variant of SipHash. In order to make it conveniently usable with rhashtable, add a wrapper that can be used in struct rhashtable_params. Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
-rw-r--r--include/linux/rhashtable.h1
-rw-r--r--lib/rhashtable.c8
2 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index 9ccbdaa9c760..36394ba95dd4 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -81,6 +81,7 @@ struct bucket_table {
u32 rhashtable_jhash(const void *key, u32 length, struct rhash_rnd seed);
u32 rhashtable_jhash2(const void *key, u32 length, struct rhash_rnd seed);
u32 rhashtable_siphash(const void *key, u32 length, struct rhash_rnd seed);
+u32 rhashtable_hsiphash(const void *key, u32 length, struct rhash_rnd seed);
static inline bool rht_is_a_nulls(const struct rhash_head *ptr)
{
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index b826f954c1ab..aa290cac423d 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -986,6 +986,14 @@ u32 rhashtable_siphash(const void *key, u32 length, struct rhash_rnd seed)
}
EXPORT_SYMBOL_GPL(rhashtable_siphash);
+u32 rhashtable_hsiphash(const void *key, u32 length, struct rhash_rnd seed)
+{
+ BUILD_BUG_ON(sizeof(seed) < sizeof(hsiphash_key_t));
+
+ return hsiphash(key, length, (hsiphash_key_t *)&seed);
+}
+EXPORT_SYMBOL_GPL(rhashtable_hsiphash);
+
/**
* rhashtable_init - initialize a new hash table
* @ht: hash table to be initialized