[lvc-project] [PATCH 6.1.y 1/2] netfilter: nft_set_pipapo: prepare destroy function for on-demand clone

Denis Zubov d.zubov at tssltd.ru
Tue Sep 22 15:18:09 MSK 2026


From: Florian Westphal <fw at strlen.de>

commit 8b8a2417558c632f249abebde97adf8c46540de2 upstream.

Once priv->clone can be NULL in case no insertions/removals occurred
in the last transaction we need to drop set elements from priv->match
if priv->clone is NULL.

While at it, condense this function by reusing the pipapo_free_match
helper instead of open-coded version.

The rcu_barrier() is removed, its not needed: old call_rcu instances
for pipapo_reclaim_match do not access struct nft_set.

Signed-off-by: Florian Westphal <fw at strlen.de>
Reviewed-by: Stefano Brivio <sbrivio at redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

Needed in 6.1.y since v6.1.184, which took the middle of the
on-demand clone series (e.g. 11fb04a11193) as a dependency of
47e65eff5069: nft_pipapo_commit() now leaves priv->clone NULL, so
destroy must release elements from priv->match. Context adjusted
for the WARN_ON_ONCE() added by 16f3595c0441.

Fixes: 11fb04a11193 ("netfilter: nft_set_pipapo: move cloning of match info to insert/removal path")
Signed-off-by: Denis Zubov <d.zubov at tssltd.ru>
---
 net/netfilter/nft_set_pipapo.c | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c
index 4b37c6684bff..9add83917f17 100644
--- a/net/netfilter/nft_set_pipapo.c
+++ b/net/netfilter/nft_set_pipapo.c
@@ -2379,35 +2379,20 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
 {
 	struct nft_pipapo *priv = nft_set_priv(set);
 	struct nft_pipapo_match *m;
-	int cpu;
 
 	WARN_ON_ONCE(!list_empty(&priv->gc_head));
 
 	m = rcu_dereference_protected(priv->match, true);
-	if (m) {
-		rcu_barrier();
-
-		for_each_possible_cpu(cpu)
-			pipapo_free_scratch(m, cpu);
-		free_percpu(m->scratch);
-		pipapo_free_fields(m);
-		kfree(m);
-		priv->match = NULL;
-	}
 
 	if (priv->clone) {
-		m = priv->clone;
-
-		nft_set_pipapo_match_destroy(ctx, set, m);
-
-		for_each_possible_cpu(cpu)
-			pipapo_free_scratch(priv->clone, cpu);
-		free_percpu(priv->clone->scratch);
-
-		pipapo_free_fields(priv->clone);
-		kfree(priv->clone);
+		nft_set_pipapo_match_destroy(ctx, set, priv->clone);
+		pipapo_free_match(priv->clone);
 		priv->clone = NULL;
+	} else {
+		nft_set_pipapo_match_destroy(ctx, set, m);
 	}
+
+	pipapo_free_match(m);
 }
 
 /**
-- 
2.53.0




More information about the lvc-project mailing list