Skip to content

Commit d6f000c

Browse files
martinetdvijay-suman
authored andcommitted
net: usb: usbnet: restore usb%d name exception for local mac addresses
commit 2ea396448f26d0d7d66224cb56500a6789c7ed07 upstream. commit 8a7d12d ("net: usb: usbnet: fix name regression") 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. (some USB LTE modems are known to hand out a stable mac from the locally administered range; that mac appears to be random (different for mulitple devices) and can be reset with device-specific commands, so while such devices would benefit from getting a OUI reserved, we have to deal with these and might as well preserve the existing behavior to avoid breaking fragile openwrt configurations and such on upgrade.) Link: https://lkml.kernel.org/r/[email protected] Fixes: 8a7d12d ("net: usb: usbnet: fix name regression") Cc: [email protected] Tested-by: Ahmed Naseef <[email protected]> Signed-off-by: Dominique Martinet <[email protected]> Acked-by: Oliver Neukum <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit df594b4bf294b778acceb2f81e3e0aac29038e42) FOF: 0525 Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 98c6a7a commit d6f000c

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drivers/net/usb/usbnet.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
181181
}
182182
EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
183183

184+
static bool usbnet_needs_usb_name_format(struct usbnet *dev, struct net_device *net)
185+
{
186+
/* Point to point devices which don't have a real MAC address
187+
* (or report a fake local one) have historically used the usb%d
188+
* naming. Preserve this..
189+
*/
190+
return (dev->driver_info->flags & FLAG_POINTTOPOINT) != 0 &&
191+
(is_zero_ether_addr(net->dev_addr) ||
192+
is_local_ether_addr(net->dev_addr));
193+
}
194+
184195
static void intr_complete (struct urb *urb)
185196
{
186197
struct usbnet *dev = urb->context;
@@ -1764,13 +1775,11 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
17641775
if (status < 0)
17651776
goto out1;
17661777

1767-
// heuristic: "usb%d" for links we know are two-host,
1768-
// else "eth%d" when there's reasonable doubt. userspace
1769-
// can rename the link if it knows better.
1778+
/* heuristic: rename to "eth%d" if we are not sure this link
1779+
* is two-host (these links keep "usb%d")
1780+
*/
17701781
if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
1771-
((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 ||
1772-
/* somebody touched it*/
1773-
!is_zero_ether_addr(net->dev_addr)))
1782+
!usbnet_needs_usb_name_format(dev, net))
17741783
strscpy(net->name, "eth%d", sizeof(net->name));
17751784
/* WLAN devices should always be named "wlan%d" */
17761785
if ((dev->driver_info->flags & FLAG_WLAN) != 0)

0 commit comments

Comments
 (0)