Skip to content

Commit

Permalink
netfilter: nf_conntrack: avoid additional compare.
Browse files Browse the repository at this point in the history
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
  • Loading branch information
Changli Gao authored and Patrick McHardy committed Nov 5, 2009
1 parent 9481721 commit 5ae27aa
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions net/netfilter/nf_conntrack_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5ae27aa

Please sign in to comment.