From patchwork Tue Aug 3 16:36:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12416765 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B36E1C4320A for ; Tue, 3 Aug 2021 16:37:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 883F861037 for ; Tue, 3 Aug 2021 16:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233588AbhHCQhV (ORCPT ); Tue, 3 Aug 2021 12:37:21 -0400 Received: from mga17.intel.com ([192.55.52.151]:62813 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233670AbhHCQhT (ORCPT ); Tue, 3 Aug 2021 12:37:19 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10065"; a="194013574" X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="194013574" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2021 09:37:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="500883484" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga001.jf.intel.com with ESMTP; 03 Aug 2021 09:36:56 -0700 Received: from alobakin-mobl.ger.corp.intel.com (eflejszm-mobl2.ger.corp.intel.com [10.213.26.164]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 173GahEq029968; Tue, 3 Aug 2021 17:36:52 +0100 From: Alexander Lobakin To: "David S. Miller" , Jakub Kicinski Cc: Alexander Lobakin , Jesse Brandeburg , Lukasz Czapnik , Marcin Kubiak , Michal Kubiak , Michal Swiatkowski , Jonathan Corbet , Netanel Belgazal , Arthur Kiyanovski , Guy Tzalik , Saeed Bishara , Ioana Ciornei , Claudiu Manoil , Thomas Petazzoni , Marcin Wojtas , Russell King , Edward Cree , Martin Habets , "Michael S. Tsirkin" , Jason Wang , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Shay Agroskin , Sameeh Jubran , Alexander Duyck , Danielle Ratson , Ido Schimmel , Andrew Lunn , Vladyslav Tarasiuk , Arnd Bergmann , Andrew Morton , Jian Shen , Petr Vorel , Dan Murphy , Yangbo Lu , Michal Kubecek , Zheng Yongjun , Heiner Kallweit , YueHaibing , Johannes Berg , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, bpf@vger.kernel.org Subject: [PATCH net-next 02/21] ethtool, stats: add compile-time checks for standard stats Date: Tue, 3 Aug 2021 18:36:22 +0200 Message-Id: <20210803163641.3743-3-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210803163641.3743-1-alexandr.lobakin@intel.com> References: <20210803163641.3743-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Make sure that the number of counters inside stats structures is with the corresponding Ethtool Netlink definitions. RMON stats is a special case -- don't take histogram fields into account. Signed-off-by: Alexander Lobakin Reviewed-by: Jesse Brandeburg --- net/ethtool/stats.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/ethtool/stats.c b/net/ethtool/stats.c index e35c87206b4c..8b5c27e034f9 100644 --- a/net/ethtool/stats.c +++ b/net/ethtool/stats.c @@ -117,6 +117,15 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, ops = dev->ethtool_ops; + BUILD_BUG_ON(sizeof(data->phy_stats) / sizeof(u64) != + __ETHTOOL_A_STATS_ETH_PHY_CNT); + BUILD_BUG_ON(sizeof(data->mac_stats) / sizeof(u64) != + __ETHTOOL_A_STATS_ETH_MAC_CNT); + BUILD_BUG_ON(sizeof(data->ctrl_stats) / sizeof(u64) != + __ETHTOOL_A_STATS_ETH_CTRL_CNT); + BUILD_BUG_ON(offsetof(typeof(data->rmon_stats), hist) / sizeof(u64) != + __ETHTOOL_A_STATS_RMON_CNT); + /* Mark all stats as unset (see ETHTOOL_STAT_NOT_SET) to prevent them * from being reported to user space in case driver did not set them. */