lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <DB7T1297UN2E.20SHSTO9HWDMU@gmail.com>
Date: Thu, 10 Jul 2025 05:25:07 +0900
From: "Yeounsu Moon" <yyyynoom@...il.com>
To: "Andrew Lunn" <andrew@...n.ch>, "David S. Miller" <davem@...emloft.net>,
 "Eric Dumazet" <edumazet@...gle.com>, "Jakub Kicinski" <kuba@...nel.org>,
 "Paolo Abeni" <pabeni@...hat.com>
Cc: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [RFC] On macro usage for ethtool stats across netdev drivers

While working on "[PATCH net-next v2] net: dlink: add support for
reporting stats via 'ethtool -S'", I received the following feedback from
Jakub:
>> +	DEFINE_RMON_STATS(rmon_rx_byte_512to1203,
>> +			  EtherStatsPkts512to1023Octets, hist[4]),
>> +	DEFINE_RMON_STATS(rmon_tx_byte_1204to1518,
>> +			  EtherStatsPkts1024to1518OctetsTransmit, hist_tx[5]),
>> +	DEFINE_RMON_STATS(rmon_rx_byte_1204to1518,
>> +			  EtherStatsPkts1024to1518Octets, hist[5])
>> +};
>>
> Do these macro wrappers really buy you anything? They make the code a lot harder to follow :(

I understand that such macro usage can reduce readability, as Jakub
pointed out. That said, this style is also seen in several other network
drivers (e.g. `intel/e1000e/ethtool.c`, `broadcom/bnxt/bnxt_ethtool.c`),
and I initially followed this approach to keep things consistent and
reduce boilerplate.

Given these differing perspectives, I'd like to raise the following
question: Is there a general consensus on the use of macro wrappers in
netdev drivers, particularly for `ethtool` stats? Is it encouraged,
discouraged, or left to the discretion of each driver maintainer?

I've seen this pattern in several existing drivers, so I'm wondering if
it was considered acceptable in the past, but has since fallen out of
favor in current developement practices.

Link: https://lore.kernel.org/netdev/20241107200940.4dff026d@kernel.org/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ