From: Florian Westphal <fw@strlen.de>
To: Florian Westphal <fw@strlen.de>
Cc: Eric Dumazet <eric.dumazet@gmail.com>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 7/7] netfilter: connlimit: use rbtree for per-host conntrack obj storage
Date: Sun, 9 Mar 2014 22:45:13 +0100 [thread overview]
Message-ID: <20140309214513.GD14012@breakpoint.cc> (raw)
In-Reply-To: <20140309184357.GC14012@breakpoint.cc>
Florian Westphal <fw@strlen.de> wrote:
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > > Hmm, that would be nice. I need to think about it again,
> > > problem is that moving it at this time could result in
> > > freeing the would-be parent of the new node.
> >
> > Yeah, thats why fq_gc() is followed by a full lookup.
> >
> > In practice, the lookup done in fq_gc() brings in cpu cache all the
> > cache lines, and second lookup is very fast.
>
> I had wondered about this. Ok, that makes sense.
> I'll change it to be more like fq.
>
> Thanks for explaining this.
Not exactly pretty, but in most cases the restart won't be needed
(either because we found node-to-add-to or no stale node to remove).
I'll fold the following into patch #7, but will wait until Tuesday
before resend in order to give others a chance to comment.
diff --git a/net/netfilter/xt_connlimit.c b/net/netfilter/xt_connlimit.c
--- a/net/netfilter/xt_connlimit.c
+++ b/net/netfilter/xt_connlimit.c
@@ -202,7 +202,9 @@ count_tree(struct net *net, struct rb_root *root,
struct xt_connlimit_conn *conn;
unsigned int count = 0;
unsigned int gc_count = 0;
+ bool no_gc = false;
+ restart:
rbnode = &(root->rb_node);
while (*rbnode) {
int diff;
@@ -230,7 +232,7 @@ count_tree(struct net *net, struct rb_root *root,
return count + 1;
}
- if (gc_count >= ARRAY_SIZE(gc_nodes))
+ if (no_gc || gc_count >= ARRAY_SIZE(gc_nodes))
continue;
/* only used for GC on hhead, retval and 'addit' ignored */
@@ -239,15 +241,22 @@ count_tree(struct net *net, struct rb_root *root,
gc_nodes[gc_count++] = rbconn;
}
+ if (gc_count) {
+ no_gc = true;
+ tree_nodes_free(root, gc_nodes, gc_count);
+ gc_count = 0;
+ goto restart;
+ }
+
/* no match, need to insert new node */
rbconn = kmem_cache_alloc(connlimit_rb_cachep, GFP_ATOMIC);
if (rbconn == NULL)
- goto out;
+ return 0;
conn = kmem_cache_alloc(connlimit_conn_cachep, GFP_ATOMIC);
if (conn == NULL) {
kmem_cache_free(connlimit_rb_cachep, rbconn);
- goto out;
+ return 0;
}
conn->tuple = *tuple;
@@ -259,10 +268,7 @@ count_tree(struct net *net, struct rb_root *root,
rb_link_node(&rbconn->node, parent, rbnode);
rb_insert_color(&rbconn->node, root);
- count = 1;
- out:
- tree_nodes_free(root, gc_nodes, gc_count);
- return count;
+ return 1;
}
static int count_them(struct net *net,
next prev parent reply other threads:[~2014-03-09 21:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-07 13:37 [PATCH 0/7] netfilter: connlimit: scalability improvements Florian Westphal
2014-03-07 13:37 ` [PATCH 1/7] netfilter: connlimit: factor hlist search into new function Florian Westphal
2014-03-07 13:37 ` [PATCH 2/7] netfilter: connlimit: improve packet-to-closed-connection logic Florian Westphal
2014-03-07 13:37 ` [PATCH 3/7] netfilter: connlimit: move insertion of new element out of count function Florian Westphal
2014-03-07 13:37 ` [PATCH 4/7] netfilter: connlimit: use kmem_cache for conn objects Florian Westphal
2014-03-07 13:37 ` [PATCH 5/7] netfilter: connlimit: use keyed locks Florian Westphal
2014-03-09 17:13 ` Jan Engelhardt
2014-03-09 18:31 ` Florian Westphal
2014-03-07 13:37 ` [PATCH 6/7] netfilter: connlimit: make same_source_net signed Florian Westphal
2014-03-07 13:37 ` [PATCH 7/7] netfilter: connlimit: use rbtree for per-host conntrack obj storage Florian Westphal
2014-03-07 14:47 ` Eric Dumazet
2014-03-07 16:15 ` Florian Westphal
2014-03-09 18:42 ` Eric Dumazet
2014-03-09 18:43 ` Florian Westphal
2014-03-09 21:45 ` Florian Westphal [this message]
2014-03-12 12:58 ` [PATCH 0/7] netfilter: connlimit: scalability improvements Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140309214513.GD14012@breakpoint.cc \
--to=fw@strlen.de \
--cc=eric.dumazet@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.