From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vincent Bernat Subject: Re: [PATCH net-next v1] ipvs: add consistent source hashing scheduling Date: Mon, 02 Apr 2018 19:57:12 +0200 Message-ID: References: <20180402172025.7380-1-vincent@bernat.im> <63c63fab-12ed-8b15-e00e-dc54e5c144eb@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: Wensong Zhang , Simon Horman , Julian Anastasov , "David S. Miller" , netdev@vger.kernel.org, lvs-devel@vger.kernel.org To: Eric Dumazet Return-path: Received: from bart.luffy.cx ([78.47.78.131]:50532 "EHLO bart.luffy.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752920AbeDBR5P (ORCPT ); Mon, 2 Apr 2018 13:57:15 -0400 In-Reply-To: <63c63fab-12ed-8b15-e00e-dc54e5c144eb@gmail.com> (Eric Dumazet's message of "Mon, 2 Apr 2018 10:33:27 -0700") Sender: netdev-owner@vger.kernel.org List-ID: =E2=9D=A6 2 avril 2018 10:33 -0700, Eric Dumazet = =C2=A0: >> +static inline u32 >> +ip_vs_csh_permutation(struct ip_vs_dest *d, int j) >> +{ >> + u32 offset, skip; >> + __be32 addr_fold =3D d->addr.ip; >> + >> +#ifdef CONFIG_IP_VS_IPV6 >> + if (d->af =3D=3D AF_INET6) >> + addr_fold =3D d->addr.ip6[0]^d->addr.ip6[1]^ >> + d->addr.ip6[2]^d->addr.ip6[3]; >> +#endif >> + addr_fold =3D ntohl(addr_fold) + ntohs(d->port); >> + offset =3D hash_32(addr_fold, 32) % IP_VS_CSH_TAB_SIZE; >> + skip =3D (hash_32(addr_fold + 1, 32) % (IP_VS_CSH_TAB_SIZE - 1)) + 1; >> + return (offset + j * skip) % IP_VS_CSH_TAB_SIZE; >> +} >> + > > This does not look very strong to me, particularly the IPv6 folding > > I would rather use __ipv6_addr_jhash() instead of ipv6_addr_hash(), > even if it is hard coded ;) I can switch to ipv6_addr_hash(). However, switching to __ipv6_addr_jhash seems useless as I would need to hardcode the initial value: people use source hashing to get the same result from one host to another. Am I missing something? --=20 Each module should do one thing well. - The Elements of Programming Style (Kernighan & Plauger)