* [PATCH net-next] ipv4: avoid quadratic behavior in FIB insertion of common address
@ 2024-09-26 10:08 Alexandre Ferrieux
2024-09-26 10:19 ` Nicolas Dichtel
2024-09-26 15:43 ` Simon Horman
0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Ferrieux @ 2024-09-26 10:08 UTC (permalink / raw)
To: edumazet; +Cc: alexandre.ferrieux, nicolas.dichtel, netdev
Mix netns into all IPv4 FIB hashes to avoid massive collision
when inserting the same address in many netns.
Signed-off-by: Alexandre Ferrieux <alexandre.ferrieux@orange.com>
---
net/ipv4/fib_semantics.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index ba2df3d2ac15..e25c8bc56067 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -347,11 +347,9 @@ static unsigned int fib_info_hashfn_1(int init_val, u8 protocol, u8 scope,
return val;
}
-static unsigned int fib_info_hashfn_result(unsigned int val)
+static unsigned int fib_info_hashfn_result(const struct net *net, unsigned int val)
{
- unsigned int mask = (fib_info_hash_size - 1);
-
- return (val ^ (val >> 7) ^ (val >> 12)) & mask;
+ return hash_32(val ^ net_hash_mix(net), fib_info_hash_bits);
}
static inline unsigned int fib_info_hashfn(struct fib_info *fi)
@@ -370,7 +368,7 @@ static inline unsigned int fib_info_hashfn(struct fib_info *fi)
} endfor_nexthops(fi)
}
- return fib_info_hashfn_result(val);
+ return fib_info_hashfn_result(fi->fib_net, val);
}
/* no metrics, only nexthop id */
@@ -385,7 +383,7 @@ static struct fib_info *fib_find_info_nh(struct net *net,
cfg->fc_protocol, cfg->fc_scope,
(__force u32)cfg->fc_prefsrc,
cfg->fc_priority);
- hash = fib_info_hashfn_result(hash);
+ hash = fib_info_hashfn_result(net, hash);
head = &fib_info_hash[hash];
hlist_for_each_entry(fi, head, fib_hash) {
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ipv4: avoid quadratic behavior in FIB insertion of common address
2024-09-26 10:08 [PATCH net-next] ipv4: avoid quadratic behavior in FIB insertion of common address Alexandre Ferrieux
@ 2024-09-26 10:19 ` Nicolas Dichtel
2024-09-26 15:43 ` Simon Horman
1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Dichtel @ 2024-09-26 10:19 UTC (permalink / raw)
To: Alexandre Ferrieux, edumazet; +Cc: alexandre.ferrieux, netdev
Le 26/09/2024 à 12:08, Alexandre Ferrieux a écrit :
> Mix netns into all IPv4 FIB hashes to avoid massive collision
> when inserting the same address in many netns.
>
> Signed-off-by: Alexandre Ferrieux <alexandre.ferrieux@orange.com>
> ---
Please, wait 24 hours before send the v2:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/maintainer-netdev.rst#n394
Also, update the commit title with the version number, for example ([PATCH
net-next v2]).
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst#n666
And add a log explaining the changes.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst#n723
Regards,
Nicolas
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ipv4: avoid quadratic behavior in FIB insertion of common address
2024-09-26 10:08 [PATCH net-next] ipv4: avoid quadratic behavior in FIB insertion of common address Alexandre Ferrieux
2024-09-26 10:19 ` Nicolas Dichtel
@ 2024-09-26 15:43 ` Simon Horman
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-09-26 15:43 UTC (permalink / raw)
To: Alexandre Ferrieux; +Cc: edumazet, alexandre.ferrieux, nicolas.dichtel, netdev
On Thu, Sep 26, 2024 at 12:08:07PM +0200, Alexandre Ferrieux wrote:
> Mix netns into all IPv4 FIB hashes to avoid massive collision
> when inserting the same address in many netns.
>
> Signed-off-by: Alexandre Ferrieux <alexandre.ferrieux@orange.com>
Hi Alexandre,
Thanks for your updated patch.
net-next is currently closed for the v6.12 merge window. It should
reopen next week, after v6.12-rc1 has been released. Please repost
your patch, keeping in mind other feedback from Nicolas Dichtel after
it has reopned.
> ---
> net/ipv4/fib_semantics.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
> index ba2df3d2ac15..e25c8bc56067 100644
> --- a/net/ipv4/fib_semantics.c
> +++ b/net/ipv4/fib_semantics.c
> @@ -347,11 +347,9 @@ static unsigned int fib_info_hashfn_1(int init_val, u8 protocol, u8 scope,
> return val;
> }
>
> -static unsigned int fib_info_hashfn_result(unsigned int val)
> +static unsigned int fib_info_hashfn_result(const struct net *net, unsigned int val)
Please line wrap the above so it fits within 80 columns, as is still
preferred by Networking code.
checkpatch can be run with an option to flag this.
> {
> - unsigned int mask = (fib_info_hash_size - 1);
> -
> - return (val ^ (val >> 7) ^ (val >> 12)) & mask;
> + return hash_32(val ^ net_hash_mix(net), fib_info_hash_bits);
> }
>
> static inline unsigned int fib_info_hashfn(struct fib_info *fi)
...
--
pw-bot: defer
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-26 15:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 10:08 [PATCH net-next] ipv4: avoid quadratic behavior in FIB insertion of common address Alexandre Ferrieux
2024-09-26 10:19 ` Nicolas Dichtel
2024-09-26 15:43 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).