Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3349019iob; Mon, 16 May 2022 20:18:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+1Ovp/YH6OkKBtz2Wg7REshCraVbxFD6qaWU/lz2EPOOAe168yMeSMSJWDzCQaCJwM2zl X-Received: by 2002:a17:907:9494:b0:6fa:78f3:eb9b with SMTP id dm20-20020a170907949400b006fa78f3eb9bmr17761601ejc.704.1652757484078; Mon, 16 May 2022 20:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652757484; cv=none; d=google.com; s=arc-20160816; b=acWqKkhw1Ooa4FXq4Wxho6y6Yoi3WFqjfuk5rDPouAp0q7FfXc4P2uNhWMyE7UuoKY ttTKvF4X0qMsvBP+b/JbpgE0oGNgpaGFkJdojIefUVESRzIeGMPaZqa8eFdzHBTNh4IN 8dOf9yg1YaId0QAFsesF/ajOv8qXMAGKnWPZsHu9bTDZVDblz45ehvF3xh1f6Dx8UMYG 4gxgKDqad0HA/QanL7+jiDqGMQvhz4zqaCdEkIwezA5ybjHiP7mQNT57BeHf4bFyr283 JARLkWqdAEmVS9PJqUJhoctNUmexkvk9R+8HJpsG5td2zUfwq0f0ryQkIsU4zF4BVPnj InMg== 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=lvM8RNP5pNmgliT48Wiyv/ega2uY3uXzH5ApsIZnlIU=; b=Liokdl75o6d725gY5SnyJVnSVpH7+QCZsJ3X7EdrSEaSqBxmrGhzcIjlZnS3QoWK0z EHZvpn3Ua0s0/92SP2aQIG/HoJZqpa1WMs5lvTlWz8yr/tDDZlx50c+Jwh56C/kETrZw RY228I04/BoLcee85yCOOhffdQPpdlTvRaev1502vV8URlfjGnHdxsHzaQdJnsoHtJgP atkn1LrwtwAd0Xk8CkhlItWZQisxUF5Hoadp/Q88dPSt4PVaj3KzwD81LLF0nBKkvPIo Rz91eVBJLfoy9f3Cpza2djZdhzGPs+7XKgzr/fYe4rPJH6/Gk6r35dvVqW1N7cIBldtM YcuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LSZLhBAt; 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 fd17-20020a056402389100b0042ab4438764si3519244edb.621.2022.05.16.20.17.38; Mon, 16 May 2022 20:18:04 -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=LSZLhBAt; 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 S1347065AbiEPUQo (ORCPT + 99 others); Mon, 16 May 2022 16:16:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348344AbiEPT6f (ORCPT ); Mon, 16 May 2022 15:58:35 -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 EED8843ACF; Mon, 16 May 2022 12:50:32 -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 8E3CA60C6F; Mon, 16 May 2022 19:50:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B9B2C36AE9; Mon, 16 May 2022 19:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652730632; bh=2OX837V48LPWy+fohNmbgAQwoavPUJVKqMpgPMB4Acg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LSZLhBAton9UfQV6N9mHqMRJZgc1e4W+Z4o/gvd0LZalcLlBekcCAjAh+3qVEIMu5 IopFJqpR7On5f+bpmdt4IwwjCaEijAR0wkSj/bf6U3P7QRhLpbQaFcck2DdFFTjhuM VU3q0l0fm4iQPBlckhXIRE04UyU2LnyEYjRj/bnQ= 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 , Sasha Levin Subject: [PATCH 5.15 061/102] tcp: drop the hash_32() part from the index calculation Date: Mon, 16 May 2022 21:36:35 +0200 Message-Id: <20220516193625.747686026@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193623.989270214@linuxfoundation.org> References: <20220516193623.989270214@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.4 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 [ Upstream commit e8161345ddbb66e449abde10d2fdce93f867eba9 ] 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: Sasha Levin --- net/ipv4/inet_hashtables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index f76e4ac1ba3a..ee9c587031b4 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -778,7 +778,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row, 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; -- 2.35.1