这篇文章记录connection如何处理。
新建一个连接
/*
* Create a new connection entry and hash it into the ip_vs_conn_tab
*/
struct ip_vs_conn *
ip_vs_conn_new(int af, int proto, const union nf_inet_addr *caddr, __be16 cport,
const union nf_inet_addr *vaddr, __be16 vport,
const union nf_inet_addr *daddr, __be16 dport, unsigned flags,
struct ip_vs_dest *dest)
{
struct ip_vs_conn *cp;
struct ip_vs_protocol *pp = ip_vs_proto_get(proto);
cp = kmem_cache_zalloc(ip_vs_conn_cachep, GFP_ATOMIC);
if (cp == NULL) {
IP_VS_ERR_RL("%s(): no memory\n", __func__);
return NULL;
}
INIT_LIST_HEAD(&cp->c_list);
setup_timer(&cp->timer, ip_vs_conn_expire, (unsigned long)cp);
cp->af = af;
cp->protocol = proto;
ip_vs_addr_copy(af, &cp->caddr, caddr);
cp->cport = cport;
ip_vs_addr_copy(af, &cp->vaddr, vaddr);
cp->vport = vport;
/* proto should only be IPPROTO_IP if d_addr is a f

本文深入探讨了IPVS中连接的创建与管理,包括ip_vs_conn_in_get和ip_vs_conn_out_get函数在增加连接引用计数的角色,以及使用ip_vs_conn_put释放连接。此外,还介绍了连接超时的处理,并详细解析了IPVS哈希表的锁机制,如采用读写锁并行化每个bucket,以减少并发时的锁竞争。
最低0.47元/天 解锁文章
3575

被折叠的 条评论
为什么被折叠?



