From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: fw@strlen.de
Subject: [PATCH nf-next,v1 0/3] convert rbtree to binary search array
Date: Thu, 15 Jan 2026 13:43:19 +0100 [thread overview]
Message-ID: <20260115124322.90712-1-pablo@netfilter.org> (raw)
Hi,
Florian reported that there is currently an issue with interval matching
in the rbtree, allowing for false negative lookup during transaction.
This series addresses this issue by translating the rbtree, which keeps
the intervals in order, to binary search. The array is published to
packet path through RCU. The idea is to keep using the rbtree
datastructure for control plane, which needs to deal with updates, then
generating a array using this rbtree for binary search lookups.
There is a corner case worth mention: Anonymous maps result in
consecutive start elements in case of contiguous intervals, this needs
a special handling which is documented in the new .commit function.
With 100k elements, this shows a little more overhead to build this
array, mainly due to the memory allocation.
This approach allows to compact the start and end elements in one single
intervals in the array, which speeds up packet lookups by ~50% according
to the existing performance script in selftests.
This is approach does not require the spinlock anymore, which is only
needed by control plane. Although I think it can be removed if .walk
is translated to dump the set content using the new array.
This also allows to remove the seqcount_t in a later patch.
Patch #1 allows to call .remove in case .abort is defined, which is
needed by this new approach. Only pipapo needs to skip .remove to speed.
Patch #2 add the binary search array approach for interval matching.
Patch #3 updates .get to use the binary search array to find for
(closest or exact) interval matching.
This series passes tests/shell successfully, but more tests on this
would be good to have because this is a bit of new code.
This series is an alternative proposal to Florian's approach.
Pablo Neira Ayuso (3):
netfilter: nf_tables: add .abort_skip_removal flag for set types
netfilter: nft_set_rbtree: translate rbtree to array for binary search
netfilter: nft_set_rbtree: use binary search array in get command
include/net/netfilter/nf_tables.h | 1 +
net/netfilter/nf_tables_api.c | 2 +-
net/netfilter/nft_set_pipapo.c | 2 +
net/netfilter/nft_set_rbtree.c | 421 ++++++++++++++++++++----------
4 files changed, 287 insertions(+), 139 deletions(-)
--
2.47.3
next reply other threads:[~2026-01-15 12:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 12:43 Pablo Neira Ayuso [this message]
2026-01-15 12:43 ` [PATCH nf-next,v1 1/3] netfilter: nf_tables: add .abort_skip_removal flag for set types Pablo Neira Ayuso
2026-01-15 14:59 ` Florian Westphal
2026-01-15 12:43 ` [PATCH nf-next,v1 2/3] netfilter: nft_set_rbtree: translate rbtree to array for binary search Pablo Neira Ayuso
2026-01-16 4:21 ` kernel test robot
2026-01-15 12:43 ` [PATCH nf-next,v1 3/3] netfilter: nft_set_rbtree: use binary search array in get command 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=20260115124322.90712-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--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