Skip to content

Commit

Permalink
netfilter: conntrack: don't attempt to iterate over empty table
Browse files Browse the repository at this point in the history
Once we place all conntracks into same table iteration becomes more
costly because the table contains conntracks that we are not interested
in (belonging to other netns).

So don't bother scanning if the current namespace has no entries.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Florian Westphal authored and Pablo Neira Ayuso committed May 5, 2016
1 parent 5e3c61f commit 88b68bc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/netfilter/nf_conntrack_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,9 @@ void nf_ct_iterate_cleanup(struct net *net,

might_sleep();

if (atomic_read(&net->ct.count) == 0)
return;

while ((ct = get_next_corpse(net, iter, data, &bucket)) != NULL) {
/* Time to push up daises... */
if (del_timer(&ct->timeout))
Expand Down

0 comments on commit 88b68bc

Please sign in to comment.