summaryrefslogtreecommitdiffstats
path: root/lib/ipv4.h
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1998-12-20 14:57:49 +0100
committerMartin Mares <mj@ucw.cz>1998-12-20 14:57:49 +0100
commita6f250f5c6d079badc4a1274b19a21a52de6acec (patch)
tree0a8fde53fead5ee11b88af0156ba2555f7cc6d3e /lib/ipv4.h
parenta05406e69c699c8b6f43bf58f47b8b0385113083 (diff)
downloadbird-a6f250f5c6d079badc4a1274b19a21a52de6acec.tar
bird-a6f250f5c6d079badc4a1274b19a21a52de6acec.zip
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.
Diffstat (limited to 'lib/ipv4.h')
-rw-r--r--lib/ipv4.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/ipv4.h b/lib/ipv4.h
index c37ea80..4ae3e95 100644
--- a/lib/ipv4.h
+++ b/lib/ipv4.h
@@ -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