mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 15:13:44 -04:00
netfilter: nft_set_pipapo: prepare destroy function for on-demand clone
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@strlen.de> Reviewed-by: Stefano Brivio <sbrivio@redhat.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
committed by
Pablo Neira Ayuso
parent
80efd2997f
commit
8b8a241755
@@ -2326,33 +2326,18 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
|
|||||||
{
|
{
|
||||||
struct nft_pipapo *priv = nft_set_priv(set);
|
struct nft_pipapo *priv = nft_set_priv(set);
|
||||||
struct nft_pipapo_match *m;
|
struct nft_pipapo_match *m;
|
||||||
int cpu;
|
|
||||||
|
|
||||||
m = rcu_dereference_protected(priv->match, true);
|
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) {
|
if (priv->clone) {
|
||||||
m = priv->clone;
|
nft_set_pipapo_match_destroy(ctx, set, priv->clone);
|
||||||
|
pipapo_free_match(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);
|
|
||||||
priv->clone = NULL;
|
priv->clone = NULL;
|
||||||
|
} else {
|
||||||
|
nft_set_pipapo_match_destroy(ctx, set, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pipapo_free_match(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user