From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: netfilter-devel@vger.kernel.org, Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH] netfilter: ipset: Increase the number of maximal sets automatically as needed
Date: Mon, 19 Nov 2012 18:49:25 +0100 [thread overview]
Message-ID: <20121119174925.GA30146@1984> (raw)
In-Reply-To: <20121119173206.GA27443@1984>
On Mon, Nov 19, 2012 at 06:32:06PM +0100, Pablo Neira Ayuso wrote:
> Hi Jozsef,
>
> On Mon, Nov 19, 2012 at 05:45:39PM +0100, Jozsef Kadlecsik wrote:
> > Hi Pablo,
> >
> > Please consider applying the next patch for the nf-next tree as it's a new
> > feature. You can also pull the patch from here:
> >
> > git://blackhole.kfki.hu/nf-next master
> >
> > The max number of sets was hardcoded at kernel cofiguration time.
> > The patch adds the support to increase the max number of sets automatically.
> >
> > Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
> > ---
> > net/netfilter/ipset/ip_set_core.c | 59 ++++++++++++++++++++++++++++++++-----
> > 1 files changed, 51 insertions(+), 8 deletions(-)
> >
> > diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
> > index 778465f..05bc604 100644
> > --- a/net/netfilter/ipset/ip_set_core.c
> > +++ b/net/netfilter/ipset/ip_set_core.c
> > @@ -31,6 +31,7 @@ static DEFINE_RWLOCK(ip_set_ref_lock); /* protects the set refs */
> > static struct ip_set **ip_set_list; /* all individual sets */
> > static ip_set_id_t ip_set_max = CONFIG_IP_SET_MAX; /* max number of sets */
> >
> > +#define IP_SET_INC 64
> > #define STREQ(a, b) (strncmp(a, b, IPSET_MAXNAMELEN) == 0)
> >
> > static unsigned int max_sets;
> > @@ -344,12 +345,26 @@ __ip_set_put(ip_set_id_t index)
> > * so it can't be destroyed (or changed) under our foot.
> > */
> >
> > +static inline struct ip_set *
> > +ip_set_rcu_get(ip_set_id_t index)
> > +{
> > + struct ip_set *set, **list;
> > +
> > + rcu_read_lock();
> > + /* ip_set_list itself needs to be protected */
> > + list = rcu_dereference(ip_set_list);
> > + set = list[index];
>
> You can simplify the two lines above with:
> list = rcu_dereference(ip_set_list[index]);
>
> > + rcu_read_unlock();
>
> Note that out of the rcu_read_unlock that `set' pointer is not granted
> to be valid.
>
> So you have to call rcu_read_unlock once you are sure you don't need
> to access your `set' object anymore, eg.
>
> int ip_set_test(...)
> {
> struct ip_set *set;
> int ret = 0;
>
> rcu_read_lock();
> set = rcu_dereference(ip_set_list[index]);
>
> ...
>
> rcu_read_unlock();
>
> /* Convert error codes to nomatch */
> return (ret < 0 ? 0 : ret);
> }
> EXPORT_SYMBOL_GPL(ip_set_test);
Oh, I see, set objects are not protected with rcu, only the set array
is protected with rcu. So any dereference out of the rcu_read_lock
section is valid. Forget the comment.
next prev parent reply other threads:[~2012-11-19 17:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-19 16:45 [PATCH] netfilter: ipset: Increase the number of maximal sets automatically as needed Jozsef Kadlecsik
2012-11-19 17:01 ` Eric Dumazet
2012-11-19 17:21 ` Jozsef Kadlecsik
2012-11-19 17:29 ` Eric Dumazet
2012-11-19 17:32 ` Pablo Neira Ayuso
2012-11-19 17:47 ` Jozsef Kadlecsik
2012-11-19 17:49 ` Pablo Neira Ayuso [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-11-20 19:27 Jozsef Kadlecsik
2012-11-27 10:48 ` Pablo Neira Ayuso
2012-11-27 11:18 ` Jozsef Kadlecsik
2012-11-27 11:33 ` Pablo Neira Ayuso
2012-11-27 11:55 ` Jozsef Kadlecsik
2012-11-27 14:09 ` 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=20121119174925.GA30146@1984 \
--to=pablo@netfilter.org \
--cc=eric.dumazet@gmail.com \
--cc=kadlec@blackhole.kfki.hu \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).