netfilter: nft_set_rbtree: Switch to node list walk for overlap detection
...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 7c84d414 ("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: 7c84d414 ("netfilter: nft_set_rbtree: Detect partial overlaps on insertion") Reviewed-by: Stefano Brivio <sbrivio@redhat.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
parent
71ab9c3e
-
mentioned in commit 2bf1435f
-
mentioned in commit 318cb24a
-
mentioned in commit ec5caa76
-
mentioned in commit a836be60
-
mentioned in commit a337706c
-
mentioned in commit 3fa13203
-
mentioned in commit 50cbb9d1
-
mentioned in commit 08738827
-
mentioned in commit 3a5142f0
-
mentioned in commit a4b9bbd1
-
mentioned in commit 56a6ea76
-
mentioned in commit ef277530
-
mentioned in commit 181859bd
-
mentioned in commit acaee227
-
mentioned in commit 899aa563
-
mentioned in commit 7ab87a32
-
mentioned in commit 8284a791
-
mentioned in commit b76db53e
Please register or sign in to comment