Re: [PATCH] net: usb: usbnet: restore usb%d name exception for local mac addresses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 03, 2024 at 10:04:55PM +0900, Dominique Martinet wrote:
> From: Dominique Martinet <dominique.martinet@xxxxxxxxxxxxxxxxx>
> 
> The previous commit assumed that local addresses always came from the
> kernel, but some devices hand out local mac addresses so we ended up
> with point-to-point devices with a mac set by the driver, renaming to
> eth%d when they used to be named usb%d.
> 
> Userspace should not rely on device name, but for the sake of stability
> restore the local mac address check portion of the naming exception:
> point to point devices which either have no mac set by the driver or
> have a local mac handed out by the driver will keep the usb%d name.
> 
> Fixes: 8a7d12d674ac ("net: usb: usbnet: fix name regression")
> Signed-off-by: Dominique Martinet <dominique.martinet@xxxxxxxxxxxxxxxxx>
> ---
>  drivers/net/usb/usbnet.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index 44179f4e807f..d044dc7b7622 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -178,6 +178,17 @@ int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
>  }
>  EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
>  
> +static bool usbnet_needs_usb_name_format(struct usbnet *dev, struct net_device *net)
> +{
> +	/* Point to point devices which don't have a real MAC address
> +	 * (or report a fake local one) have historically used the usb%d
> +	 * naming. Preserve this..
> +	 */
> +	return (dev->driver_info->flags & FLAG_POINTTOPOINT) != 0 &&
> +		(is_zero_ether_addr(net->dev_addr) ||
> +		 is_local_ether_addr(net->dev_addr));
> +}
> +
>  static void intr_complete (struct urb *urb)
>  {
>  	struct usbnet	*dev = urb->context;
> @@ -1762,13 +1773,10 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
>  		if (status < 0)
>  			goto out1;
>  
> -		// heuristic:  "usb%d" for links we know are two-host,
> -		// else "eth%d" when there's reasonable doubt.  userspace
> -		// can rename the link if it knows better.
> +		/* heuristic: rename to "eth%d" if we are not sure this link
> +		 * is two-host (these links keep "usb%d") */
>  		if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
> -		    ((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 ||
> -		     /* somebody touched it*/
> -		     !is_zero_ether_addr(net->dev_addr)))
> +		    !usbnet_needs_usb_name_format(dev, net))
>  			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
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux