diff mbox series

r8152: Set NET_ADDR_STOLEN if using passthru MAC

Message ID 20240605153340.25694-1-gmazyland@gmail.com
State New
Headers show
Series r8152: Set NET_ADDR_STOLEN if using passthru MAC | expand

Commit Message

Milan Broz June 5, 2024, 3:33 p.m. UTC
Some docks support MAC pass-through - MAC address
is taken from another device.

Driver should indicate that with NET_ADDR_STOLEN flag.

This should help to avoid collisions if network interface
names are generated with MAC policy.

Reported and discussed here
https://github.com/systemd/systemd/issues/33104

Signed-off-by: Milan Broz <gmazyland@gmail.com>
---
 drivers/net/usb/r8152.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andrew Lunn June 5, 2024, 4:39 p.m. UTC | #1
On Wed, Jun 05, 2024 at 05:33:40PM +0200, Milan Broz wrote:
> Some docks support MAC pass-through - MAC address
> is taken from another device.
> 
> Driver should indicate that with NET_ADDR_STOLEN flag.
> 
> This should help to avoid collisions if network interface
> names are generated with MAC policy.
> 
> Reported and discussed here
> https://github.com/systemd/systemd/issues/33104

MAC pass-through is broken, and expected to cause problems. We
strongly push back on any patches trying to add more instances of
it.

Ideally it needs to be done in user space where you have full access
to the tree of devices, can determine if the device getting the MAC
address really is in a dock, is the first dock in a chain of docks,
and not a USB dongle etc.

Using NET_ADDR_STOLEN is interesting. It is currently used in bonding,
when the bond device takes the MAC address from one of its slaves. It
is also used with VLAN interfaces, which inherit the MAC address of
the base interface. There is a clear relationship between the two
interfaces using the same MAC address. However in the pass through
case, the interfaces are unrelated.

However, the code says:

#define NET_ADDR_STOLEN		2	/* address is stolen from other device */

which is exactly what is happening here.

> Signed-off-by: Milan Broz <gmazyland@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
patchwork-bot+netdevbpf@kernel.org June 7, 2024, 1:10 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  5 Jun 2024 17:33:40 +0200 you wrote:
> Some docks support MAC pass-through - MAC address
> is taken from another device.
> 
> Driver should indicate that with NET_ADDR_STOLEN flag.
> 
> This should help to avoid collisions if network interface
> names are generated with MAC policy.
> 
> [...]

Here is the summary with links:
  - r8152: Set NET_ADDR_STOLEN if using passthru MAC
    https://git.kernel.org/netdev/net-next/c/cb6cf0820f22

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 19df1cd9f072..ea5c5be4a958 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1774,6 +1774,7 @@  static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
 		goto amacout;
 	}
 	memcpy(sa->sa_data, buf, 6);
+	tp->netdev->addr_assign_type = NET_ADDR_STOLEN;
 	netif_info(tp, probe, tp->netdev,
 		   "Using pass-thru MAC addr %pM\n", sa->sa_data);