batman-adv: Use common Jenkins Hash implementation
An unoptimized version of the Jenkins one-at-a-time hash function is used and partially copied all over the code wherever an hashtable is used. Instead the optimized version shared between the whole kernel should be used to reduce code duplication and use better optimized code. Only the DAT code must use the old implementation because it is used as distributed hash function which has to be common for all nodes. Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
This commit is contained in:

committed by
Antonio Quartulli

parent
d691f9e8d4
commit
36fd61cb80
@@ -206,9 +206,22 @@ static uint32_t batadv_hash_dat(const void *data, uint32_t size)
|
||||
{
|
||||
uint32_t hash = 0;
|
||||
const struct batadv_dat_entry *dat = data;
|
||||
const unsigned char *key;
|
||||
uint32_t i;
|
||||
|
||||
hash = batadv_hash_bytes(hash, &dat->ip, sizeof(dat->ip));
|
||||
hash = batadv_hash_bytes(hash, &dat->vid, sizeof(dat->vid));
|
||||
key = (const unsigned char *)&dat->ip;
|
||||
for (i = 0; i < sizeof(dat->ip); i++) {
|
||||
hash += key[i];
|
||||
hash += (hash << 10);
|
||||
hash ^= (hash >> 6);
|
||||
}
|
||||
|
||||
key = (const unsigned char *)&dat->vid;
|
||||
for (i = 0; i < sizeof(dat->vid); i++) {
|
||||
hash += key[i];
|
||||
hash += (hash << 10);
|
||||
hash ^= (hash >> 6);
|
||||
}
|
||||
|
||||
hash += (hash << 3);
|
||||
hash ^= (hash >> 11);
|
||||
|
Reference in New Issue
Block a user