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
@@ -42,12 +42,8 @@ static inline uint32_t batadv_choose_claim(const void *data, uint32_t size)
|
||||
struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data;
|
||||
uint32_t hash = 0;
|
||||
|
||||
hash = batadv_hash_bytes(hash, &claim->addr, sizeof(claim->addr));
|
||||
hash = batadv_hash_bytes(hash, &claim->vid, sizeof(claim->vid));
|
||||
|
||||
hash += (hash << 3);
|
||||
hash ^= (hash >> 11);
|
||||
hash += (hash << 15);
|
||||
hash = jhash(&claim->addr, sizeof(claim->addr), hash);
|
||||
hash = jhash(&claim->vid, sizeof(claim->vid), hash);
|
||||
|
||||
return hash % size;
|
||||
}
|
||||
@@ -59,12 +55,8 @@ static inline uint32_t batadv_choose_backbone_gw(const void *data,
|
||||
const struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data;
|
||||
uint32_t hash = 0;
|
||||
|
||||
hash = batadv_hash_bytes(hash, &claim->addr, sizeof(claim->addr));
|
||||
hash = batadv_hash_bytes(hash, &claim->vid, sizeof(claim->vid));
|
||||
|
||||
hash += (hash << 3);
|
||||
hash ^= (hash >> 11);
|
||||
hash += (hash << 15);
|
||||
hash = jhash(&claim->addr, sizeof(claim->addr), hash);
|
||||
hash = jhash(&claim->vid, sizeof(claim->vid), hash);
|
||||
|
||||
return hash % size;
|
||||
}
|
||||
|
Reference in New Issue
Block a user