netfilter:get_next_corpse():No need to double check the *bucket
Subsystems (3)
PATCH 1/1 netfilter:get_next_corpse():No need to double check the *bucket
From: Hongbin Wang <[email protected]>
The *bucket is in for loops,it has been checked.
Signed-off-by Hongbin Wang <[email protected]>
--- net/netfilter/nf_conntrack_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
net/netfilter/nf_conntrack_core.c +6 -8
@@ -2000,14 +2000,12 @@ get_next_corpse(int (*iter)(struct nf_conn *i, void *data), lockp = &nf_conntrack_locks[*bucket %CONNTRACK_LOCKS ];local_bh_disable ();nf_conntrack_lock (lockp); -if (*bucket < nf_conntrack_htable_size) { -hlist_nulls_for_each_entry (h, n, &nf_conntrack_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, &nf_conntrack_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.17.1
Florian Westphal
maintainerQuoted 16 lines · [email protected] <[email protected]> wrote:
From: Hongbin Wang <[email protected]>
The *bucket is in for loops,it has been checked.
Signed-off-by Hongbin Wang <[email protected]>--- net/netfilter/nf_conntrack_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)net/netfilter/nf_conntrack_core.c +0
-0@@ -2000,14 +2000,12 @@ get_next_corpse(int (*iter)(struct nf_conn *i, void *data), lockp = &nf_conntrack_locks[*bucket %CONNTRACK_LOCKS ];local_bh_disable ();
net/netfilter/nf_conntrack_core.c get_next_corpse(int (*iter)(struct nf_conn *i, void *data), · line 2003
Quoted 10 lines
net/netfilter/nf_conntrack_core.c +1
-8nf_conntrack_lock (lockp); -if (*bucket < nf_conntrack_htable_size) { -hlist_nulls_for_each_entry (h, n, &nf_conntrack_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, &nf_conntrack_hash[*bucket], hnnode) {
I don't think this is correct.
unless we hold nf_conntrack_lock() nf_conntrack_hash[] could be reallocated, no?