summaryrefslogtreecommitdiffstats
path: root/net/netfilter/ipvs/ip_vs_sh.c
diff options
context:
space:
mode:
authorVincent Bernat <vincent@bernat.im>2018-04-01 12:27:11 +0200
committerSimon Horman <horms@verge.net.au>2018-04-09 10:15:27 +0300
commit9a17740e0ea1c9b1edd89836bb27c76272f54641 (patch)
treed3038013b241a1ee394aacb1ff7214e8b448b8bb /net/netfilter/ipvs/ip_vs_sh.c
parent30edf801d7ed4b5a59601265792d3256836dc127 (diff)
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_sh.c')
-rw-r--r--net/netfilter/ipvs/ip_vs_sh.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/netfilter/ipvs/ip_vs_sh.c b/net/netfilter/ipvs/ip_vs_sh.c
index 16aaac6eedc9..1e01c782583a 100644
--- a/net/netfilter/ipvs/ip_vs_sh.c
+++ b/net/netfilter/ipvs/ip_vs_sh.c
@@ -96,7 +96,8 @@ ip_vs_sh_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 (offset + (ntohs(port) + ntohl(addr_fold))*2654435761UL) &
+ return (offset + hash_32(ntohs(port) + ntohl(addr_fold),
+ IP_VS_SH_TAB_BITS)) &
IP_VS_SH_TAB_MASK;
}