2007/03/26

YCLin的ip_vs_cad_hash_init()

ip_vs_cad_hash_init():
用來讀/boot/hot_in檔案,並且vmalloc空間存放讀進來的資料.
location: ip_vs_cad.c
referenced: In function ip_vs_bind_scheduler()


ip_vs_bind_scheduler(struct ip_vs_service *, struct ip_vs_scheduler *):
用來加入新的scheduler. (ex. lard,wrr,wlc...)
location: ip_vs_sched.c
referenced: In function ip_vs_add_service()


ip_vs_add_service(struct ip_vs_rule_user *ur, struct ip_vs_service **svc_p):
用來加入service, 先用ur->sched_name找scheduler,
再用ip_vs_bind_scheduler綁起來...
location: ip_vs_ctl.c
referenced: do_ip_vs_set_ctl()


do_ip_vs_set_ctl(struct sock *sk, int cmd, void *user, unsigned int len):
不明@@.. 待check...
裡面有一堆case:
據說是dispatcher的主函式


TODO: nf_sockopt_ops

jhash

Kernel version: 2.6.18
/include/linux/jhash.h

Code:

/* A special ultra-optimized versions that knows they are hashing exactly
* 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;
}
Usage:
/*
* 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)