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] [day] [month] [year] [list]
Message-ID: <20210929235643.GD964074@nvidia.com>
Date:   Wed, 29 Sep 2021 20:56:43 -0300
From:   Jason Gunthorpe <jgg@...dia.com>
To:     Leon Romanovsky <leon@...nel.org>
Cc:     Mark Zhang <markzhang@...dia.com>,
        Doug Ledford <dledford@...hat.com>,
        Aharon Landau <aharonl@...dia.com>,
        "David S. Miller" <davem@...emloft.net>,
        Dennis Dalessandro <dennis.dalessandro@...nelisnetworks.com>,
        Gal Pressman <galpress@...zon.com>,
        Jakub Kicinski <kuba@...nel.org>, linux-kernel@...r.kernel.org,
        linux-rdma@...r.kernel.org, Maor Gottlieb <maorg@...dia.com>,
        Mike Marciniszyn <mike.marciniszyn@...nelisnetworks.com>,
        Mustafa Ismail <mustafa.ismail@...el.com>,
        Naresh Kumar PBS <nareshkumar.pbs@...adcom.com>,
        Neta Ostrovsky <netao@...dia.com>, netdev@...r.kernel.org,
        Potnuri Bharat Teja <bharat@...lsio.com>,
        Saeed Mahameed <saeedm@...dia.com>,
        Selvin Xavier <selvin.xavier@...adcom.com>,
        Shiraz Saleem <shiraz.saleem@...el.com>,
        Yishai Hadas <yishaih@...dia.com>,
        Zhu Yanjun <zyjzyj2000@...il.com>
Subject: Re: [PATCH rdma-next v1 06/11] RDMA/nldev: Add support to get status
 of all counters

On Wed, Sep 29, 2021 at 03:26:25PM +0300, Leon Romanovsky wrote:
> On Tue, Sep 28, 2021 at 08:52:17AM -0300, Jason Gunthorpe wrote:
> > On Tue, Sep 28, 2021 at 05:12:39PM +0800, Mark Zhang wrote:
> > > On 9/28/2021 1:30 AM, Jason Gunthorpe wrote:
> > > > On Wed, Sep 15, 2021 at 02:07:25AM +0300, Leon Romanovsky wrote:
> > > > > +static int stat_get_doit_default_counter(struct sk_buff *skb,
> > > > > +					 struct nlmsghdr *nlh,
> > > > > +					 struct netlink_ext_ack *extack,
> > > > > +					 struct nlattr *tb[])
> > > > > +{
> > > > > +	struct rdma_hw_stats *stats;
> > > > > +	struct ib_device *device;
> > > > > +	u32 index, port;
> > > > > +	int ret;
> > > > > +
> > > > > +	if (!tb[RDMA_NLDEV_ATTR_DEV_INDEX] || !tb[RDMA_NLDEV_ATTR_PORT_INDEX])
> > > > > +		return -EINVAL;
> > > > > +
> > > > > +	index = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]);
> > > > > +	device = ib_device_get_by_index(sock_net(skb->sk), index);
> > > > > +	if (!device)
> > > > > +		return -EINVAL;
> > > > > +
> > > > > +	port = nla_get_u32(tb[RDMA_NLDEV_ATTR_PORT_INDEX]);
> > > > > +	if (!rdma_is_port_valid(device, port)) {
> > > > > +		ret = -EINVAL;
> > > > > +		goto end;
> > > > > +	}
> > > > > +
> > > > > +	stats = ib_get_hw_stats_port(device, port);
> > > > > +	if (!stats) {
> > > > > +		ret = -EINVAL;
> > > > > +		goto end;
> > > > > +	}
> > > > > +
> > > > > +	if (tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_DYNAMIC])
> > > > > +		ret = stat_get_doit_stats_list(skb, nlh, extack, tb,
> > > > > +					       device, port, stats);
> > > > > +	else
> > > > > +		ret = stat_get_doit_stats_values(skb, nlh, extack, tb, device,
> > > > > +						 port, stats);
> > > > 
> > > > This seems strange, why is the output of a get contingent on a ignored
> > > > input attribute? Shouldn't the HWCOUNTER_DYNAMIC just always be
> > > > emitted?
> > > 
> > > The CMD_STAT_GET is originally used to get the default hwcounter statistic
> > > (the value of all hwstats), now we also want to use this command to get a
> > > list of counters (just name and status), so kernel differentiates these 2
> > > cases based on HWCOUNTER_DYNAMIC attr.
> > 
> > Don't do that, it is not how netlink works. Either the whole attribute
> > should be returned or you need a new get command
> 
> The netlink way is to be independent on returned parameter, if it not
> supported, this parameter won't be available at all. This makes HWCOUNTER_DYNAMIC
> to work exactly as netlink would do.

The issue is making the output dependent on the input:

 +	if (tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_DYNAMIC])

Setting HWCOUNTER_DYNAMIC as an input flag to get the GET to return a
completely different output format is not netlinky

Either always return HWCOUNTER_DYNAMIC or make another query to get it

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ