mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
New hash functions according to benchmarks posted yesterday. (The IPv6
version has not been benchmarked yet due to insufficient test data.) Now ipa_hash() returns a uniformely distributed 16-bit value.
This commit is contained in:
@@ -61,10 +61,12 @@ typedef u32 ip_addr;
|
||||
int ipv4_classify(u32);
|
||||
u32 ipv4_class_mask(u32);
|
||||
|
||||
/* FIXME: Is this hash function uniformly distributed over standard routing tables? */
|
||||
static inline unsigned ipv4_hash(u32 a)
|
||||
{
|
||||
return a ^ (a >> 16) ^ (a >> 24);
|
||||
/* Returns a 16-bit value */
|
||||
a ^= a >> 16;
|
||||
a ^= a << 10;
|
||||
return a & 0xffff;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user