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

To: Julian Anastasov <ja@xxxxxx>
Subject: Re: [PATCH net-next v1] ipvs: fix multiplicative hashing in sh/dh/lblc/lblcr algorithms
Cc: Wensong Zhang <wensong@xxxxxxxxxxxx>, Simon Horman <horms@xxxxxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxxxxx>, netdev@xxxxxxxxxxxxxxx, lvs-devel@xxxxxxxxxxxxxxx
From: Vincent Bernat <vincent@xxxxxxxxx>
Date: Sun, 01 Apr 2018 12:16:10 +0200
 ❦  1 avril 2018 11:11 +0300, Julian Anastasov <ja@xxxxxx> :

>> -    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)
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at

<Prev in Thread] Current Thread [Next in Thread>