* [PATCH net-next] netfilter: nf_conntrack: remove the unneed check for *bucket
@ 2016-01-30 12:25 Weidong Wang
2016-01-30 21:30 ` Florian Westphal
0 siblings, 1 reply; 4+ messages in thread
From: Weidong Wang @ 2016-01-30 12:25 UTC (permalink / raw)
To: pablo, kaber, kadlec, David Miller
Cc: netfilter-devel, coreteam, netdev, linux-kernel
In the 'for(...) {}', the *bucket alwasy < net->ct.htable_size,
so remove the check
Signed-off-by: Weidong Wang <wangweidong1@huawei.com>
---
net/netfilter/nf_conntrack_core.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 3cb3cb8..cd7d5c8 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1383,14 +1383,12 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data),
lockp = &nf_conntrack_locks[*bucket % CONNTRACK_LOCKS];
local_bh_disable();
spin_lock(lockp);
- if (*bucket < net->ct.htable_size) {
- hlist_nulls_for_each_entry(h, n, &net->ct.hash[*bucket], hnnode) {
- if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL)
- continue;
- ct = nf_ct_tuplehash_to_ctrack(h);
- if (iter(ct, data))
- goto found;
- }
+ hlist_nulls_for_each_entry(h, n, &net->ct.hash[*bucket], hnnode) {
+ if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL)
+ continue;
+ ct = nf_ct_tuplehash_to_ctrack(h);
+ if (iter(ct, data))
+ goto found;
}
spin_unlock(lockp);
local_bh_enable();
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] netfilter: nf_conntrack: remove the unneed check for *bucket
2016-01-30 12:25 [PATCH net-next] netfilter: nf_conntrack: remove the unneed check for *bucket Weidong Wang
@ 2016-01-30 21:30 ` Florian Westphal
2016-01-31 3:37 ` Weidong Wang
2016-02-01 16:39 ` David Laight
0 siblings, 2 replies; 4+ messages in thread
From: Florian Westphal @ 2016-01-30 21:30 UTC (permalink / raw)
To: Weidong Wang
Cc: pablo, kaber, kadlec, David Miller, netfilter-devel, coreteam,
netdev, linux-kernel
Weidong Wang <wangweidong1@huawei.com> wrote:
> In the 'for(...) {}', the *bucket alwasy < net->ct.htable_size,
> so remove the check
> @@ -1383,14 +1383,12 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data),
> lockp = &nf_conntrack_locks[*bucket % CONNTRACK_LOCKS];
> local_bh_disable();
> spin_lock(lockp);
> - if (*bucket < net->ct.htable_size) {
AFAIU net->ct.htable_size can shrink between for-test and aquiring
the bucket lockp, so this additional if-test is needed.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] netfilter: nf_conntrack: remove the unneed check for *bucket
2016-01-30 21:30 ` Florian Westphal
@ 2016-01-31 3:37 ` Weidong Wang
2016-02-01 16:39 ` David Laight
1 sibling, 0 replies; 4+ messages in thread
From: Weidong Wang @ 2016-01-31 3:37 UTC (permalink / raw)
To: Florian Westphal
Cc: pablo, kaber, kadlec, David Miller, netfilter-devel, coreteam,
netdev, linux-kernel
On 2016/1/31 5:30, Florian Westphal wrote:
> Weidong Wang <wangweidong1@huawei.com> wrote:
>> In the 'for(...) {}', the *bucket alwasy < net->ct.htable_size,
>> so remove the check
>> @@ -1383,14 +1383,12 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data),
>> lockp = &nf_conntrack_locks[*bucket % CONNTRACK_LOCKS];
>> local_bh_disable();
>> spin_lock(lockp);
>> - if (*bucket < net->ct.htable_size) {
>
> AFAIU net->ct.htable_size can shrink between for-test and aquiring
> the bucket lockp, so this additional if-test is needed.
>
ok, Got it.
So ignore this patch.
Regards,
Weidong
> .
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH net-next] netfilter: nf_conntrack: remove the unneed check for *bucket
2016-01-30 21:30 ` Florian Westphal
2016-01-31 3:37 ` Weidong Wang
@ 2016-02-01 16:39 ` David Laight
1 sibling, 0 replies; 4+ messages in thread
From: David Laight @ 2016-02-01 16:39 UTC (permalink / raw)
To: 'Florian Westphal', Weidong Wang
Cc: pablo, kaber, kadlec, David Miller, netfilter-devel, coreteam,
netdev, linux-kernel
From: Florian Westphal
> Sent: 30 January 2016 21:30
> Weidong Wang <wangweidong1@huawei.com> wrote:
> > In the 'for(...) {}', the *bucket alwasy < net->ct.htable_size,
> > so remove the check
> > @@ -1383,14 +1383,12 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data),
> > lockp = &nf_conntrack_locks[*bucket % CONNTRACK_LOCKS];
> > local_bh_disable();
> > spin_lock(lockp);
> > - if (*bucket < net->ct.htable_size) {
>
> AFAIU net->ct.htable_size can shrink between for-test and aquiring
> the bucket lockp, so this additional if-test is needed.
If the table can shrink, can it not also grow - in which case
the references bucket will be incorrect?
David
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-01 16:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-30 12:25 [PATCH net-next] netfilter: nf_conntrack: remove the unneed check for *bucket Weidong Wang
2016-01-30 21:30 ` Florian Westphal
2016-01-31 3:37 ` Weidong Wang
2016-02-01 16:39 ` David Laight
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).