usbnet: use each random address only once
Subsystems (5)
Oliver Neukum
maintainerPATCH 1/1 usbnet: use each random address only once
Even random MACs should be unique to a device.
Get a new one each time it is used.
This bug is as old as the driver.
Signed-off-by Oliver Neukum <[email protected]>
--- drivers/net/usb/usbnet.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/usb/usbnet.c +4 -1
@@ -1797,8 +1797,11 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) }/* let userspace know we have a random address */ -if (ether_addr_equal (net->dev_addr, node_id)) +if (ether_addr_equal (net->dev_addr, node_id)) { net->addr_assign_type =NET_ADDR_RANDOM ; +/* next device needs a new one*/ +eth_random_addr (node_id); + }if ((dev->driver_info->flags &FLAG_WLAN ) !=0 )SET_NETDEV_DEVTYPE (net, &wlan_type);
Signature · 1 line
2.35.3
Jakub Kicinski
maintainerQuoted 17 lines · On Wed, 29 Jun 2022 16:21:49 +0200 Oliver Neukum wrote:
Even random MACs should be unique to a device.
Get a new one each time it is used.This bug is as old as the driver.
Signed-off-by Oliver Neukum <[email protected]>--- drivers/net/usb/usbnet.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/usb/usbnet.c +0
-0@@ -1797,8 +1797,11 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) }
drivers/net/usb/usbnet.c usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) · line 1807
Quoted 10 lines
drivers/net/usb/usbnet.c +4
-1/* let userspace know we have a random address */ -if (ether_addr_equal (net->dev_addr, node_id)) +if (ether_addr_equal (net->dev_addr, node_id)) { net->addr_assign_type =NET_ADDR_RANDOM ; +/* next device needs a new one*/ +eth_random_addr (node_id); + }if ((dev->driver_info->flags &FLAG_WLAN ) !=0 )SET_NETDEV_DEVTYPE (net, &wlan_type);
Why is that node_id thing even there, can we just delete it?
Leave the address as all-zero and check if driver filled it in with:
if (!is_valid_ether_addr(net->dev_addr)) eth_hw_addr_random(net->dev_addr);