Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4121686rwe; Mon, 17 Apr 2023 08:14:08 -0700 (PDT) X-Google-Smtp-Source: AKy350YMuqqYOroSkOzgR/qKNfCGBE0f8WpOPJ8wrU1DnHC32/jeY3g4RTtiKjGaLESQ0I2eQvIm X-Received: by 2002:a17:90a:e507:b0:247:e4c:d168 with SMTP id t7-20020a17090ae50700b002470e4cd168mr15142827pjy.10.1681744448145; Mon, 17 Apr 2023 08:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681744448; cv=none; d=google.com; s=arc-20160816; b=Rwcp0cvgchR0U1xNkKaTwJ7qHeUFS7aDv8fi5EDFzbXuENMMus7/ZrflJSBHDL07oK LNajUcyB+XoRxnQq7C1qO3dCCyVMZiUbNcuq2Ik/UEbGNrfekeIn755qhWlWQu5oFC79 sK13vmTxAi5Z0ZQ48djDJaGFWXuGOtB2PqgKl7rqjEf9Z8dv7ojmtBdt5iw0KKQkeXPQ x5YcwiFV2IQjZovC9a25bT7i/77Ub+igPOtdb+JDVNPtKrRiVcQl8IuWyf0kQ1liHeZ+ 34Ld19yXckwPjYnaS39JhGCJ+DA2FSo/ywEJwBkNj7P2yLjLepTnB8fDQYDlgM+0qZ2K ADOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=NIQkvwLY3v0juec1Qg+32zo4zk6H6pZGo59u/EREwuI=; b=QF47gPpCIXm8TsRiFD99BwFrvUxIKKNjIMV8v21QDwLjRLsYnGCL4RgsoAyEtU5r7j Kbnb44oqOgbhlZbKPlgPirORpTK8DW4QTN9UEV8nsDdj+SNMCtdtoAXGqHkfFS/vJHa7 Khk85cXxgdJWkfmTwyAMxiewRGSDhXfuSuTgX1NBiT72mRiXXEScp8eUKM9Ky9lGSm3A 8BxZcKuD3OJGQME9jXjPl1BGQt5MbvcHIAd8r/LzDkq8t4w0tjfAPxbEid74f1R3ZCec A8Acpc6j4JuUVmaQsaKxjzlJrlpKc/3UJmPujcreDnSoJQzoItHitt7rxQ4ieIa3klxL 9Xgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xa8XIpFr; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020a656104000000b004fae5f0895dsi12186717pgu.45.2023.04.17.08.13.56; Mon, 17 Apr 2023 08:14:08 -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=@kernel.org header.s=k20201202 header.b=Xa8XIpFr; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231280AbjDQPLn (ORCPT + 99 others); Mon, 17 Apr 2023 11:11:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbjDQPLc (ORCPT ); Mon, 17 Apr 2023 11:11:32 -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 E04CFAF02; Mon, 17 Apr 2023 08:11:26 -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 473A3626A5; Mon, 17 Apr 2023 15:11:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13DD4C4339E; Mon, 17 Apr 2023 15:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681744285; bh=jO4SH5SYNICEVsSAgMcpOLdT5eYDNjxqRtRYykVAw9k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Xa8XIpFrXoflrJBQKG7si4QG+0+RGUdY/4Ko5Z41kDhHwhPE2skB8OCOMXsC3R0st hrN9wcf2uokQC/+eaP5Xt3j9/zzCO9Om6XZm1Bbe1YEm74QvOfm0V0qRFGDTGoZhvn mImIMqsCoaKKlae40Rjexr+/KI+j+9MESb4pbiCSknd6svf2itMNfN//eAh7bWjjo2 NRObpOgXCqgCPaMYn8G8XTkGfs3NPHHe4RXmYqCUcBX1HIL3MeX4gFNr+lQ35MjTm/ ebZamN4OEoyFT6f/srItZ66jOLcqaGwoUTfR4M87xWypmCR/PZwibDL+3W+J6jYjC6 2h4A6BCartadQ== From: Simon Horman Date: Mon, 17 Apr 2023 17:10:46 +0200 Subject: [PATCH nf-next v3 2/4] ipvs: Consistently use array_size() in ip_vs_conn_init() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230409-ipvs-cleanup-v3-2-5149ea34b0b9@kernel.org> References: <20230409-ipvs-cleanup-v3-0-5149ea34b0b9@kernel.org> In-Reply-To: <20230409-ipvs-cleanup-v3-0-5149ea34b0b9@kernel.org> To: Julian Anastasov Cc: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , netdev@vger.kernel.org, "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , lvs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, Horatiu Vultur X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Consistently use array_size() to calculate the size of ip_vs_conn_tab in bytes. Flagged by Coccinelle: WARNING: array_size is already used (line 1498) to compute the same size No functional change intended. Compile tested only. Signed-off-by: Simon Horman Reviewed-by: Horatiu Vultur --- v3 - Correct division by 1024. It was applied to the wrong variable in v2. - Add Horatiu's Reviewed-by tag v2 - Retain division by 1024, which was lost in v1 --- net/netfilter/ipvs/ip_vs_conn.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index 13534e02346c..928e64653837 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c @@ -1481,6 +1481,7 @@ void __net_exit ip_vs_conn_net_cleanup(struct netns_ipvs *ipvs) int __init ip_vs_conn_init(void) { + size_t tab_array_size; int idx; /* Compute size and mask */ @@ -1494,8 +1495,9 @@ int __init ip_vs_conn_init(void) /* * Allocate the connection hash table and initialize its list heads */ - ip_vs_conn_tab = vmalloc(array_size(ip_vs_conn_tab_size, - sizeof(*ip_vs_conn_tab))); + tab_array_size = array_size(ip_vs_conn_tab_size, + sizeof(*ip_vs_conn_tab)); + ip_vs_conn_tab = vmalloc(tab_array_size); if (!ip_vs_conn_tab) return -ENOMEM; @@ -1508,10 +1510,8 @@ int __init ip_vs_conn_init(void) return -ENOMEM; } - pr_info("Connection hash table configured " - "(size=%d, memory=%ldKbytes)\n", - ip_vs_conn_tab_size, - (long)(ip_vs_conn_tab_size*sizeof(*ip_vs_conn_tab))/1024); + pr_info("Connection hash table configured (size=%d, memory=%zdKbytes)\n", + ip_vs_conn_tab_size, tab_array_size / 1024); IP_VS_DBG(0, "Each connection entry needs %zd bytes at least\n", sizeof(struct ip_vs_conn)); -- 2.30.2