Kernel version: 2.6.18
/include/linux/jhash.h
Code:
/* A special ultra-optimized versions that knows they are hashing exactlyUsage:
* 3, 2 or 1 word(s).
*
* NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
* done at the end is not done here.
*/
static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
{
a += JHASH_GOLDEN_RATIO;
b += JHASH_GOLDEN_RATIO;
c += initval;
__jhash_mix(a, b, c);
return c;
}
/*
* Returns hash value for IPVS connection entry
*/
static unsigned int ip_vs_conn_hashkey(unsigned proto, __u32 addr, __u16 port)
{
return jhash_3words(addr, port, proto, ip_vs_conn_rnd)
& IP_VS_CONN_TAB_MASK;
}
ip_vs_conn_rnd:
Initialize at ip_vs_conn_init(void).
Randon value of static unsigned int.
IP_VS_CONN_TAB_MASK: (4098)
Defined in ip_vs.h
#define CONFIG_IP_VS_TAB_BITS 12 //default
#define IP_VS_CONN_TAB_BITS CONFIG_IP_VS_TAB_BITS
#define IP_VS_CONN_TAB_SIZE (1 << IP_VS_CONN_TAB_BITS)
#define IP_VS_CONN_TAB_MASK (IP_VS_CONN_TAB_SIZE - 1)
