简体   繁体   English

为什么在找到nf_conn之后内核函数:get_next_corpse增加计数器?

[英]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.

相关问题 nf_ct_get(skb,&ctinfo)函数获取IPv6 udp数据包的netfiter conntrack&#39;struct conn&#39; - nf_ct_get(skb,&ctinfo) function to fetch netfiter conntrack 'struct conn' of IPv6 udp packet nf_hook-内核在TCP / IP的哪一层工作? - At which layer of TCP/IP does nf_hook - kernel works? 为什么在POST方法请求后服务器响应GET? - Why does Server response with GET after POST method request? pcap_next()函数应该放在数据包传输之前还是之后? - pcap_next() function should be put before the packet transmission or after? 客户端中 net.conn 读取尝试的程序空白。 不显示和错误它只是变成空白并停止工作 - program blanks at net.conn read attempt in client. Does not show and error it just goes blank and stops working 是否可以在Netfilter的NF_IP_POST_ROUTING步骤之后挂接数据包? - Is it possible to hook a packet after NF_IP_POST_ROUTING step of Netfilter? 如何使用TrafficStats类在Android中获取Wifi数据计数器 - How to get Wifi data counter in Android using TrafficStats class linux内核如何处理乱序的tcp段? - how does linux kernel process out-of-order tcp segment? 为什么套接字连接被阻止并且TCP内核不断重传[ACK]数据包 - Why Socket Connection Blocked and TCP Kernel Keeps Retransmitting [ACK] packets 更改线路的数据速率是否会增加吞吐量? - Does changing the data rate of a line increase throughput?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM