Skip to contentSkip to conversation

netfilter: avoid additional compare.

PATCH Applied Changli Gao 2 participants 2 messages Nov 5, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: avoid additional compare.

avoid additional compare.

avoid additional compare.

----

 net/netfilter/nf_conntrack_core.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
net/netfilter/nf_conntrack_core.c +10 -4
index ca6e68d..b917d6a 100644
@@ -512,11 +512,17 @@ static noinline int early_drop(struct net *net, unsigned int hash)
 			cnt++;
 		}
 
-		if (ct && unlikely(nf_ct_is_dying(ct) ||
-				   !atomic_inc_not_zero(&ct->ct_general.use)))
-			ct = NULL;
-		if (ct || cnt >= NF_CT_EVICTION_RANGE)
+		if (ct != NULL) {
+			if (likely(!nf_ct_is_dying(ct) &&
+				   atomic_inc_not_zero(&ct->ct_general.use)))
+				break;
+			else
+				ct = NULL;
+		}
+
+		if (cnt >= NF_CT_EVICTION_RANGE)
 			break;
+
 		hash = (hash + 1) % nf_conntrack_htable_size;
 	}
 	rcu_read_unlock();
#1 lore raw
Quoted 1 line · Changli Gao

avoid additional compare.

Applied, thanks.