Commit bab8eb0d authored by Oliver Neukum's avatar Oliver Neukum Committed by Jakub Kicinski

usbnet: modern method to get random MAC

The driver generates a random MAC once on load
and uses it over and over, including on two devices
needing a random MAC at the same time.

Jakub suggested revamping the driver to the modern
API for setting a random MAC rather than fixing
the old stuff.

The bug is as old as the driver.
Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Link: https://patch.msgid.link/20240829175201.670718-1-oneukum@suse.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent cfd433ce
...@@ -61,9 +61,6 @@ ...@@ -61,9 +61,6 @@
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
// randomly generated ethernet address
static u8 node_id [ETH_ALEN];
/* use ethtool to change the level for any given device */ /* use ethtool to change the level for any given device */
static int msg_level = -1; static int msg_level = -1;
module_param (msg_level, int, 0); module_param (msg_level, int, 0);
...@@ -1725,7 +1722,6 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) ...@@ -1725,7 +1722,6 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
dev->net = net; dev->net = net;
strscpy(net->name, "usb%d", sizeof(net->name)); strscpy(net->name, "usb%d", sizeof(net->name));
eth_hw_addr_set(net, node_id);
/* rx and tx sides can use different message sizes; /* rx and tx sides can use different message sizes;
* bind() should set rx_urb_size in that case. * bind() should set rx_urb_size in that case.
...@@ -1801,9 +1797,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) ...@@ -1801,9 +1797,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
goto out4; goto out4;
} }
/* let userspace know we have a random address */ /* this flags the device for user space */
if (ether_addr_equal(net->dev_addr, node_id)) if (!is_valid_ether_addr(net->dev_addr))
net->addr_assign_type = NET_ADDR_RANDOM; eth_hw_addr_random(net);
if ((dev->driver_info->flags & FLAG_WLAN) != 0) if ((dev->driver_info->flags & FLAG_WLAN) != 0)
SET_NETDEV_DEVTYPE(net, &wlan_type); SET_NETDEV_DEVTYPE(net, &wlan_type);
...@@ -2211,7 +2207,6 @@ static int __init usbnet_init(void) ...@@ -2211,7 +2207,6 @@ static int __init usbnet_init(void)
BUILD_BUG_ON( BUILD_BUG_ON(
sizeof_field(struct sk_buff, cb) < sizeof(struct skb_data)); sizeof_field(struct sk_buff, cb) < sizeof(struct skb_data));
eth_random_addr(node_id);
return 0; return 0;
} }
module_init(usbnet_init); module_init(usbnet_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment