[英]Why does the kernel function:get_next_corpse increase counter after a nf_conn is found?
I am reading the kernel source code and try to understand the mechanism of ip conntrack. 我正在阅读内核源代码,并尝试了解ip conntrack的机制。 How to understand the function get_next_corpse that increases counter of the nf_conn struct that is found to be cleaned.
如何理解增加被发现要清除的nf_conn结构的计数器的函数get_next_corpse。
static struct nf_conn *
get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data),
void *data, unsigned int *bucket)
{
struct nf_conntrack_tuple_hash *h;
struct nf_conn *ct;
struct hlist_nulls_node *n;
spin_lock_bh(&nf_conntrack_lock);
for (; *bucket < nf_conntrack_htable_size; (*bucket)++) {
hlist_nulls_for_each_entry(h, n, &net->ct.hash[*bucket], hnnode) {
ct = nf_ct_tuplehash_to_ctrack(h);
if (iter(ct, data))
goto found;
}
}
hlist_nulls_for_each_entry(h, n, &net->ct.unconfirmed, hnnode) {
ct = nf_ct_tuplehash_to_ctrack(h);
if (iter(ct, data))
set_bit(IPS_DYING_BIT, &ct->status);
}
spin_unlock_bh(&nf_conntrack_lock);
return NULL;
found:
atomic_inc(&ct->ct_general.use); //Why ??!
spin_unlock_bh(&nf_conntrack_lock);
return ct;
}
As the ct is found to be cleaned, why need atomic_inc(&ct->ct_general.use)? 由于发现ct已被清除,为什么需要atomic_inc(&ct-> ct_general.use)?
Just for keep consistency for that conntrack for concurrency/preemption. 只是为了保持并发性/抢占性的一致性。
Like the P/V operation introduced by OS textbook. 类似于OS教科书介绍的P / V操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.