Index: sys/netinet/tcp_hostcache.c =================================================================== --- sys/netinet/tcp_hostcache.c +++ sys/netinet/tcp_hostcache.c @@ -71,6 +71,7 @@ #include #include +#include #include #include #include @@ -175,16 +176,15 @@ static MALLOC_DEFINE(M_HOSTCACHE, "hostcache", "TCP hostcache"); +/* Use jenkins_hash32(), as in other parts of the tcp stack */ +#define HOSTCACHE_HASHSALT 0xb0afb0af; #define HOSTCACHE_HASH(ip) \ - (((ip)->s_addr ^ ((ip)->s_addr >> 7) ^ ((ip)->s_addr >> 17)) & \ - V_tcp_hostcache.hashmask) + (jenkins_hash32((uint32_t *)(ip), 1, HOSTCACHE_HASHSALT) & \ + V_tcp_hostcache.hashmask) -/* XXX: What is the recommended hash to get good entropy for IPv6 addresses? */ #define HOSTCACHE_HASH6(ip6) \ - (((ip6)->s6_addr32[0] ^ \ - (ip6)->s6_addr32[1] ^ \ - (ip6)->s6_addr32[2] ^ \ - (ip6)->s6_addr32[3]) & \ + (jenkins_hash32((uint32_t *)&((ip6)->s6_addr32[0]), 4, \ + HOSTCACHE_HASHSALT) & \ V_tcp_hostcache.hashmask) #define THC_LOCK(lp) mtx_lock(lp)