All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>
Cc: Arseny Maslennikov <ar@cs.msu.ru>,
	linux-rdma@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca>,
	netdev@vger.kernel.org
Subject: Re: [PATCH v3 3/3] IB/ipoib: Log sysfs 'dev_id' accesses from userspace
Date: Fri, 7 Sep 2018 20:28:21 +0300	[thread overview]
Message-ID: <20180907172821.GS3142@mtr-leonro.mtl.com> (raw)
In-Reply-To: <adc47601cbf388f7909bc01dd3b122d6558cc74e.camel@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4338 bytes --]

On Fri, Sep 07, 2018 at 01:14:37PM -0400, Doug Ledford wrote:
> On Thu, 2018-09-06 at 16:03 +0300, Leon Romanovsky wrote:
> > On Thu, Sep 06, 2018 at 10:04:33AM +0300, Arseny Maslennikov wrote:
> > > On Wed, Sep 05, 2018 at 04:50:35PM +0300, Leon Romanovsky wrote:
> > > > On Mon, Sep 03, 2018 at 07:13:16PM +0300, Arseny Maslennikov wrote:
> > > > > Signed-off-by: Arseny Maslennikov <ar@cs.msu.ru>
> > > > > ---
> > > > >  drivers/infiniband/ulp/ipoib/ipoib_main.c | 38 +++++++++++++++++++++++
> > > > >  1 file changed, 38 insertions(+)
> > > > >
> > > > > diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> > > > > index 30f840f874b3..7386e5bde3d3 100644
> > > > > --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
> > > > > +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> > > > > @@ -2386,6 +2386,42 @@ int ipoib_add_pkey_attr(struct net_device *dev)
> > > > >  	return device_create_file(&dev->dev, &dev_attr_pkey);
> > > > >  }
> > > > >
> > > > > +/*
> > > > > + * We erroneously exposed the iface's port number in the dev_id
> > > > > + * sysfs field long after dev_port was introduced for that purpose[1],
> > > > > + * and we need to stop everyone from relying on that.
> > > > > + * Let's overload the shower routine for the dev_id file here
> > > > > + * to gently bring the issue up.
> > > > > + *
> > > > > + * [1] https://www.spinics.net/lists/netdev/msg272123.html
> > > > > + */
> > > > > +static ssize_t dev_id_show(struct device *dev,
> > > > > +			   struct device_attribute *attr, char *buf)
> > > > > +{
> > > > > +	struct net_device *ndev = to_net_dev(dev);
> > > > > +	ssize_t ret = -EINVAL;
> > > > > +
> > > > > +	if (ndev->dev_id == ndev->dev_port) {
> > > > > +		netdev_info_once(ndev,
> > > > > +			"\"%s\" wants to know my dev_id. "
> > > > > +			"Should it look at dev_port instead?\n",
> > > > > +			current->comm);
> > > > > +		netdev_info_once(ndev,
> > > > > +			"See Documentation/ABI/testing/sysfs-class-net for more info.\n");
> > > > > +	}
> > > > > +
> > > > > +	ret = sprintf(buf, "%#x\n", ndev->dev_id);
> > > > > +
> > > > > +	return ret;
> > > > > +}
> > > > > +static DEVICE_ATTR_RO(dev_id);
> > > > > +
> > > >
> > > > I don't see this field among exposed by IPoIB, why should we expose it now?
> > > >
> > >
> > > To deviate from standard netdev behaviour, which only prints the
> > > field out. Doug wanted this to also print a deprecation message, and
> > > netdev (obviously) does not do that. See below.
> > >
> > > > > +int ipoib_intercept_dev_id_attr(struct net_device *dev)
> > > > > +{
> > > > > +	device_remove_file(&dev->dev, &dev_attr_dev_id);
> > > > > +	return device_create_file(&dev->dev, &dev_attr_dev_id);
> > > >
> > > > Why isn't enough to rely on netdev code?
> > > >
> > >
> > > Netdev code relies on macros around a *static* function 'netdev_show',
> > > which is defined in net/core/net-sysfs.c; it is not listed in any header
> > > files, and the macros aren't as well. This all leads me to believe it
> > > was not really meant to be used from outside net/core/net-sysfs.
> > >
> > > The only way we could use any netdev code here is to set up our own
> > > handler (again), printk() a message, then call netdev_show — but we have
> > > no access to it.
> > >
> > > Of course, it also may be that I'm terribly missing a clue.
> >
> > Thanks,
> >
> > IMHO, the end result of adequate Doug's request is a little bit too much.
> > I don't think that it justifies such remove->create construction.
> >
> > Personal opinion.
>
> I agree with you that the end result is kinda bulky, *but*, we will need
> to know if there are things using the old dev_id before we can remove
> it.  In particular, I'm concerned the IPoIB handling code of
> NetworkManager uses it.  It's worth the cost I think.

I did my checks now and saw that ibdev2netdev uses the value provided
from this dev_id, so every invocation of that script will generate the
warning.

See this line in Parav's repo
https://github.com/Mellanox/container_scripts/blob/master/ibdev2netdev#L112

Thanks

>
> --
> Doug Ledford <dledford@redhat.com>
>     GPG KeyID: B826A3330E572FDD
>     Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

  reply	other threads:[~2018-09-07 17:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03 16:13 [PATCH v3 0/3] IB/ipoib: Use dev_port to disambiguate port numbers Arseny Maslennikov
2018-09-03 16:13 ` [PATCH v3 1/3] Documentation/ABI: document /sys/class/net/*/dev_port Arseny Maslennikov
2018-09-03 16:13 ` [PATCH v3 2/3] IB/ipoib: Use dev_port to expose network interface port numbers Arseny Maslennikov
2018-09-05 13:41   ` Leon Romanovsky
2018-09-03 16:13 ` [PATCH v3 3/3] IB/ipoib: Log sysfs 'dev_id' accesses from userspace Arseny Maslennikov
2018-09-05 13:50   ` Leon Romanovsky
2018-09-06  7:04     ` Arseny Maslennikov
2018-09-06 13:03       ` Leon Romanovsky
2018-09-07 17:14         ` Doug Ledford
2018-09-07 17:28           ` Leon Romanovsky [this message]
2018-09-07 20:02             ` Doug Ledford
2018-09-05 15:47   ` Stephen Hemminger
2018-09-06  7:26     ` Arseny Maslennikov
2018-09-06 12:56       ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180907172821.GS3142@mtr-leonro.mtl.com \
    --to=leon@kernel.org \
    --cc=ar@cs.msu.ru \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.