Skip to content

Commit c1f305a

Browse files
ummakynesgregkh
authored andcommitted
netfilter: nf_tables: add .abort_skip_removal flag for set types
commit f175b46 upstream. 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> Cc: "Kris Karas (Bug Reporting)" <bugs-a21@moonlit-rail.com> Cc: Genes Lists <lists@sapience.com> Cc: Philip Müller <philm@manjaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2ad6657 commit c1f305a

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

include/net/netfilter/nf_tables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ struct nft_set_ext;
456456
* @init: initialize private data of new set instance
457457
* @destroy: destroy private data of set instance
458458
* @gc_init: initialize garbage collection
459+
* @abort_skip_removal: skip removal of elements from abort path
459460
* @elemsize: element private size
460461
*
461462
* Operations lookup, update and delete have simpler interfaces, are faster
@@ -513,6 +514,7 @@ struct nft_set_ops {
513514
const struct nft_set *set);
514515
void (*gc_init)(const struct nft_set *set);
515516

517+
bool abort_skip_removal;
516518
unsigned int elemsize;
517519
};
518520

net/netfilter/nf_tables_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7821,7 +7821,8 @@ static bool nft_trans_elems_new_abort(const struct nft_ctx *ctx,
78217821
continue;
78227822
}
78237823

7824-
if (!te->set->ops->abort || nft_setelem_is_catchall(te->set, te->elems[i].priv))
7824+
if (!te->set->ops->abort_skip_removal ||
7825+
nft_setelem_is_catchall(te->set, te->elems[i].priv))
78257826
nft_setelem_remove(ctx->net, te->set, te->elems[i].priv);
78267827

78277828
if (!nft_setelem_is_catchall(te->set, te->elems[i].priv))

net/netfilter/nft_set_pipapo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,7 @@ const struct nft_set_type nft_set_pipapo_type = {
23702370
.gc_init = nft_pipapo_gc_init,
23712371
.commit = nft_pipapo_commit,
23722372
.abort = nft_pipapo_abort,
2373+
.abort_skip_removal = true,
23732374
.elemsize = offsetof(struct nft_pipapo_elem, ext),
23742375
},
23752376
};
@@ -2394,6 +2395,7 @@ const struct nft_set_type nft_set_pipapo_avx2_type = {
23942395
.gc_init = nft_pipapo_gc_init,
23952396
.commit = nft_pipapo_commit,
23962397
.abort = nft_pipapo_abort,
2398+
.abort_skip_removal = true,
23972399
.elemsize = offsetof(struct nft_pipapo_elem, ext),
23982400
},
23992401
};

0 commit comments

Comments
 (0)