aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/rhashtable.h1
-rw-r--r--lib/rhashtable.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index 063e7fa7e9ca..262f3186c368 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -123,6 +123,7 @@ typedef int (*rht_obj_cmpfn_t)(struct rhashtable_compare_arg *arg,
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);
struct rhashtable;
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 97ee2a5b77fc..587fd42f3073 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -24,6 +24,7 @@
#include <linux/vmalloc.h>
#include <linux/mm.h>
#include <linux/jhash.h>
+#include <linux/siphash.h>
#include <linux/random.h>
#include <linux/rhashtable.h>
#include <linux/err.h>
@@ -988,6 +989,14 @@ u32 rhashtable_jhash2(const void *key, u32 length, struct rhash_rnd seed)
}
EXPORT_SYMBOL_GPL(rhashtable_jhash2);
+u32 rhashtable_siphash(const void *key, u32 length, struct rhash_rnd seed)
+{
+ BUILD_BUG_ON(sizeof(seed) < sizeof(siphash_key_t));
+
+ return siphash(key, length, (siphash_key_t *)&seed);
+}
+EXPORT_SYMBOL_GPL(rhashtable_siphash);
+
/**
* rhashtable_init - initialize a new hash table
* @ht: hash table to be initialized