how to get consistent value of "nf_conntrack_htable_size" and "nf_conntrack_hash" in a kernel module ?

Shiyao Ma i at introo.me
Fri Jul 7 11:55:25 EDT 2017


Hi,

I want to foreach all the `struct nf_conn's in my out-of-tree kernel module.

My plan is to get the `nf_conntrack_htable_size' and `nf_conntrack_hash', then do some read on the hash table.

However, the symbol `nf_conntrack_generation' is not exported, so I cannot do things like this:

struct hlist_nulls_head *hptr;
unsigned int sequence, hsz;

do {
    sequence = read_seqcount_begin(&nf_conntrack_generation);
    hsz = nf_conntrack_htable_size;
    hptr = nf_conntrack_hash;
} while (read_seqcount_retry(&nf_conntrack_generation, sequence));


How to get a consistent value of `nf_conntrack_htable_size' and `nf_conntrack_hash' ?


Thanks.


More information about the Kernelnewbies mailing list