diff options
author | Vincent Bernat <vincent@bernat.im> | 2018-04-01 12:27:11 +0200 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2018-04-09 10:15:27 +0300 |
commit | 9a17740e0ea1c9b1edd89836bb27c76272f54641 (patch) | |
tree | d3038013b241a1ee394aacb1ff7214e8b448b8bb /net/netfilter/ipvs/ip_vs_lblcr.c | |
parent | netfilter: ipvs: Add configurations of Maglev hashing (diff) | |
download | linux-dev-9a17740e0ea1c9b1edd89836bb27c76272f54641.tar.xz linux-dev-9a17740e0ea1c9b1edd89836bb27c76272f54641.zip |
ipvs: fix multiplicative hashing in sh/dh/lblc/lblcr algorithms
The sh/dh/lblc/lblcr algorithms are using Knuth's multiplicative
hashing incorrectly. Replace its use by the hash_32() macro, which
correctly implements this algorithm. It doesn't use the same constant,
but it shouldn't matter.
Signed-off-by: Vincent Bernat <vincent@bernat.im>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'net/netfilter/ipvs/ip_vs_lblcr.c')
-rw-r--r-- | net/netfilter/ipvs/ip_vs_lblcr.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c index 92adc04557ed..9b6a6c9e9cfa 100644 --- a/net/netfilter/ipvs/ip_vs_lblcr.c +++ b/net/netfilter/ipvs/ip_vs_lblcr.c @@ -47,6 +47,7 @@ #include <linux/jiffies.h> #include <linux/list.h> #include <linux/slab.h> +#include <linux/hash.h> /* for sysctl */ #include <linux/fs.h> @@ -323,7 +324,7 @@ ip_vs_lblcr_hashkey(int af, const union nf_inet_addr *addr) addr_fold = addr->ip6[0]^addr->ip6[1]^ addr->ip6[2]^addr->ip6[3]; #endif - return (ntohl(addr_fold)*2654435761UL) & IP_VS_LBLCR_TAB_MASK; + return hash_32(ntohl(addr_fold), IP_VS_LBLCR_TAB_BITS); } |