All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: usb: r8152: Check used MAC passthrough address
@ 2022-01-05  6:17 Aaron Ma
  2022-01-05  7:23 ` Henning Schild
  0 siblings, 1 reply; 13+ messages in thread
From: Aaron Ma @ 2022-01-05  6:17 UTC (permalink / raw)
  To: aaron.ma, kuba, henning.schild, linux-usb, netdev, linux-kernel
  Cc: davem, hayeswang, tiwai

When plugin multiple r8152 ethernet dongles to Lenovo Docks
or USB hub, MAC passthrough address from BIOS should be
checked if it had been used to avoid using on other dongles.

Currently builtin r8152 on Dock still can't be identified.
First detected r8152 will use the MAC passthrough address.

Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
---
 drivers/net/usb/r8152.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index f9877a3e83ac..77f11b3f847b 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1605,6 +1605,7 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
 	char *mac_obj_name;
 	acpi_object_type mac_obj_type;
 	int mac_strlen;
+	struct net_device *ndev;
 
 	if (tp->lenovo_macpassthru) {
 		mac_obj_name = "\\MACA";
@@ -1662,6 +1663,15 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
 		ret = -EINVAL;
 		goto amacout;
 	}
+	rcu_read_lock();
+	for_each_netdev_rcu(&init_net, ndev) {
+		if (strncmp(buf, ndev->dev_addr, 6) == 0) {
+			rcu_read_unlock();
+			goto amacout;
+		}
+	}
+	rcu_read_unlock();
+
 	memcpy(sa->sa_data, buf, 6);
 	netif_info(tp, probe, tp->netdev,
 		   "Using pass-thru MAC addr %pM\n", sa->sa_data);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-01-05 20:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05  6:17 [PATCH] net: usb: r8152: Check used MAC passthrough address Aaron Ma
2022-01-05  7:23 ` Henning Schild
2022-01-05  7:32   ` Henning Schild
2022-01-05  7:38     ` Aaron Ma
2022-01-05  7:55       ` Henning Schild
2022-01-05  8:01         ` Aaron Ma
2022-01-05  8:32           ` Henning Schild
2022-01-05  8:37             ` Aaron Ma
2022-01-05  8:47               ` Henning Schild
2022-01-05  8:54                 ` Aaron Ma
2022-01-05 10:40                 ` Henning Schild
2022-01-05 19:55               ` Florian Fainelli
2022-01-05 20:57                 ` Henning Schild

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.