netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Oliver Neukum <oneukum@suse.com>
Cc: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, Greg Thelen <gthelen@google.com>,
	John Sperbeck <jsperbeck@google.com>
Subject: Re: [RFC] net: usb: usbnet: fix name regression
Date: Thu, 17 Oct 2024 14:44:13 +0100	[thread overview]
Message-ID: <20241017134413.GL1697@kernel.org> (raw)
In-Reply-To: <20241015140442.247752-1-oneukum@suse.com>

On Tue, Oct 15, 2024 at 04:03:32PM +0200, Oliver Neukum wrote:
> The fix for MAC addresses broke detection of the naming convention
> because it gave network devices no random MAC before bind()
> was called. This means that the check for the local assignment bit
> was always negative as the address was zeroed from allocation,
> instead of from overwriting the MAC with a unique hardware address.
> 
> The correct check for whether bind() has altered the MAC is
> done with is_zero_ether_addr
> 
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
> Reported-by: Greg Thelen <gthelen@google.com>
> Diagnosed-by: John Sperbeck <jsperbeck@google.com>
> Fixes: bab8eb0dd4cb9 ("usbnet: modern method to get random MAC")
> ---
>  drivers/net/usb/usbnet.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index ee1b5fd7b491..44179f4e807f 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -1767,7 +1767,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
>  		// can rename the link if it knows better.
>  		if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
>  		    ((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 ||
> -		     (net->dev_addr [0] & 0x02) == 0))
> +		     /* somebody touched it*/
> +		     !is_zero_ether_addr(net->dev_addr)))

Hi Oliver,

I think works for the case where a random address will be assigned
as per the cited commit. But I'm unsure that is correct wrt
to the case where ->bind assigns an address with 0x2 set in the 0th octet.

Can that occur in practice? Perhaps not because the driver would
rely on usbnet_probe() to set a random address. But if so then
it would previously have hit the "eth%d" logic, but does not anymore.

>  			strscpy(net->name, "eth%d", sizeof(net->name));
>  		/* WLAN devices should always be named "wlan%d" */
>  		if ((dev->driver_info->flags & FLAG_WLAN) != 0)
> -- 
> 2.47.0
> 
> 

      reply	other threads:[~2024-10-17 13:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-15 14:03 [RFC] net: usb: usbnet: fix name regression Oliver Neukum
2024-10-17 13:44 ` Simon Horman [this message]

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=20241017134413.GL1697@kernel.org \
    --to=horms@kernel.org \
    --cc=edumazet@google.com \
    --cc=gthelen@google.com \
    --cc=jsperbeck@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=pabeni@redhat.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).