Subject: Re: [PATCH net-next v1] ipvs: fix multiplicative hashing in sh/dh/lblc/lblcr algorithms

From: Vincent Bernat <[email-masked]>
Date: Sun, 01 Apr 2018 12:16:10 +0200

❦  1 avril 2018 11:11 +0300, Julian Anastasov <[email-masked]> :

>> -	return (ntohl(addr_fold)*2654435761UL) & IP_VS_DH_TAB_MASK;
>> +	return ((ntohl(addr_fold)*2654435761U) >>
>> +		(32 - IP_VS_DH_TAB_BITS)) &
>> +		IP_VS_DH_TAB_MASK;
>
> 	Looks like the '& mask' part is not needed, still,
> it does not generate extra code. I see that other code uses
> hash_32(val, bits) from include/linux/hash.h but note that it
> used different ratio before Linux 4.7, in case someone backports
> this patch on old kernels. So, I don't have preference what should
> be used, may be return hash_32(ntohl(addr_fold), IP_VS_DH_TAB_BITS)
> is better.

I didn't notice this macro. I think this is a better option. Let me
amend the patch.
-- 
Don't stop with your first draft.
            - The Elements of Programming Style (Kernighan & Plauger)