Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6138229iog; Thu, 23 Jun 2022 12:08:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v9HAVvAJqiOHk/fCA2oicd3NN8YVd+B9uHQqj+XgxGgWfNcqOhtt4UdnunjM77/RyNml4P X-Received: by 2002:a05:6a00:1584:b0:51c:7932:975a with SMTP id u4-20020a056a00158400b0051c7932975amr42291924pfk.80.1656011316911; Thu, 23 Jun 2022 12:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011316; cv=none; d=google.com; s=arc-20160816; b=egc/SQ4NDEJ1Eu9393jZzKMRC+tzw4+DVnTVjJDIOBMYhhLWoaQKO2vaR3miEeZxtB 8suollbk4LRcmeoiAjmJBxp78tn7oQs1B/cRJNf1YCcAWXqRtrb7a8bxNkhejZ5/yWlR i+/BWIpIy+tBWdwqz5Wc/1Ic/3SUmrx1PJsjWEnQxPq6RkZO5azx+j4sZs02z7jQ6Es9 duYbj5hG0Mx6P5H5FA1Kv7hDLf1hnWagl0RhYNOBGXOEstCoPtwyniij1QEmtZ338h0k iO71NCYngifzUd6h0OkzzLYpL9FzT//61lvf/TBB9VAiynSUQ5ZUIcbI5FRGC/8+5T4l X2Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ed6BDSn6gQkyzq6vFXYhsqZ0R52zlVJAnmLuvqFlRZU=; b=xC+3yyiIS9VKTOKibbgrjWD+IOvyHxQ67Rq+8CHyPiC7LfMOTc5CZwSx4ArLfadpq2 Qxw+GPDKhmwiKaWI3MdPSwa2Dj1zG3uOgwdpDah6dBKk8s+IFNJvrBtDhtgfl6WavXvj DcxfzO2mT/q7jhxZGHpX1Ka5AU/Dpw46L7q4J4BtgZse7v7mv8m69OQzz6SZsN9AFRCE EhYkRduVtb/r5KYDyrJVTlZ8AfpTwB8O2+OOjG0w+eGOYMY1BcVqxRGY0DFKANY9Uz5E u1PwLAaIsOkTnQAdKwWRI6LO3RgW0ptiaU4xM70H2v8X1HwETzrQXR2bv/bRaODKTJLO ilaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yWNEsKLQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j11-20020a17090a2a8b00b001e312672c02si262281pjd.30.2022.06.23.12.08.20; Thu, 23 Jun 2022 12:08:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yWNEsKLQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235930AbiFWSVQ (ORCPT + 99 others); Thu, 23 Jun 2022 14:21:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237089AbiFWSRs (ORCPT ); Thu, 23 Jun 2022 14:17:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6465490F94; Thu, 23 Jun 2022 10:24:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B606961ED3; Thu, 23 Jun 2022 17:24:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A315C3411B; Thu, 23 Jun 2022 17:24:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005045; bh=swF7sbNxpW28GN6oVd41lbO80ioP3K/tLDQUL7wUsfw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yWNEsKLQS5R5uk6RL0I/jKhKPr+5zuCMyVDsWblpOXtT7ndGtbSafp578JhBbl5/N ai/z4v/diqtN9j2dhP4xc5Hj0ipTJ0i6D2OilRBKq5j3UmAJt6hhrDJ4sVkNGZLe7C /2th8kajB9h4UQVR81mlgmGsalAKxcN4QLIumdgg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amit Klein , Eric Dumazet , Willy Tarreau , Jakub Kicinski , Ben Hutchings Subject: [PATCH 4.19 233/234] tcp: drop the hash_32() part from the index calculation Date: Thu, 23 Jun 2022 18:45:00 +0200 Message-Id: <20220623164349.643899717@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Willy Tarreau commit e8161345ddbb66e449abde10d2fdce93f867eba9 upstream. In commit 190cc82489f4 ("tcp: change source port randomizarion at connect() time"), the table_perturb[] array was introduced and an index was taken from the port_offset via hash_32(). But it turns out that hash_32() performs a multiplication while the input here comes from the output of SipHash in secure_seq, that is well distributed enough to avoid the need for yet another hash. Suggested-by: Amit Klein Reviewed-by: Eric Dumazet Signed-off-by: Willy Tarreau Signed-off-by: Jakub Kicinski Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- net/ipv4/inet_hashtables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -767,7 +767,7 @@ int __inet_hash_connect(struct inet_time net_get_random_once(table_perturb, INET_TABLE_PERTURB_SIZE * sizeof(*table_perturb)); - index = hash_32(port_offset, INET_TABLE_PERTURB_SHIFT); + index = port_offset & (INET_TABLE_PERTURB_SIZE - 1); offset = READ_ONCE(table_perturb[index]) + (port_offset >> 32); offset %= remaining;