]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfilter: nf_tables: add .abort_skip_removal flag for set types
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 21 Jan 2026 00:08:44 +0000 (01:08 +0100)
committerFlorian Westphal <fw@strlen.de>
Thu, 22 Jan 2026 16:18:13 +0000 (17:18 +0100)
The pipapo set backend is the only user of the .abort interface so far.
To speed up pipapo abort path, removals are skipped.

The follow up patch updates the rbtree to use to build an array of
ordered elements, then use binary search. This needs a new .abort
interface but, unlike pipapo, it also need to undo/remove elements.

Add a flag and use it from the pipapo set backend.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
include/net/netfilter/nf_tables.h
net/netfilter/nf_tables_api.c
net/netfilter/nft_set_pipapo.c

index 2597077442e557fd5b94c4cbb74f92beaa23d201..31906f90706e9aec49809efd37a35287835546da 100644 (file)
@@ -451,6 +451,7 @@ struct nft_set_ext;
  *     @init: initialize private data of new set instance
  *     @destroy: destroy private data of set instance
  *     @gc_init: initialize garbage collection
+ *     @abort_skip_removal: skip removal of elements from abort path
  *     @elemsize: element private size
  *
  *     Operations lookup, update and delete have simpler interfaces, are faster
@@ -508,6 +509,7 @@ struct nft_set_ops {
                                                   const struct nft_set *set);
        void                            (*gc_init)(const struct nft_set *set);
 
+       bool                            abort_skip_removal;
        unsigned int                    elemsize;
 };
 
index e7247363c643e478ffbc74f97f63588fc95f72b1..be4924aeaf0e468e516c4be64df7f0fe3f84432b 100644 (file)
@@ -7807,7 +7807,8 @@ static bool nft_trans_elems_new_abort(const struct nft_ctx *ctx,
                        continue;
                }
 
-               if (!te->set->ops->abort || nft_setelem_is_catchall(te->set, te->elems[i].priv))
+               if (!te->set->ops->abort_skip_removal ||
+                   nft_setelem_is_catchall(te->set, te->elems[i].priv))
                        nft_setelem_remove(ctx->net, te->set, te->elems[i].priv);
 
                if (!nft_setelem_is_catchall(te->set, te->elems[i].priv))
index 6d77a5f0088ad0e9c078213f14f4fa6e8f6a9b22..18e1903b1d3d0b9eb1827a7f3a353ef452427ce9 100644 (file)
@@ -2370,6 +2370,7 @@ const struct nft_set_type nft_set_pipapo_type = {
                .gc_init        = nft_pipapo_gc_init,
                .commit         = nft_pipapo_commit,
                .abort          = nft_pipapo_abort,
+               .abort_skip_removal = true,
                .elemsize       = offsetof(struct nft_pipapo_elem, ext),
        },
 };
@@ -2394,6 +2395,7 @@ const struct nft_set_type nft_set_pipapo_avx2_type = {
                .gc_init        = nft_pipapo_gc_init,
                .commit         = nft_pipapo_commit,
                .abort          = nft_pipapo_abort,
+               .abort_skip_removal = true,
                .elemsize       = offsetof(struct nft_pipapo_elem, ext),
        },
 };