netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Jonathan Davies <jonathan.davies@nutanix.com>
Cc: Oliver Neukum <oneukum@suse.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, andrew@lunn.ch
Subject: Re: [PATCH] net: usbnet: allow overriding of default USB interface naming
Date: Mon, 14 Jun 2021 15:51:17 +0200	[thread overview]
Message-ID: <YMde1fN+qIBfCWpD@kroah.com> (raw)
In-Reply-To: <a620bc87-5ee7-6132-6aa0-6b99e1052960@nutanix.com>

On Mon, Jun 14, 2021 at 11:58:57AM +0100, Jonathan Davies wrote:
> On 14/06/2021 10:43, Greg KH wrote:
> > On Mon, Jun 14, 2021 at 10:32:05AM +0100, Jonathan Davies wrote:
> > > On 12/06/2021 08:01, Greg KH wrote:
> > > > On Fri, Jun 11, 2021 at 03:23:39PM +0000, Jonathan Davies wrote:
> > > > > When the predictable device naming scheme for NICs is not in use, it is
> > > > > common for there to be udev rules to rename interfaces to names with
> > > > > prefix "eth".
> > > > > 
> > > > > Since the timing at which USB NICs are discovered is unpredictable, it
> > > > > can be interfere with udev's attempt to rename another interface to
> > > > > "eth0" if a freshly discovered USB interface is initially given the name
> > > > > "eth0".
> > > > > 
> > > > > Hence it is useful to be able to override the default name. A new usbnet
> > > > > module parameter allows this to be configured.
> > > > > 
> > > > > Signed-off-by: Jonathan Davies <jonathan.davies@nutanix.com>
> > > > > Suggested-by: Prashanth Sreenivasa <prashanth.sreenivasa@nutanix.com>
> > > > > ---
> > > > >    drivers/net/usb/usbnet.c | 13 ++++++++++---
> > > > >    1 file changed, 10 insertions(+), 3 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> > > > > index ecf6284..55f6230 100644
> > > > > --- a/drivers/net/usb/usbnet.c
> > > > > +++ b/drivers/net/usb/usbnet.c
> > > > > @@ -72,6 +72,13 @@ static int msg_level = -1;
> > > > >    module_param (msg_level, int, 0);
> > > > >    MODULE_PARM_DESC (msg_level, "Override default message level");
> > > > > +#define DEFAULT_ETH_DEV_NAME "eth%d"
> > > > > +
> > > > > +static char *eth_device_name = DEFAULT_ETH_DEV_NAME;
> > > > > +module_param(eth_device_name, charp, 0644);
> > > > > +MODULE_PARM_DESC(eth_device_name, "Device name pattern for Ethernet devices"
> > > > > +				  " (default: \"" DEFAULT_ETH_DEV_NAME "\")");
> > > > 
> > > > This is not the 1990's, please do not add new module parameters as they
> > > > are on a global driver level, and not on a device level.
> > > 
> > > The initial name is set at probe-time, so the device doesn't exist yet. So I
> > > felt like it was a choice between either changing the hard-coded "eth%d"
> > > string or providing a driver-level module parameter. Is there a better
> > > alternative?
> > 
> > This has always been this way, why is this suddenly an issue?  What
> > changed to cause the way we can name these devices after they have been
> > found like we have been for the past decade+?
> 
> The thing that changed for me was that system-udevd does *not* have the
> backoff and retry logic that traditional versions of udev had.
> 
> Compare implementations of rename_netif in
> https://git.kernel.org/pub/scm/linux/hotplug/udev.git/tree/src/udev-event.c
> (traditional udev, which handles collisions) and
> https://github.com/systemd/systemd/blob/main/src/udev/udev-event.c
> (systemd-udevd, which does not handle collisions).

Then submit a change to add the logic back.  This looks like a userspace
tool breaking existing setups, so please take it up with the developers
of that tool.  The kernel has not changed or "broken" anything here.

> I think this logic was removed under the assumption that users of
> systemd-udevd would also use the predictable device naming scheme, meaning
> renames are guaranteed to not collide with devices being probed.

Why are you not using the predictable device naming scheme?  If you have
multiple network devices in the system, it seems like that is a good
idea to follow as the developers added that for a reason.

> > > > Also changing the way usb network devices are named is up to userspace,
> > > > the kernel should not be involved in this.  What is wrong with just
> > > > renaming it in userspace as you want to today?
> > > 
> > > Yes, renaming devices is the responsibility of userspace. Normally udev will
> > > rename a device shortly after it is probed. But there's a window during
> > > which it has the name the kernel initially assigns. If there's other
> > > renaming activity happening during that window there's a chance of
> > > collisions.
> > > 
> > > Userspace solutions include:
> > >   1. udev backing off and retrying in the event of a collision; or
> > >   2. avoiding ever renaming a device to a name in the "eth%d" namespace.
> > 
> > Picking a different namespace does not cause a lack of collisions to
> > happen, you could have multiple usb network devices being found at the
> > same time, right?
> > 
> > So no matter what, 1) has to happen.
> 
> Within a namespace, the "%d" in "eth%d" means __dev_alloc_name finds a name
> that's not taken. I didn't check the locking but assume that can only happen
> serially, in which case two devices probed in parallel would not mutually
> collide.
> 
> So I don't think it's necessarily true that 1) has to happen.

Multiple USB devices in the system will cause the same exact thing to
happen with your patch, so you still need 1).

thanks

greg k-h

  parent reply	other threads:[~2021-06-14 13:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11 15:23 [PATCH] net: usbnet: allow overriding of default USB interface naming Jonathan Davies
2021-06-11 17:16 ` Andrew Lunn
2021-06-14  9:32   ` Jonathan Davies
2021-06-14 12:40     ` Oliver Neukum
2021-06-12  7:01 ` Greg KH
2021-06-14  9:32   ` Jonathan Davies
2021-06-14  9:43     ` Greg KH
2021-06-14 10:58       ` Jonathan Davies
2021-06-14 12:23         ` Andrew Lunn
2021-06-14 14:53           ` Jonathan Davies
2021-06-14 13:51         ` Greg KH [this message]
2021-06-14 14:53           ` Jonathan Davies
2021-06-14 19:20             ` Jakub Kicinski

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=YMde1fN+qIBfCWpD@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=jonathan.davies@nutanix.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).