Skip to content

Commit 2beb999

Browse files
martinetdgregkh
authored andcommitted
net: usb: usbnet: restore usb%d name exception for local mac addresses
commit 2ea3964 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/20241203130457.904325-1-asmadeus@codewreck.org Fixes: 8a7d12d ("net: usb: usbnet: fix name regression") Cc: stable@vger.kernel.org Tested-by: Ahmed Naseef <naseefkm@gmail.com> Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> Acked-by: Oliver Neukum <oneukum@suse.com> Link: https://patch.msgid.link/20250326-usbnet_rename-v2-1-57eb21fcff26@atmark-techno.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3007115 commit 2beb999

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

drivers/net/usb/usbnet.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
178178
}
179179
EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
180180

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

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

0 commit comments

Comments
 (0)