netfilter: conntrack: don't attempt to iterate over empty table
authorFlorian Westphal <fw@strlen.de>
Thu, 28 Apr 2016 17:13:42 +0000 (19:13 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 5 May 2016 14:39:44 +0000 (16:39 +0200)
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>
net/netfilter/nf_conntrack_core.c

index 29fa08b3ab8292b9b24259afab90d814d7bfce10..f2e75a54408b4f2d2fcd84995c64864d3f0a291d 100644 (file)
@@ -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))
This page took 0.097863 seconds and 5 git commands to generate.