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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230116174234.yzq6cnczs6fxww6q@skbuf>
Date:   Mon, 16 Jan 2023 19:42:34 +0200
From:   Vladimir Oltean <vladimir.oltean@....com>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Paolo Abeni <pabeni@...hat.com>,
        Michal Kubecek <mkubecek@...e.cz>,
        Claudiu Manoil <claudiu.manoil@....com>,
        Vinicius Costa Gomes <vinicius.gomes@...el.com>,
        Xiaoliang Yang <xiaoliang.yang_1@....com>,
        Kurt Kanzenbach <kurt@...utronix.de>,
        Rui Sousa <rui.sousa@....com>,
        Ferenc Fejes <ferenc.fejes@...csson.com>,
        Pranavi Somisetty <pranavi.somisetty@....com>,
        Harini Katakam <harini.katakam@....com>,
        Colin Foster <colin.foster@...advantage.com>,
        UNGLinuxDriver@...rochip.com,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>
Subject: Re: [PATCH v2 net-next 04/12] net: ethtool: netlink: retrieve stats
 from multiple sources (eMAC, pMAC)

On Sun, Jan 15, 2023 at 01:22:14AM +0200, Vladimir Oltean wrote:
> On Fri, Jan 13, 2023 at 08:43:36PM -0800, Jakub Kicinski wrote:
> > On Wed, 11 Jan 2023 18:16:58 +0200 Vladimir Oltean wrote:
> > > +/**
> > > + * enum ethtool_stats_src - source of ethtool statistics
> > > + * @ETHTOOL_STATS_SRC_AGGREGATE:
> > > + *	if device supports a MAC merge layer, this retrieves the aggregate
> > > + *	statistics of the eMAC and pMAC. Otherwise, it retrieves just the
> > > + *	statistics of the single (express) MAC.
> > > + * @ETHTOOL_STATS_SRC_EMAC:
> > > + *	if device supports a MM layer, this retrieves the eMAC statistics.
> > > + *	Otherwise, it retrieves the statistics of the single (express) MAC.
> > > + * @ETHTOOL_STATS_SRC_PMAC:
> > > + *	if device supports a MM layer, this retrieves the pMAC statistics.
> > > + */
> > > +enum ethtool_stats_src {
> > > +	ETHTOOL_STATS_SRC_AGGREGATE,
> > > +	ETHTOOL_STATS_SRC_EMAC,
> > > +	ETHTOOL_STATS_SRC_PMAC,
> > > +};
> > 
> > Should we somehow call it "MAC stats"?
> > 
> > Right now its named like a generic attribute, but it's not part of 
> > the header nest (ETHTOOL_A_HEADER_*).
> > 
> > I'm not sure myself which way is better, but feels like either it
> > should be generic, in the header nest, and parsed by the common code;
> > or named more specifically and stay in the per-cmd attrs.
> 
> Considering that I currently have separate netlink attributes for
> ETHTOOL_MSG_STATS_GET (ETHTOOL_A_STATS_SRC) and for
> ETHTOOL_MSG_PAUSE_GET (ETHTOOL_A_PAUSE_STATS_SRC), I'm going to add just
> a single attribute right under ETHTOOL_A_HEADER_FLAGS for v3 and go from
> there. Is it ok if I keep naming it ETHTOOL_A_STATS_SRC, or would you
> prefer something else?

I'm already lost while trying to implement this change request.

ETHTOOL_A_STATS_HEADER uses NLA_POLICY_NESTED(ethnl_header_policy),
while ETHTOOL_A_PAUSE_HEADER uses NLA_POLICY_NESTED(ethnl_header_policy_stats).

The two header nest policies look like this:

const struct nla_policy ethnl_header_policy[] = {
	[ETHTOOL_A_HEADER_DEV_INDEX]	= { .type = NLA_U32 },
	[ETHTOOL_A_HEADER_DEV_NAME]	= { .type = NLA_NUL_STRING,
					    .len = ALTIFNAMSIZ - 1 },
	[ETHTOOL_A_HEADER_FLAGS]	= NLA_POLICY_MASK(NLA_U32,
							  ETHTOOL_FLAGS_BASIC),
};

const struct nla_policy ethnl_header_policy_stats[] = {
	[ETHTOOL_A_HEADER_DEV_INDEX]	= { .type = NLA_U32 },
	[ETHTOOL_A_HEADER_DEV_NAME]	= { .type = NLA_NUL_STRING,
					    .len = ALTIFNAMSIZ - 1 },
	[ETHTOOL_A_HEADER_FLAGS]	= NLA_POLICY_MASK(NLA_U32,
							  ETHTOOL_FLAGS_STATS),
};

The request seems to be for ETHTOOL_A_PAUSE_HEADER to use a policy like this:

 const struct nla_policy ethnl_header_policy_mac_stats[] = {
 	[ETHTOOL_A_HEADER_DEV_INDEX]	= { .type = NLA_U32 },
 	[ETHTOOL_A_HEADER_DEV_NAME]	= { .type = NLA_NUL_STRING,
 					    .len = ALTIFNAMSIZ - 1 },
 	[ETHTOOL_A_HEADER_FLAGS]	= NLA_POLICY_MASK(NLA_U32,
 							  ETHTOOL_FLAGS_STATS),
+	[ETHTOOL_A_HEADER_MAC_STATS_SRC] = NLA_POLICY_MASK(NLA_U32,
+							   ETHTOOL_MAC_STATS_SRC_PMAC),
 };

and for ETHTOOL_A_STATS_HEADER to use a policy like this:

const struct nla_policy ethnl_header_policy_mac_stats_src_basic[] = {
	[ETHTOOL_A_HEADER_DEV_INDEX]	= { .type = NLA_U32 },
	[ETHTOOL_A_HEADER_DEV_NAME]	= { .type = NLA_NUL_STRING,
					    .len = ALTIFNAMSIZ - 1 },
	[ETHTOOL_A_HEADER_FLAGS]	= NLA_POLICY_MASK(NLA_U32,
							  ETHTOOL_FLAGS_BASIC),
+	[ETHTOOL_A_HEADER_MAC_STATS_SRC] = NLA_POLICY_MASK(NLA_U32,
+							   ETHTOOL_MAC_STATS_SRC_PMAC),
};

Did I get this right?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ