Skip to contentSkip to conversation

nft_set_pipapo: Drop useless assignment of scratch map index on insert

PATCH Applied Stefano Brivio 2 participants 5 messages Jun 14, 2020 – Jun 30, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nft_set_pipapo: Drop useless assignment of scratch map index on insert

In nft_pipapo_insert(), we need to reallocate scratch maps that will be used for matching by lookup functions, if they have never been allocated or if the bucket size changes as a result of the insertion.

As pipapo_realloc_scratch() provides a pair of fresh, zeroed out maps, there's no need to select a particular one after reallocation.

Other than being useless, the existing assignment was also troubled by the fact that the index was set only on the CPU performing the actual insertion, as spotted by Florian.

Simply drop the assignment.

Fixes 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation of ranges")

---
This might cause a conflict on merge from nf.git with commit c3829285b2e6 ("netfilter: nft_set_pipapo: Disable preemption before getting per-CPU pointer") -- the resolution is to just drop the call to this_cpu_write() like this patch does. I can send an explicit conflict resolution patch if needed.

 net/netfilter/nft_set_pipapo.c | 2 --
 1 file changed, 2 deletions(-)
net/netfilter/nft_set_pipapo.c +0 -2
index 8b5acc6910fd..9aa2bb3982e8 100644
@@ -1247,8 +1247,6 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
 		if (err)
 			return err;
 
-		this_cpu_write(nft_pipapo_scratch_index, false);
-
 		m->bsize_max = bsize_max;
 	}
 
Signature · 1 line
2.27.0
#1 lore raw
Quoted 4 lines · Stefano Brivio

In nft_pipapo_insert(), we need to reallocate scratch maps that will be used for matching by lookup functions, if they have never been allocated or if the bucket size changes as a result of the insertion.

Quoted 8 lines

As pipapo_realloc_scratch() provides a pair of fresh, zeroed out maps, there's no need to select a particular one after reallocation.

Other than being useless, the existing assignment was also troubled by the fact that the index was set only on the CPU performing the actual insertion, as spotted by Florian.

Simply drop the assignment.

I have just refreshed nf-next to pull in your fix dependency.

Please, rebase and resubmit this patch on top of nf-next.

Thanks.

#2 lore raw
In reply to Stefano Brivio
Quoted 7 lines · Stefano Brivio

In nft_pipapo_insert(), we need to reallocate scratch maps that will be used for matching by lookup functions, if they have never been allocated or if the bucket size changes as a result of the insertion.

As pipapo_realloc_scratch() provides a pair of fresh, zeroed out maps, there's no need to select a particular one after reallocation.

Quoted 8 lines

Other than being useless, the existing assignment was also troubled by the fact that the index was set only on the CPU performing the actual insertion, as spotted by Florian.

Simply drop the assignment.

Fixes 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation of ranges")

Hm.

It has a Fixes: tag.

Probably route this through nf.git instead?

Thanks.

#3 lore raw
Quoted 14 lines · On Wed, 17 Jun 2020 22:07:05 +0200 Pablo Neira Ayuso <[email protected]>…
Quoted 13 lines · Stefano Brivio

In nft_pipapo_insert(), we need to reallocate scratch maps that will be used for matching by lookup functions, if they have never been allocated or if the bucket size changes as a result of the insertion.

As pipapo_realloc_scratch() provides a pair of fresh, zeroed out maps, there's no need to select a particular one after reallocation.

Other than being useless, the existing assignment was also troubled by the fact that the index was set only on the CPU performing the actual insertion, as spotted by Florian.

Simply drop the assignment.

Quoted 8 lines
Quoted 2 lines
Fixes 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation of ranges")

Hm.

It has a Fixes: tag.

Probably route this through nf.git instead?

I wouldn't, because it just removes a redundant assignment (so I consider it a fix) but it doesn't fix any functional issue. Is there a specific reason why I should?

Signature · 1 line
Stefano
maintainer Applied
#4 lore raw
In reply to Stefano Brivio
Quoted 4 lines · Stefano Brivio

In nft_pipapo_insert(), we need to reallocate scratch maps that will be used for matching by lookup functions, if they have never been allocated or if the bucket size changes as a result of the insertion.

Quoted 8 lines

As pipapo_realloc_scratch() provides a pair of fresh, zeroed out maps, there's no need to select a particular one after reallocation.

Other than being useless, the existing assignment was also troubled by the fact that the index was set only on the CPU performing the actual insertion, as spotted by Florian.

Simply drop the assignment.

Applied to nf-next, thanks.