netfilter: nf_conntrack: avoid additional compare.
authorChangli Gao <xiaosuo@gmail.com>
Thu, 5 Nov 2009 13:51:31 +0000 (14:51 +0100)
committerPatrick McHardy <kaber@trash.net>
Thu, 5 Nov 2009 13:51:31 +0000 (14:51 +0100)
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
net/netfilter/nf_conntrack_core.c

index 7c9ec3d..8e572d7 100644 (file)
@@ -511,11 +511,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();