netfilter: nf_conntrack: remove the unneed check for *bucket
Subsystems (3)
PATCH 1/1 netfilter: nf_conntrack: remove the unneed check for *bucket
In the 'for(...) {}', the *bucket alwasy < net->ct.htable_size, so remove the check
--- net/netfilter/nf_conntrack_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
net/netfilter/nf_conntrack_core.c +6 -8
@@ -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 ();
Signature · 1 line
2.7.0
Florian Westphal
maintainernet/netfilter/nf_conntrack_core.c get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data), · line 1386
Quoted 7 lines · Weidong Wang
In the 'for(...) {}', the *bucket alwasy <
net->ct.htable_size, so remove the checknet/netfilter/nf_conntrack_core.c +0
-1@@ -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.
Quoted 12 lines · Florian Westphal
net/netfilter/nf_conntrack_core.c get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data), · line 1386
Quoted 7 lines · Weidong Wang
In the 'for(...) {}', the *bucket alwasy <
net->ct.htable_size, so remove the checknet/netfilter/nf_conntrack_core.c +0
-1@@ -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_sizecan 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
Quoted 2 lines
.
From: Florian Westphal
Quoted 12 lines
Sent: 30 January 2016 21:30
net/netfilter/nf_conntrack_core.c get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data), · line 1386
Quoted 7 lines · Weidong Wang
In the 'for(...) {}', the *bucket alwasy <
net->ct.htable_size, so remove the checknet/netfilter/nf_conntrack_core.c +0
-1@@ -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_sizecan 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