]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: nft_set_rbtree: overlap detection with element re-addition after deletion
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 18 Apr 2022 10:21:05 +0000 (12:21 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 22 Apr 2022 13:49:15 +0000 (15:49 +0200)
This patch fixes spurious EEXIST errors.

Extend 6dce4a781fa8 ("netfilter: nft_set_rbtree: handle element
re-addition after deletion") to deal with elements with same end flags
in the same transation.

Reset the overlap flag as described by 4392e5177e05 ("netfilter:
nft_set_rbtree: Detect partial overlaps on insertion").

Fixes: 4392e5177e05 ("netfilter: nft_set_rbtree: Detect partial overlaps on insertion")
Fixes: 6dce4a781fa8 ("netfilter: nft_set_rbtree: handle element re-addition after deletion")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_set_rbtree.c

index d600a566da324ae7198635d81757ce78f7205489..7325bee7d14425232f953e630b7453cd490b5ce9 100644 (file)
@@ -349,7 +349,11 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
                                *ext = &rbe->ext;
                                return -EEXIST;
                        } else {
-                               p = &parent->rb_left;
+                               overlap = false;
+                               if (nft_rbtree_interval_end(rbe))
+                                       p = &parent->rb_left;
+                               else
+                                       p = &parent->rb_right;
                        }
                }