From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Patrick McHardy <kaber@trash.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] netfilter: nf_tables: handle more than 8 * PAGE_SIZE set name allocations
Date: Wed, 12 Mar 2014 17:18:00 +0100 [thread overview]
Message-ID: <20140312161800.GA784@localhost> (raw)
In-Reply-To: <1394192045-9039-1-git-send-email-kaber@trash.net>
On Fri, Mar 07, 2014 at 12:34:05PM +0100, Patrick McHardy wrote:
> We currently have a limit of 8 * PAGE_SIZE anonymous sets. Lift that limit
> by continuing the scan if the entire page is exhausted.
>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
> ---
> net/netfilter/nf_tables_api.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index f25d011..89d7ec4 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -2004,7 +2004,7 @@ static int nf_tables_set_alloc_name(struct nft_ctx *ctx, struct nft_set *set,
> const struct nft_set *i;
> const char *p;
> unsigned long *inuse;
> - unsigned int n = 0;
> + unsigned int n = 0, min = 0;
>
> p = strnchr(name, IFNAMSIZ, '%');
> if (p != NULL) {
> @@ -2014,23 +2014,28 @@ static int nf_tables_set_alloc_name(struct nft_ctx *ctx, struct nft_set *set,
> inuse = (unsigned long *)get_zeroed_page(GFP_KERNEL);
> if (inuse == NULL)
> return -ENOMEM;
> -
> +cont:
> list_for_each_entry(i, &ctx->table->sets, list) {
> int tmp;
>
> if (!sscanf(i->name, name, &tmp))
> continue;
> - if (tmp < 0 || tmp >= BITS_PER_BYTE * PAGE_SIZE)
> + if (tmp < min || tmp >= min + BITS_PER_BYTE * PAGE_SIZE)
I think we can break looping if tmp >= min + BITS_PER_BYTE * PAGE_SIZE
fulfills (assuming the list of sets is ordered).
> continue;
>
> - set_bit(tmp, inuse);
> + set_bit(tmp - min, inuse);
> }
>
> n = find_first_zero_bit(inuse, BITS_PER_BYTE * PAGE_SIZE);
> + if (n >= BITS_PER_BYTE * PAGE_SIZE) {
> + min += BITS_PER_BYTE * PAGE_SIZE;
> + memset(inuse, 0, PAGE_SIZE);
> + goto cont;
If the page is full, we start iterating over the set list from the
beginning.
> + }
> free_page((unsigned long)inuse);
> }
>
> - snprintf(set->name, sizeof(set->name), name, n);
> + snprintf(set->name, sizeof(set->name), name, min + n);
> list_for_each_entry(i, &ctx->table->sets, list) {
> if (!strcmp(set->name, i->name))
> return -ENFILE;
> --
> 1.8.5.3
>
next prev parent reply other threads:[~2014-03-12 16:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-07 11:34 [PATCH] netfilter: nf_tables: handle more than 8 * PAGE_SIZE set name allocations Patrick McHardy
2014-03-12 16:18 ` Pablo Neira Ayuso [this message]
2014-03-26 12:20 ` Patrick McHardy
2014-03-26 13:08 ` 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=20140312161800.GA784@localhost \
--to=pablo@netfilter.org \
--cc=kaber@trash.net \
--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.