Skip to content

Commit 8b8a241

Browse files
Florian Westphalummakynes
authored andcommitted
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>
1 parent 80efd29 commit 8b8a241

1 file changed

Lines changed: 6 additions & 21 deletions

File tree

net/netfilter/nft_set_pipapo.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,33 +2326,18 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
23262326
{
23272327
struct nft_pipapo *priv = nft_set_priv(set);
23282328
struct nft_pipapo_match *m;
2329-
int cpu;
23302329

23312330
m = rcu_dereference_protected(priv->match, true);
2332-
if (m) {
2333-
rcu_barrier();
2334-
2335-
for_each_possible_cpu(cpu)
2336-
pipapo_free_scratch(m, cpu);
2337-
free_percpu(m->scratch);
2338-
pipapo_free_fields(m);
2339-
kfree(m);
2340-
priv->match = NULL;
2341-
}
23422331

23432332
if (priv->clone) {
2344-
m = priv->clone;
2345-
2346-
nft_set_pipapo_match_destroy(ctx, set, m);
2347-
2348-
for_each_possible_cpu(cpu)
2349-
pipapo_free_scratch(priv->clone, cpu);
2350-
free_percpu(priv->clone->scratch);
2351-
2352-
pipapo_free_fields(priv->clone);
2353-
kfree(priv->clone);
2333+
nft_set_pipapo_match_destroy(ctx, set, priv->clone);
2334+
pipapo_free_match(priv->clone);
23542335
priv->clone = NULL;
2336+
} else {
2337+
nft_set_pipapo_match_destroy(ctx, set, m);
23552338
}
2339+
2340+
pipapo_free_match(m);
23562341
}
23572342

23582343
/**

0 commit comments

Comments
 (0)