[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1d570c92-8acc-fd82-ce8b-f23b2ce47a9f@gmail.com>
Date: Tue, 18 Jan 2022 19:42:11 -0700
From: David Ahern <dsahern@...il.com>
To: Eric Dumazet <eric.dumazet@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>
Cc: David Ahern <dsahern@...nel.org>, netdev <netdev@...r.kernel.org>,
Eric Dumazet <edumazet@...gle.com>
Subject: Re: [PATCH net 2/2] ipv4: add net_hash_mix() dispersion to
fib_info_laddrhash keys
On 1/18/22 1:46 PM, Eric Dumazet wrote:
> diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
> index 9813949da10493de36b9db797b6a5d94fd9bd3b1..7971889fc0fe3690e47931c39e6a8f8e0fb1d31f 100644
> --- a/net/ipv4/fib_semantics.c
> +++ b/net/ipv4/fib_semantics.c
> @@ -52,6 +52,7 @@ static DEFINE_SPINLOCK(fib_info_lock);
> static struct hlist_head *fib_info_hash;
> static struct hlist_head *fib_info_laddrhash;
> static unsigned int fib_info_hash_size;
> +static unsigned int fib_info_hash_bits;
> static unsigned int fib_info_cnt;
>
> #define DEVINDEX_HASHBITS 8
> @@ -1247,13 +1248,9 @@ int fib_check_nh(struct net *net, struct fib_nh *nh, u32 table, u8 scope,
> return err;
> }
>
> -static inline unsigned int fib_laddr_hashfn(__be32 val)
> +static inline unsigned int fib_laddr_hashfn(const struct net *net, __be32 val)
> {
> - unsigned int mask = (fib_info_hash_size - 1);
> -
> - return ((__force u32)val ^
> - ((__force u32)val >> 7) ^
> - ((__force u32)val >> 14)) & mask;
> + return hash_32(net_hash_mix(net) ^ (__force u32)val, fib_info_hash_bits);
> }
>
> static struct hlist_head *fib_info_hash_alloc(int bytes)
for consistency, make this hashfn and bucket lookup similar to
fib_devindex_hashfn and fib_info_devhash_bucket.
Powered by blists - more mailing lists