From: "Liping Zhang" <zlpnobody@163.com>
To: "Florian Westphal" <fw@strlen.de>
Cc: pablo@netfilter.org, netfilter-devel@vger.kernel.org,
"Liping Zhang" <liping.zhang@spreadtrum.com>
Subject: Re: [PATCH nf 1/3] netfilter: conntrack: fix race between nf_conntrack proc read and hash resize
Date: Sun, 3 Jul 2016 10:22:10 +0800 (CST) [thread overview]
Message-ID: <3d7eb75e.22de.155ae9025a4.Coremail.zlpnobody@163.com> (raw)
In-Reply-To: <20160702174612.GD24701@breakpoint.cc>
>Good catch, but ...
>
>> diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
>> index 3e2f332..4f6453a 100644
>> --- a/include/net/netfilter/nf_conntrack_core.h
>> +++ b/include/net/netfilter/nf_conntrack_core.h
>> @@ -82,6 +82,7 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
>> #define CONNTRACK_LOCKS 1024
>>
>> extern struct hlist_nulls_head *nf_conntrack_hash;
>> +extern seqcount_t nf_conntrack_generation;
>
>instead of this and the proliferation of this:
>
>> + do {
>> + sequence = read_seqcount_begin(&nf_conntrack_generation);
>> + st->htable_size = nf_conntrack_htable_size;
>> + st->hash = nf_conntrack_hash;
>> + } while (read_seqcount_retry(&nf_conntrack_generation, sequence));
>> +
>> return ct_get_idx(seq, *pos);
>> }
>
>I think it might be better to do something like
>
>/* must be called with rcu read lock held */
>unsigned int nf_conntrack_get_ht(struct hlist_nulls_head *h,
> unsigned int *buckets)
>{
> do {
> s = read_seq ...
> size = nf_conntrack_htable_size;
> ptr = nf_conntrack_hash;
> } while ...
>
> *h = ptr;
> *buckets = size;
>
> return s;
Agree.
And I also find there's no need to use nf_conntrack_generation in my patch #2 and #3.
Will send V2 later.
Thanks
next prev parent reply other threads:[~2016-07-03 2:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-02 10:59 [PATCH nf 0/3] netfilter: conntrack: fix race condition associated with hash resize Liping Zhang
2016-07-02 10:59 ` [PATCH nf 1/3] netfilter: conntrack: fix race between nf_conntrack proc read and " Liping Zhang
2016-07-02 17:46 ` Florian Westphal
2016-07-03 2:22 ` Liping Zhang [this message]
2016-07-02 10:59 ` [PATCH nf 2/3] netfilter: cttimeout: unlink timeout obj again when hash resize happen Liping Zhang
2016-07-02 10:59 ` [PATCH nf 3/3] netfilter: nf_ct_helper: unlink helper " Liping Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3d7eb75e.22de.155ae9025a4.Coremail.zlpnobody@163.com \
--to=zlpnobody@163.com \
--cc=fw@strlen.de \
--cc=liping.zhang@spreadtrum.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).