net: usb: usbnet: fix name regression
Oliver Neukum
maintainerRFC 1/1 net: usb: usbnet: fix name regression
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
--- drivers/net/usb/usbnet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/usb/usbnet.c +2 -1
@@ -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)))strscpy (net->name,"eth%d" ,sizeof (net->name));/* WLAN devices should always be named "wlan%d" */ if ((dev->driver_info->flags &FLAG_WLAN ) !=0 )
Signature · 1 line
2.47.0
Simon Horman
reviewerQuoted 22 lines · Oliver Neukum
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 withis_zero_ether_addrSigned-off-by Oliver Neukum <[email protected]>Reported-by Greg Thelen <[email protected]>Diagnosed-by John Sperbeck <[email protected]>Fixes bab8eb0dd4cb9 ("usbnet: modern method to get random MAC")--- drivers/net/usb/usbnet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/usb/usbnet.c +0
-0
drivers/net/usb/usbnet.c usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) · line 1771
Quoted 6 lines
drivers/net/usb/usbnet.c +2
-1@@ -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.
Quoted 7 lines
drivers/net/usb/usbnet.c +0
-0strscpy (net->name,"eth%d" ,sizeof (net->name));/* WLAN devices should always be named "wlan%d" */ if ((dev->driver_info->flags &FLAG_WLAN ) !=0 )Signature · 1 line
2.47.0