All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: netfilter-devel@vger.kernel.org
Cc: Jozsef Kadlecsik <kadlec@netfilter.org>
Subject: Re: [PATCH nf v4] netfilter: ipset: remove need to allocate memory on delete operations operations
Date: Fri, 7 Aug 2026 15:50:30 +0200	[thread overview]
Message-ID: <anXipjQLvKUmiIYF@strlen.de> (raw)
In-Reply-To: <20260807002808.20075-1-fw@strlen.de>

Florian Westphal <fw@strlen.de> wrote:
> +		write_seqcount_end(&nets->seq);
> +		spin_unlock_bh(&set->lock);
>  	}
>  #endif
>  }
> @@ -1253,31 +1310,41 @@ mtype_test_cidrs(struct ip_set *set, struct mtype_elem *d,
>  #if IPSET_NET_COUNT == 2
>  	struct net_prefixes *nets1;
>  	struct mtype_elem orig = *d;
> +	unsigned int seq1;
>  	int ret, i, j, k;
>  #else
>  	int ret, i, j;
>  #endif
> -	u32 key, multi = 0;
> +	unsigned int seq0;
> +	u32 key, multi;
>  	u8 pos;
>  
>  	pr_debug("test by nets\n");
>  	rcu_read_lock_bh();
> +retry:
> +	multi = 0;
>  	nets0 = rcu_dereference_bh(h->rnets[0]);
> +	seq0 = read_seqcount_begin(&nets0->seq);
[..]
>  unlock:
> +	if (read_seqcount_retry(&nets0->seq, seq0))
> +		goto retry;

Sashiko now says this retry loop causes double-count
on match, yet v3 said not doing this causes possible
miss of a nomatch entry.

I think missing nomatch entry is worse and doublecount
is ok.

The restart is rare enough anyway because write_seqcount_begin()
is only called when set is flushed or a element deletion brings
a cidr count value down to 0.

Another option is to prellocate all possible CIDRs but I'd
like to avoid it, this means checking up to 128 possible CIDRs
in ipv6 case.

Pre-sampling all values into local on-stack array is a non-starter
too due to stack cost.

What one COULD do is to use pcpu stash area for this, needs
local bh / local_lock.

But I think its a bit "too much" for this problem.

  reply	other threads:[~2026-08-07 13:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07  0:28 [PATCH nf v4] netfilter: ipset: remove need to allocate memory on delete operations operations Florian Westphal
2026-08-07 13:50 ` Florian Westphal [this message]
2026-08-09 13:36   ` Jozsef Kadlecsik

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=anXipjQLvKUmiIYF@strlen.de \
    --to=fw@strlen.de \
    --cc=kadlec@netfilter.org \
    --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.