From: Stefano Brivio <sbrivio@redhat.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, fw@strlen.de
Subject: Re: [PATCH nf,v4 1/2] netfilter: nft_set_rbtree: Switch to node list walk for overlap detection
Date: Sat, 21 Jan 2023 12:02:37 +0100 [thread overview]
Message-ID: <20230121120237.49b73c65@elisabeth> (raw)
In-Reply-To: <20230118151839.547103-1-pablo@netfilter.org>
On Wed, 18 Jan 2023 16:18:38 +0100
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> ...instead of a tree descent, which became overly complicated in an
> attempt to cover cases where expired or inactive elements would affect
> comparisons with the new element being inserted.
>
> Further, it turned out that it's probably impossible to cover all those
> cases, as inactive nodes might entirely hide subtrees consisting of a
> complete interval plus a node that makes the current insertion not
> overlap.
>
> To speed up the overlap check, descent the tree to find a greater
> element that is closer to the key value to insert. Then walk down the
> node list for overlap detection. Starting the overlap check from
> rb_first() unconditionally is slow, it takes 10 times longer due to the
> full linear traversal of the list.
>
> Moreover, perform garbage collection of expired elements when walking
> down the node list to avoid bogus overlap reports.
>
> For the insertion operation itself, this essentially reverts back to the
> implementation before commit 7c84d41416d8 ("netfilter: nft_set_rbtree:
> Detect partial overlaps on insertion"), except that cases of complete
> overlap are already handled in the overlap detection phase itself, which
> slightly simplifies the loop to find the insertion point.
>
> Based on initial patch from Stefano Brivio, including text from the
> original patch description too.
>
> Fixes: 7c84d41416d8 ("netfilter: nft_set_rbtree: Detect partial overlaps on insertion")
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> v4: - s/Descent/Descend in comments as per Stefano.
> - reintroduce nft_rbtree_update_first().
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
--
Stefano
prev parent reply other threads:[~2023-01-21 11:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 15:18 [PATCH nf,v4 1/2] netfilter: nft_set_rbtree: Switch to node list walk for overlap detection Pablo Neira Ayuso
2023-01-18 15:18 ` [PATCH nf,v4 2/2] netfilter: nft_set_rbtree: skip elements in transaction from garbage collection Pablo Neira Ayuso
2023-01-21 11:02 ` Stefano Brivio [this message]
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=20230121120237.49b73c65@elisabeth \
--to=sbrivio@redhat.com \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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.