aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2018-07-26 01:56:45 +0200
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>2018-07-26 01:58:40 +0200
commit25d757f8a0f0c832defd0bc4dc555a230f281fd3 (patch)
treeae03656bc84647ca479894aefd4f1ff740aca376 /include
parentLinux 4.18-rc6 (diff)
downloadlinux-dev-25d757f8a0f0c832defd0bc4dc555a230f281fd3.tar.xz
linux-dev-25d757f8a0f0c832defd0bc4dc555a230f281fd3.zip
rhashtable: Change the seed to 128 bits
The SipHash algorithm relies on a 128-bit hash seed. In order to use SipHash with rhashtable, change the seed used in rhashtable to 128 bits. Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/rhashtable.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index 4e1f535c2034..063e7fa7e9ca 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -73,6 +73,10 @@ struct rhlist_head {
struct rhlist_head __rcu *next;
};
+struct rhash_rnd {
+ u64 data[2];
+};
+
/**
* struct bucket_table - Table of hash buckets
* @size: Number of hash buckets
@@ -91,7 +95,7 @@ struct bucket_table {
unsigned int size;
unsigned int nest;
unsigned int rehash;
- u32 hash_rnd;
+ struct rhash_rnd hash_rnd;
unsigned int locks_mask;
spinlock_t *locks;
struct list_head walkers;
@@ -112,11 +116,14 @@ struct rhashtable_compare_arg {
const void *key;
};
-typedef u32 (*rht_hashfn_t)(const void *data, u32 len, u32 seed);
-typedef u32 (*rht_obj_hashfn_t)(const void *data, u32 len, u32 seed);
+typedef u32 (*rht_hashfn_t)(const void *data, u32 len, struct rhash_rnd seed);
+typedef u32 (*rht_obj_hashfn_t)(const void *data, u32 len, struct rhash_rnd seed);
typedef int (*rht_obj_cmpfn_t)(struct rhashtable_compare_arg *arg,
const void *obj);
+u32 rhashtable_jhash(const void *key, u32 length, struct rhash_rnd seed);
+u32 rhashtable_jhash2(const void *key, u32 length, struct rhash_rnd seed);
+
struct rhashtable;
/**
@@ -242,7 +249,7 @@ static inline unsigned int rht_bucket_index(const struct bucket_table *tbl,
static inline unsigned int rht_key_get_hash(struct rhashtable *ht,
const void *key, const struct rhashtable_params params,
- unsigned int hash_rnd)
+ struct rhash_rnd hash_rnd)
{
unsigned int hash;
@@ -255,16 +262,16 @@ static inline unsigned int rht_key_get_hash(struct rhashtable *ht,
if (params.hashfn)
hash = params.hashfn(key, key_len, hash_rnd);
else if (key_len & (sizeof(u32) - 1))
- hash = jhash(key, key_len, hash_rnd);
+ hash = jhash(key, key_len, hash_rnd.data[0]);
else
- hash = jhash2(key, key_len / sizeof(u32), hash_rnd);
+ hash = jhash2(key, key_len / sizeof(u32), hash_rnd.data[0]);
} else {
unsigned int key_len = ht->p.key_len;
if (params.hashfn)
hash = params.hashfn(key, key_len, hash_rnd);
else
- hash = jhash(key, key_len, hash_rnd);
+ hash = jhash(key, key_len, hash_rnd.data[0]);
}
return hash;