netfilter: nf_tables: do not remove elements if set backend implements .abort
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 4 Oct 2023 11:12:58 +0000 (13:12 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Oct 2023 10:03:07 +0000 (12:03 +0200)
commit ebd032fa881882fef2acb9da1bbde48d8233241d upstream.

pipapo set backend maintains two copies of the datastructure, removing
the elements from the copy that is going to be discarded slows down
the abort path significantly, from several minutes to few seconds after
this patch.

Fixes: 212ed75dc5fb ("netfilter: nf_tables: integrate pipapo into commit protocol")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/nf_tables_api.c

index 5e3dbe2652dbd867431733fea66477bcdb2999bf..8ab545802dd15d76b3fa712b56bb938a3e918257 100644 (file)
@@ -9931,7 +9931,10 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
                                break;
                        }
                        te = (struct nft_trans_elem *)trans->data;
-                       nft_setelem_remove(net, te->set, &te->elem);
+                       if (!te->set->ops->abort ||
+                           nft_setelem_is_catchall(te->set, &te->elem))
+                               nft_setelem_remove(net, te->set, &te->elem);
+
                        if (!nft_setelem_is_catchall(te->set, &te->elem))
                                atomic_dec(&te->set->nelems);