net: usb: r8152: Check used MAC passthrough address
Subsystems (4)
PATCH 1/1 net: usb: r8152: Check used MAC passthrough address
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.
--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/usb/r8152.c +10 -0
@@ -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);
Signature · 1 line
2.30.2
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:
Quoted 25 lines
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 <[email protected]>--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/usb/r8152.c +1
-0@@ -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" ;
drivers/net/usb/r8152.c static int · line 1670
Quoted 8 lines
drivers/net/usb/r8152.c +5
-0@@ -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;
Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess a strncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME)) is needed as well.
Maybe leave here withnetif_info()
And move the whole block up, we can skip the whole ACPI story if we find the MAC busy.
drivers/net/usb/r8152.c static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) · line 1673
Quoted 3 lines
drivers/net/usb/r8152.c +3
-0+ } + } +rcu_read_unlock ();
Not sure if this function is guaranteed to only run once at a time, otherwise i think that is a race. Multiple instances could make it to this very point at the same time.
Henning
Quoted 3 lines
drivers/net/usb/r8152.c +0
-0memcpy (sa->sa_data, buf,6 );netif_info (tp, probe, tp->netdev,"Using pass-thru MAC addr %pM\n" , sa->sa_data);
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:
Quoted 47 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 25 lines
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 <[email protected]>--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/usb/r8152.c +0
-0@@ -1605,6 +1605,7 @@ static int
vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)char*mac_obj_name;acpi_object_typemac_obj_type;drivers/net/usb/r8152.c +1
-0int mac_strlen; +struct net_device *ndev;if (tp->lenovo_macpassthru) { mac_obj_name ="\\MACA" ;drivers/net/usb/r8152.c static int · line 1670
Quoted 8 lines
drivers/net/usb/r8152.c +5
-0@@ -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;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.
Quoted 5 lines
Maybe leave here with
netif_info()And move the whole block up, we can skip the whole ACPI story if we find the MAC busy.
That is wrong, need to know that MAC so can not move up too much. But maybe above the is_valid_ether_addr
Henning
Quoted 15 lines
drivers/net/usb/r8152.c static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) · line 1673
Quoted 3 lines
drivers/net/usb/r8152.c +3
-0+ } + } +rcu_read_unlock ();Not sure if this function is guaranteed to only run once at a time, otherwise i think that is a race. Multiple instances could make it to this very point at the same time.
Henning
Quoted 4 lines
drivers/net/usb/r8152.c +0
-0memcpy (sa->sa_data, buf,6 );netif_info (tp, probe, tp->netdev,"Using pass-thru MAC addr %pM\n" , sa->sa_data);
Quoted 8 lines · Henning Schild
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:Quoted 5 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Sure, I will do it.
Quoted 34 lines
Quoted 34 lines
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 31 lines
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 <[email protected]>--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/usb/r8152.c +0
-0@@ -1605,6 +1605,7 @@ static int
vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)char*mac_obj_name;acpi_object_typemac_obj_type;
intmac_strlen;drivers/net/usb/r8152.c +4
-0+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 ) {
Quoted 8 lines
Quoted 8 lines
drivers/net/usb/r8152.c static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) · line 1670
Quoted 2 lines
drivers/net/usb/r8152.c +2
-0+rcu_read_unlock (); + goto amacout;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.
PCI ethernet could be a builtin one on dock since there will be TBT4 dock.
Quoted 3 lines
Quoted 3 lines
Maybe leave here with
netif_info()
Not good to print in rcu lock.
Quoted 5 lines
Quoted 2 lines
And move the whole block up, we can skip the whole ACPI story if we find the MAC busy.
That is wrong, need to know that MAC so can not move up too much. But maybe above the
is_valid_ether_addr
The MAC passthough address is read from ACPI.
ACPI read only happens once during r8152 driver probe. To keep the lock less time, do it after is_valid_ether_addr.
Quoted 11 lines
Henning
Quoted 8 lines
drivers/net/usb/r8152.c static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) · line 1673
Quoted 3 lines
drivers/net/usb/r8152.c +3
-0+ } + } +rcu_read_unlock ();Not sure if this function is guaranteed to only run once at a time, otherwise i think that is a race. Multiple instances could make it to this very point at the same time.
Run once for one device.
So add a safe lock.
Aaron
Quoted 8 lines
Quoted 7 lines
Henning
Quoted 4 lines
drivers/net/usb/r8152.c +0
-0memcpy (sa->sa_data, buf,6 );netif_info (tp, probe, tp->netdev,"Using pass-thru MAC addr %pM\n" , sa->sa_data);
Am Wed, 5 Jan 2022 15:38:51 +0800
schrieb Aaron Ma <[email protected]>:
Quoted 55 lines · Henning Schild
Quoted 8 lines
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:Quoted 5 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Sure, I will do it.
Quoted 34 lines
Quoted 34 lines
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 31 lines
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 <[email protected]>--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/usb/r8152.c +0
-0@@ -1605,6 +1605,7 @@ static int
vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)char*mac_obj_name;acpi_object_typemac_obj_type;
intmac_strlen;drivers/net/usb/r8152.c +1
-0+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;
}drivers/net/usb/r8152.c +3
-0+rcu_read_lock (); +for_each_netdev_rcu (&init_net, ndev) { +if (strncmp (buf, ndev->dev_addr,6 ) ==0 ) {Quoted 8 lines
Quoted 8 lines
drivers/net/usb/r8152.c static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) · line 1670
Quoted 2 lines
drivers/net/usb/r8152.c +2
-0+rcu_read_unlock (); + goto amacout;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.
Quoted 2 lines
PCI ethernet could be a builtin one on dock since there will be TBT4 dock.
In my X280 there is a PCI device in the laptop, always there. And its MAC is the one found in ACPI. Did not try but i think for such devices there would never be inheritance even if one wanted and used a Lenovo dock that is supposed to do it.
Maybe i should try the patch but it seems like it defeats inheritance completely. Well depending on probe order ...
regards,
Henning
Quoted 41 lines
Quoted 3 lines
Quoted 3 lines
Maybe leave here with
netif_info()Not good to print in rcu lock.
Quoted 5 lines
Quoted 2 lines
And move the whole block up, we can skip the whole ACPI story if we find the MAC busy.
That is wrong, need to know that MAC so can not move up too much. But maybe above the
is_valid_ether_addrThe MAC passthough address is read from ACPI.
ACPI read only happens once during r8152 driver probe. To keep the lock less time, do it afteris_valid_ether_addr.Quoted 11 lines
Henning
Quoted 8 lines
drivers/net/usb/r8152.c static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) · line 1673
Quoted 3 lines
drivers/net/usb/r8152.c +3
-0+ } + } +rcu_read_unlock ();Not sure if this function is guaranteed to only run once at a time, otherwise i think that is a race. Multiple instances could make it to this very point at the same time.
Run once for one device.
So add a safe lock.Aaron
Quoted 8 lines
Quoted 7 lines
Henning
Quoted 4 lines
memcpy(sa->sa_data, buf, 6); netif_info(tp, probe,tp->netdev,
"Using pass-thru MAC addr %pM\n",sa->sa_data);
Quoted 58 lines · Henning Schild
Am Wed, 5 Jan 2022 15:38:51 +0800
schrieb Aaron Ma <[email protected]>:Quoted 55 lines · Henning Schild
Quoted 8 lines
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:Quoted 5 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Sure, I will do it.
Quoted 42 lines
Quoted 42 lines
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 28 lines
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 <[email protected]>--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/usb/r8152.c +0
-0@@ -1605,6 +1605,7 @@ static intvendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr
*sa) char *mac_obj_name; acpi_object_type mac_obj_type; int mac_strlen;drivers/net/usb/r8152.c +1
-0+struct net_device *ndev;if (tp->lenovo_macpassthru) { mac_obj_name ="\\MACA" ;@@ -1662,6 +1663,15 @@ static intvendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr
*sa) ret = -EINVAL; goto amacout; }drivers/net/usb/r8152.c static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) · line 1670
Quoted 5 lines
drivers/net/usb/r8152.c +5
-0+rcu_read_lock (); +for_each_netdev_rcu (&init_net, ndev) { +if (strncmp (buf, ndev->dev_addr,6 ) ==0 ) { +rcu_read_unlock (); + goto amacout;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.
Quoted 8 lines
Quoted 2 lines
PCI ethernet could be a builtin one on dock since there will be TBT4 dock.
In my X280 there is a PCI device in the laptop, always there. And its MAC is the one found in ACPI. Did not try but i think for such devices there would never be inheritance even if one wanted and used a Lenovo dock that is supposed to do it.
There will more TBT4 docks in market, the new ethernet is just the same as PCI device, connected by thunderbolt.
For exmaple, connect a TBT4 dock which uses i225 pcie base ethernet, then connect another TBT3 dock which uses r8152.
If skip PCI check, then i225 and r8152 will use the same MAC.
Aaron
Quoted 49 lines
Maybe i should try the patch but it seems like it defeats inheritance completely. Well depending on probe order ...
regards,
HenningQuoted 41 lines
Quoted 3 lines
Quoted 3 lines
Maybe leave here with
netif_info()Not good to print in rcu lock.
Quoted 5 lines
Quoted 2 lines
And move the whole block up, we can skip the whole ACPI story if we find the MAC busy.
That is wrong, need to know that MAC so can not move up too much. But maybe above the
is_valid_ether_addrThe MAC passthough address is read from ACPI.
ACPI read only happens once during r8152 driver probe. To keep the lock less time, do it afteris_valid_ether_addr.Quoted 11 lines
Henning
Quoted 8 lines
drivers/net/usb/r8152.c static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) · line 1673
Quoted 3 lines
drivers/net/usb/r8152.c +3
-0+ } + } +rcu_read_unlock ();Not sure if this function is guaranteed to only run once at a time, otherwise i think that is a race. Multiple instances could make it to this very point at the same time.
Run once for one device.
So add a safe lock.Aaron
Quoted 8 lines
Quoted 7 lines
Henning
Quoted 4 lines
memcpy(sa->sa_data, buf, 6); netif_info(tp, probe, tp->netdev, "Using pass-thru MAC addr %pM\n",
sa->sa_data);
Am Wed, 5 Jan 2022 16:01:24 +0800
schrieb Aaron Ma <[email protected]>:
Quoted 68 lines · Henning Schild
Quoted 58 lines
Am Wed, 5 Jan 2022 15:38:51 +0800
schrieb Aaron Ma <[email protected]>:Quoted 55 lines · Henning Schild
Quoted 8 lines
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:Quoted 5 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Sure, I will do it.
Quoted 42 lines
Quoted 42 lines
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 28 lines
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 <[email protected]>--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/usb/r8152.c +0
-0@@ -1605,6 +1605,7 @@ static intvendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr
*sa) char *mac_obj_name; acpi_object_type mac_obj_type; int mac_strlen;drivers/net/usb/r8152.c +1
-0+struct net_device *ndev;if (tp->lenovo_macpassthru) { mac_obj_name ="\\MACA" ;@@ -1662,6 +1663,15 @@ static intvendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr
*sa) ret = -EINVAL; goto amacout; }drivers/net/usb/r8152.c static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) · line 1670
Quoted 5 lines
drivers/net/usb/r8152.c +5
-0+rcu_read_lock (); +for_each_netdev_rcu (&init_net, ndev) { +if (strncmp (buf, ndev->dev_addr,6 ) ==0 ) { +rcu_read_unlock (); + goto amacout;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.Quoted 8 lines
Quoted 2 lines
PCI ethernet could be a builtin one on dock since there will be TBT4 dock.
In my X280 there is a PCI device in the laptop, always there. And its MAC is the one found in ACPI. Did not try but i think for such devices there would never be inheritance even if one wanted and used a Lenovo dock that is supposed to do it.
Quoted 6 lines
There will more TBT4 docks in market, the new ethernet is just the same as PCI device, connected by thunderbolt.
For exmaple, connect a TBT4 dock which uses i225 pcie base ethernet, then connect another TBT3 dock which uses r8152.
If skip PCI check, then i225 and r8152 will use the same MAC.
In current 5.15 i have that sort of collision already. All r8152s will happily grab the MAC of the I219. In fact i have only ever seen it with one r8152 at a time but while the I219 was actively in use. While this patch will probably solve that, i bet it would defeat MAC pass-thru altogether. Even when turned on in the BIOS.
Or does that iterator take "up"/"down" state into consideration? But even if, the I219 could become "up" any time later.
These collisions are simply bound to happen and probably very hard to avoid once you have set your mind on allowing pass-thru in the first place. Not sure whether that even has potential to disturb network equipment like switches.
Henning
Quoted 51 lines
Aaron
Quoted 49 lines
Maybe i should try the patch but it seems like it defeats inheritance completely. Well depending on probe order ...
regards,
HenningQuoted 41 lines
Quoted 3 lines
Quoted 3 lines
Maybe leave here with
netif_info()Not good to print in rcu lock.
Quoted 5 lines
Quoted 2 lines
And move the whole block up, we can skip the whole ACPI story if we find the MAC busy.
That is wrong, need to know that MAC so can not move up too much. But maybe above the
is_valid_ether_addrThe MAC passthough address is read from ACPI.
ACPI read only happens once during r8152 driver probe. To keep the lock less time, do it afteris_valid_ether_addr.Quoted 11 lines
Henning
Quoted 8 lines
drivers/net/usb/r8152.c static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) · line 1673
Quoted 3 lines
drivers/net/usb/r8152.c +3
-0+ } + } +rcu_read_unlock ();Not sure if this function is guaranteed to only run once at a time, otherwise i think that is a race. Multiple instances could make it to this very point at the same time.
Run once for one device.
So add a safe lock.Aaron
Quoted 8 lines
Quoted 7 lines
Henning
Quoted 4 lines
memcpy(sa->sa_data, buf, 6); netif_info(tp, probe, tp->netdev, "Using pass-thru MAC addr %pM\n",
sa->sa_data);
Quoted 78 lines · Henning Schild
Am Wed, 5 Jan 2022 16:01:24 +0800
schrieb Aaron Ma <[email protected]>:Quoted 68 lines · Henning Schild
Quoted 58 lines
Am Wed, 5 Jan 2022 15:38:51 +0800
schrieb Aaron Ma <[email protected]>:Quoted 55 lines · Henning Schild
Quoted 8 lines
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:Quoted 5 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Sure, I will do it.
Quoted 42 lines
Quoted 42 lines
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 28 lines
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 <[email protected]>--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/usb/r8152.c +0
-0@@ -1605,6 +1605,7 @@ static intvendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr
*sa) char *mac_obj_name; acpi_object_type mac_obj_type; int mac_strlen;drivers/net/usb/r8152.c +1
-0+struct net_device *ndev;if (tp->lenovo_macpassthru) { mac_obj_name ="\\MACA" ;@@ -1662,6 +1663,15 @@ static intvendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr
*sa) ret = -EINVAL; goto amacout; }drivers/net/usb/r8152.c
Quoted 5 lines
drivers/net/usb/r8152.c +5
-0+rcu_read_lock (); +for_each_netdev_rcu (&init_net, ndev) { +if (strncmp (buf, ndev->dev_addr,6 ) ==0 ) { +rcu_read_unlock (); + goto amacout;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.Quoted 8 lines
Quoted 2 lines
PCI ethernet could be a builtin one on dock since there will be TBT4 dock.
In my X280 there is a PCI device in the laptop, always there. And its MAC is the one found in ACPI. Did not try but i think for such devices there would never be inheritance even if one wanted and used a Lenovo dock that is supposed to do it.
Quoted 6 lines
There will more TBT4 docks in market, the new ethernet is just the same as PCI device, connected by thunderbolt.
For exmaple, connect a TBT4 dock which uses i225 pcie base ethernet, then connect another TBT3 dock which uses r8152.
If skip PCI check, then i225 and r8152 will use the same MAC.
Quoted 8 lines
In current 5.15 i have that sort of collision already. All r8152s will happily grab the MAC of the I219. In fact i have only ever seen it with one r8152 at a time but while the I219 was actively in use. While this patch will probably solve that, i bet it would defeat MAC pass-thru altogether. Even when turned on in the BIOS.
Or does that iterator take "up"/"down" state into consideration? But even if, the I219 could become "up" any time later.
No, that's different, I219 got MAC from their own space. MAC passthrough got MAC from ACPI "\MACA".
Quoted 5 lines
These collisions are simply bound to happen and probably very hard to avoid once you have set your mind on allowing pass-thru in the first place. Not sure whether that even has potential to disturb network equipment like switches.
After check MAC address, it will be more safe.
Aaron
Quoted 54 lines
Henning
Quoted 51 lines
Aaron
Quoted 49 lines
Maybe i should try the patch but it seems like it defeats inheritance completely. Well depending on probe order ...
regards,
HenningQuoted 41 lines
Quoted 3 lines
Quoted 3 lines
Maybe leave here with
netif_info()Not good to print in rcu lock.
Quoted 5 lines
Quoted 2 lines
And move the whole block up, we can skip the whole ACPI story if we find the MAC busy.
That is wrong, need to know that MAC so can not move up too much. But maybe above the
is_valid_ether_addrThe MAC passthough address is read from ACPI.
ACPI read only happens once during r8152 driver probe. To keep the lock less time, do it afteris_valid_ether_addr.Quoted 11 lines
Henning
Quoted 8 lines
drivers/net/usb/r8152.c
Quoted 3 lines
drivers/net/usb/r8152.c +3
-0+ } + } +rcu_read_unlock ();Not sure if this function is guaranteed to only run once at a time, otherwise i think that is a race. Multiple instances could make it to this very point at the same time.
Run once for one device.
So add a safe lock.Aaron
Quoted 8 lines
Quoted 7 lines
Henning
Quoted 4 lines
memcpy(sa->sa_data, buf, 6); netif_info(tp, probe, tp->netdev, "Using pass-thru MAC addr %pM\n",
sa->sa_data);
Am Wed, 5 Jan 2022 16:37:11 +0800
schrieb Aaron Ma <[email protected]>:
Quoted 88 lines · Henning Schild
Quoted 78 lines
Am Wed, 5 Jan 2022 16:01:24 +0800
schrieb Aaron Ma <[email protected]>:Quoted 68 lines · Henning Schild
Quoted 58 lines
Am Wed, 5 Jan 2022 15:38:51 +0800
schrieb Aaron Ma <[email protected]>:Quoted 55 lines · Henning Schild
Quoted 8 lines
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:Quoted 5 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Sure, I will do it.
Quoted 42 lines
Quoted 42 lines
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 28 lines
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 <[email protected]>--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/usb/r8152.c +0
-0@@ -1605,6 +1605,7 @@ static int
vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)char*mac_obj_name;acpi_object_typemac_obj_type; intmac_strlen;drivers/net/usb/r8152.c +1
-0+struct net_device *ndev;if (tp->lenovo_macpassthru) { mac_obj_name ="\\MACA" ;@@ -1662,6 +1663,15 @@ static intvendor_mac_passthru_addr_read(struct r8152 *tp, struct
sockaddr *sa) ret = -EINVAL; goto amacout; }drivers/net/usb/r8152.c
Quoted 5 lines
drivers/net/usb/r8152.c +5
-0+rcu_read_lock (); +for_each_netdev_rcu (&init_net, ndev) { +if (strncmp (buf, ndev->dev_addr,6 ) ==0 ) { +rcu_read_unlock (); + goto amacout;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.Quoted 8 lines
Quoted 2 lines
PCI ethernet could be a builtin one on dock since there will be TBT4 dock.
In my X280 there is a PCI device in the laptop, always there. And its MAC is the one found in ACPI. Did not try but i think for such devices there would never be inheritance even if one wanted and used a Lenovo dock that is supposed to do it.
Quoted 6 lines
There will more TBT4 docks in market, the new ethernet is just the same as PCI device, connected by thunderbolt.
For exmaple, connect a TBT4 dock which uses i225 pcie base ethernet, then connect another TBT3 dock which uses r8152. If skip PCI check, then i225 and r8152 will use the same MAC.
Quoted 8 lines
In current 5.15 i have that sort of collision already. All r8152s will happily grab the MAC of the I219. In fact i have only ever seen it with one r8152 at a time but while the I219 was actively in use. While this patch will probably solve that, i bet it would defeat MAC pass-thru altogether. Even when turned on in the BIOS. Or does that iterator take "up"/"down" state into consideration? But even if, the I219 could become "up" any time later.
Quoted 2 lines
No, that's different, I219 got MAC from their own space. MAC passthrough got MAC from ACPI "\MACA".
On my machine "\MACA" and I219 are the same, likely "\MACA" was populated by looking at that I219 by the BIOS.
Not sure if "\MACA" can change when plugging docks, but probably not since the BIOS is also trying to implement inheritance of the main MAC.
Let me try this patch, maybe i do not get it.
Henning
Quoted 64 lines
Quoted 5 lines
These collisions are simply bound to happen and probably very hard to avoid once you have set your mind on allowing pass-thru in the first place. Not sure whether that even has potential to disturb network equipment like switches.
After check MAC address, it will be more safe.
Aaron
Quoted 54 lines
Henning
Quoted 51 lines
Aaron
Quoted 49 lines
Maybe i should try the patch but it seems like it defeats inheritance completely. Well depending on probe order ...
regards,
HenningQuoted 41 lines
Quoted 3 lines
Quoted 3 lines
Maybe leave here with
netif_info()Not good to print in rcu lock.
Quoted 5 lines
Quoted 2 lines
And move the whole block up, we can skip the whole ACPI story if we find the MAC busy.
That is wrong, need to know that MAC so can not move up too much. But maybe above the
is_valid_ether_addrThe MAC passthough address is read from ACPI.
ACPI read only happens once during r8152 driver probe. To keep the lock less time, do it afteris_valid_ether_addr.Quoted 11 lines
Henning
Quoted 8 lines
drivers/net/usb/r8152.c
Quoted 3 lines
drivers/net/usb/r8152.c +3
-0+ } + } +rcu_read_unlock ();Not sure if this function is guaranteed to only run once at a time, otherwise i think that is a race. Multiple instances could make it to this very point at the same time.
Run once for one device.
So add a safe lock.Aaron
Quoted 8 lines
Quoted 7 lines
Henning
Quoted 4 lines
memcpy(sa->sa_data, buf, 6); netif_info(tp, probe, tp->netdev, "Using pass-thru MAC addr %pM\n",
sa->sa_data);
Quoted 94 lines · Henning Schild
Am Wed, 5 Jan 2022 16:37:11 +0800
schrieb Aaron Ma <[email protected]>:Quoted 88 lines · Henning Schild
Quoted 78 lines
Am Wed, 5 Jan 2022 16:01:24 +0800
schrieb Aaron Ma <[email protected]>:Quoted 68 lines · Henning Schild
Quoted 58 lines
Am Wed, 5 Jan 2022 15:38:51 +0800
schrieb Aaron Ma <[email protected]>:Quoted 55 lines · Henning Schild
Quoted 8 lines
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:Quoted 5 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Sure, I will do it.
Quoted 42 lines
Quoted 42 lines
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 28 lines
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 <[email protected]>--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/usb/r8152.c +0
-0@@ -1605,6 +1605,7 @@ static int
vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)char*mac_obj_name;acpi_object_typemac_obj_type; intmac_strlen;drivers/net/usb/r8152.c +1
-0+struct net_device *ndev;if (tp->lenovo_macpassthru) { mac_obj_name ="\\MACA" ;@@ -1662,6 +1663,15 @@ static intvendor_mac_passthru_addr_read(struct r8152 *tp, struct
sockaddr *sa) ret = -EINVAL; goto amacout; }drivers/net/usb/r8152.c
Quoted 5 lines
drivers/net/usb/r8152.c +5
-0+rcu_read_lock (); +for_each_netdev_rcu (&init_net, ndev) { +if (strncmp (buf, ndev->dev_addr,6 ) ==0 ) { +rcu_read_unlock (); + goto amacout;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.Quoted 8 lines
Quoted 2 lines
PCI ethernet could be a builtin one on dock since there will be TBT4 dock.
In my X280 there is a PCI device in the laptop, always there. And its MAC is the one found in ACPI. Did not try but i think for such devices there would never be inheritance even if one wanted and used a Lenovo dock that is supposed to do it.
Quoted 6 lines
There will more TBT4 docks in market, the new ethernet is just the same as PCI device, connected by thunderbolt.
For exmaple, connect a TBT4 dock which uses i225 pcie base ethernet, then connect another TBT3 dock which uses r8152. If skip PCI check, then i225 and r8152 will use the same MAC.
Quoted 8 lines
In current 5.15 i have that sort of collision already. All r8152s will happily grab the MAC of the I219. In fact i have only ever seen it with one r8152 at a time but while the I219 was actively in use. While this patch will probably solve that, i bet it would defeat MAC pass-thru altogether. Even when turned on in the BIOS. Or does that iterator take "up"/"down" state into consideration? But even if, the I219 could become "up" any time later.
Quoted 2 lines
No, that's different, I219 got MAC from their own space. MAC passthrough got MAC from ACPI "\MACA".
Quoted 6 lines
On my machine "\MACA" and I219 are the same, likely "\MACA" was populated by looking at that I219 by the BIOS.
Not sure if "\MACA" can change when plugging docks, but probably not since the BIOS is also trying to implement inheritance of the main MAC.Let me try this patch, maybe i do not get it.
That's expected, MAC passthrough is intended to replace I219.
This feature allows the MAC address of the native Ethernet network device on the system to be used on dock.
The company network only see one MAC for your laptop.
Aaron
Quoted 68 lines
Henning
Quoted 64 lines
Quoted 5 lines
These collisions are simply bound to happen and probably very hard to avoid once you have set your mind on allowing pass-thru in the first place. Not sure whether that even has potential to disturb network equipment like switches.
After check MAC address, it will be more safe.
Aaron
Quoted 54 lines
Henning
Quoted 51 lines
Aaron
Quoted 49 lines
Maybe i should try the patch but it seems like it defeats inheritance completely. Well depending on probe order ...
regards,
HenningQuoted 41 lines
Quoted 3 lines
Quoted 3 lines
Maybe leave here with
netif_info()Not good to print in rcu lock.
Quoted 5 lines
Quoted 2 lines
And move the whole block up, we can skip the whole ACPI story if we find the MAC busy.
That is wrong, need to know that MAC so can not move up too much. But maybe above the
is_valid_ether_addrThe MAC passthough address is read from ACPI.
ACPI read only happens once during r8152 driver probe. To keep the lock less time, do it afteris_valid_ether_addr.Quoted 11 lines
Henning
Quoted 8 lines
drivers/net/usb/r8152.c
Quoted 3 lines
drivers/net/usb/r8152.c +3
-0+ } + } +rcu_read_unlock ();Not sure if this function is guaranteed to only run once at a time, otherwise i think that is a race. Multiple instances could make it to this very point at the same time.
Run once for one device.
So add a safe lock.Aaron
Quoted 8 lines
Quoted 7 lines
Henning
Quoted 4 lines
memcpy(sa->sa_data, buf, 6); netif_info(tp, probe, tp->netdev, "Using pass-thru MAC addr %pM\n",
sa->sa_data);
Am Wed, 5 Jan 2022 09:47:02 +0100
schrieb Henning Schild <[email protected]>:
Quoted 94 lines
Am Wed, 5 Jan 2022 16:37:11 +0800
schrieb Aaron Ma <[email protected]>:Quoted 88 lines · Henning Schild
Quoted 78 lines
Am Wed, 5 Jan 2022 16:01:24 +0800
schrieb Aaron Ma <[email protected]>:Quoted 68 lines · Henning Schild
Quoted 58 lines
Am Wed, 5 Jan 2022 15:38:51 +0800
schrieb Aaron Ma <[email protected]>:Quoted 55 lines · Henning Schild
Quoted 8 lines
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:Quoted 5 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Sure, I will do it.
Quoted 42 lines
Quoted 42 lines
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 28 lines
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 <[email protected]>--- drivers/net/usb/r8152.c | 10 ++++++++++ 1 file changed, 10 insertions(+)(quoted diff) +0
-0
b/drivers/net/usb/r8152.cindexf9877a3e83ac..77f11b3f847b100644 ---a/drivers/net/usb/r8152.c
+++b/drivers/net/usb/r8152.c(quoted diff) +0
-0@@ -1605,6 +1605,7 @@ static int
vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)char*mac_obj_name;acpi_object_typemac_obj_type; intmac_strlen;(quoted diff) +1
-0+ struct net_device *ndev; if (tp->lenovo_macpassthru) { mac_obj_name = "\\MACA";@@ -1662,6 +1663,15 @@ static intvendor_mac_passthru_addr_read(struct r8152 *tp, struct
sockaddr *sa) ret = -EINVAL; goto amacout; }Review
Quoted 5 lines
(quoted diff) +5
-0+ rcu_read_lock(); + for_each_netdev_rcu(&init_net, ndev) { + if (strncmp(buf, ndev->dev_addr, 6) == 0) { + rcu_read_unlock(); + goto amacout;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.Quoted 8 lines
Quoted 2 lines
PCI ethernet could be a builtin one on dock since there will be TBT4 dock.
In my X280 there is a PCI device in the laptop, always there. And its MAC is the one found in ACPI. Did not try but i think for such devices there would never be inheritance even if one wanted and used a Lenovo dock that is supposed to do it.
Quoted 6 lines
There will more TBT4 docks in market, the new ethernet is just the same as PCI device, connected by thunderbolt.
For exmaple, connect a TBT4 dock which uses i225 pcie base ethernet, then connect another TBT3 dock which uses r8152. If skip PCI check, then i225 and r8152 will use the same MAC.
Quoted 8 lines
In current 5.15 i have that sort of collision already. All r8152s will happily grab the MAC of the I219. In fact i have only ever seen it with one r8152 at a time but while the I219 was actively in use. While this patch will probably solve that, i bet it would defeat MAC pass-thru altogether. Even when turned on in the BIOS. Or does that iterator take "up"/"down" state into consideration? But even if, the I219 could become "up" any time later.
Quoted 2 lines
No, that's different, I219 got MAC from their own space. MAC passthrough got MAC from ACPI "\MACA".
Quoted 7 lines
On my machine "\MACA" and I219 are the same, likely "\MACA" was populated by looking at that I219 by the BIOS.
Not sure if "\MACA" can change when plugging docks, but probably not since the BIOS is also trying to implement inheritance of the main MAC.Let me try this patch, maybe i do not get it.
So i tried it and inheritance now is killed as expected because that I219 has that MAC. So for devices that have a PCI device built-in ... this patch is like removing pass-thru altogether. And very likely not what you intended.
On top the device will receive a random MAC because there is no error code before "goto amacount;" some randomness from the stack of the caller of determine_ethernet_addr where the "sa"s come from.
I now have an "ret = -EBUSY" in mine ... but still there can never be pass-thru because that I219 is always there.
This patch is very wrong! And i am still not sure about the race, you did not say anything about that.
Henning
Quoted 67 lines
Henning
Quoted 64 lines
Quoted 5 lines
These collisions are simply bound to happen and probably very hard to avoid once you have set your mind on allowing pass-thru in the first place. Not sure whether that even has potential to disturb network equipment like switches.
After check MAC address, it will be more safe.
Aaron
Quoted 54 lines
Henning
Quoted 51 lines
Aaron
Quoted 49 lines
Maybe i should try the patch but it seems like it defeats inheritance completely. Well depending on probe order ...
regards,
HenningQuoted 41 lines
Quoted 3 lines
Quoted 3 lines
Maybe leave here with
netif_info()Not good to print in rcu lock.
Quoted 5 lines
Quoted 2 lines
And move the whole block up, we can skip the whole ACPI story if we find the MAC busy.
That is wrong, need to know that MAC so can not move up too much. But maybe above the
is_valid_ether_addrThe MAC passthough address is read from ACPI.
ACPI read only happens once during r8152 driver probe. To keep the lock less time, do it afteris_valid_ether_addr.Quoted 11 lines
Henning
Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ } + } + rcu_read_unlock();Not sure if this function is guaranteed to only run once at a time, otherwise i think that is a race. Multiple instances could make it to this very point at the same time.
Run once for one device.
So add a safe lock.Aaron
Quoted 8 lines
Quoted 7 lines
Henning
Quoted 4 lines
memcpy(sa->sa_data, buf, 6); netif_info(tp, probe, tp->netdev, "Using pass-thru MAC addr %pM\n",
sa->sa_data);
Quoted 92 lines · Aaron Ma
Quoted 77 lines · Henning Schild
Am Wed, 5 Jan 2022 16:01:24 +0800
schrieb Aaron Ma <[email protected]>:Quoted 67 lines · Henning Schild
Quoted 57 lines
Am Wed, 5 Jan 2022 15:38:51 +0800
schrieb Aaron Ma <[email protected]>:Quoted 54 lines · Henning Schild
Quoted 8 lines
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:Quoted 5 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Sure, I will do it.
Quoted 41 lines
Quoted 41 lines
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 24 lines
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 <[email protected]>---
drivers/net/usb/r8152.c| 10 ++++++++++1 file changed, 10 insertions(+)drivers/net/usb/r8152.c +0
-0@@ -1605,6 +1605,7 @@ static int
vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)char*mac_obj_name;acpi_object_typemac_obj_type; intmac_strlen;
+ structnet_device*ndev;
if (tp->lenovo_macpassthru) {mac_obj_name= "\\MACA";drivers/net/usb/r8152.c +0
-0@@ -1662,6 +1663,15 @@ static intQuoted 8 lines
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;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.Quoted 8 lines
Quoted 2 lines
PCI ethernet could be a builtin one on dock since there will be TBT4 dock.
In my X280 there is a PCI device in the laptop, always there. And its MAC is the one found in ACPI. Did not try but i think for such devices there would never be inheritance even if one wanted and used a Lenovo dock that is supposed to do it.
Quoted 6 lines
There will more TBT4 docks in market, the new ethernet is just the same as PCI device, connected by thunderbolt.
For exmaple, connect a TBT4 dock which uses i225 pcie base ethernet, then connect another TBT3 dock which uses r8152.
If skip PCI check, then i225 and r8152 will use the same MAC.Quoted 8 lines
In current 5.15 i have that sort of collision already. All r8152s will happily grab the MAC of the I219. In fact i have only ever seen it with one r8152 at a time but while the I219 was actively in use. While this patch will probably solve that, i bet it would defeat MAC pass-thru altogether. Even when turned on in the BIOS.
Or does that iterator take "up"/"down" state into consideration? But even if, the I219 could become "up" any time later.No, that's different, I219 got MAC from their own space. MAC passthrough got MAC from ACPI "\MACA".
Quoted 7 lines
Quoted 5 lines
These collisions are simply bound to happen and probably very hard to avoid once you have set your mind on allowing pass-thru in the first place. Not sure whether that even has potential to disturb network equipment like switches.
After check MAC address, it will be more safe.
Sorry to just do a drive by review here, but why is passing through the MAC a kernel problem and not something that you punt to user-space entirely?
Signature · 1 line
Florian
Am Wed, 5 Jan 2022 11:55:06 -0800
schrieb Florian Fainelli <[email protected]>:
Quoted 99 lines · Aaron Ma
Quoted 98 lines · Henning Schild
Quoted 77 lines
Am Wed, 5 Jan 2022 16:01:24 +0800
schrieb Aaron Ma <[email protected]>:Quoted 67 lines · Henning Schild
Quoted 57 lines
Am Wed, 5 Jan 2022 15:38:51 +0800
schrieb Aaron Ma <[email protected]>:Quoted 54 lines · Henning Schild
Quoted 8 lines
Am Wed, 5 Jan 2022 08:23:55 +0100
schrieb Henning Schild <[email protected]>:Quoted 5 lines
Hi Aaron,
if this or something similar goes in, please add another patch to remove the left-over defines.
Sure, I will do it.
Quoted 41 lines
Quoted 41 lines
Am Wed, 5 Jan 2022 14:17:47 +0800
schrieb Aaron Ma <[email protected]>:Quoted 24 lines
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 <[email protected]>---
drivers/net/usb/r8152.c| 10 ++++++++++1 file changed, 10 insertions(+)(quoted diff) +0
-0
b/drivers/net/usb/r8152.cindexf9877a3e83ac..77f11b3f847b100644 ---a/drivers/net/usb/r8152.c
+++b/drivers/net/usb/r8152.c(quoted diff) +0
-0@@ -1605,6 +1605,7 @@ static int
vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)char*mac_obj_name;acpi_object_typemac_obj_type; intmac_strlen;
+ structnet_device*ndev;
if (tp->lenovo_macpassthru) {mac_obj_name= "\\MACA";(quoted diff) +0
-0@@ -1662,6 +1663,15 @@ static intQuoted 8 lines
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;Since the original PCI netdev will always be there, that would disable inheritance would it not?
I guess astrncmp(MODULE_NAME, info->driver, strlen(MODULE_NAME))is needed as well.Quoted 8 lines
Quoted 2 lines
PCI ethernet could be a builtin one on dock since there will be TBT4 dock.
In my X280 there is a PCI device in the laptop, always there. And its MAC is the one found in ACPI. Did not try but i think for such devices there would never be inheritance even if one wanted and used a Lenovo dock that is supposed to do it.
Quoted 6 lines
There will more TBT4 docks in market, the new ethernet is just the same as PCI device, connected by thunderbolt.
For exmaple, connect a TBT4 dock which uses i225 pcie base ethernet, then connect another TBT3 dock which uses r8152. If skip PCI check, then i225 and r8152 will use the same MAC.
Quoted 8 lines
In current 5.15 i have that sort of collision already. All r8152s will happily grab the MAC of the I219. In fact i have only ever seen it with one r8152 at a time but while the I219 was actively in use. While this patch will probably solve that, i bet it would defeat MAC pass-thru altogether. Even when turned on in the BIOS. Or does that iterator take "up"/"down" state into consideration? But even if, the I219 could become "up" any time later.
No, that's different, I219 got MAC from their own space. MAC passthrough got MAC from ACPI "\MACA".
Quoted 5 lines
These collisions are simply bound to happen and probably very hard to avoid once you have set your mind on allowing pass-thru in the first place. Not sure whether that even has potential to disturb network equipment like switches.
Quoted 5 lines
Quoted 1 line
After check MAC address, it will be more safe.
Sorry to just do a drive by review here, but why is passing through the MAC a kernel problem and not something that you punt to user-space entirely?
Agreed and several other people seem to feel the same way about pass-thru not deserving a place in the kernel.
This all dates back to 34ee32c9a5696247be405bb0c21f3d1fc6cb5729 and some other patches that came later
9647722befbedcd6735e00655ffec392c05f0c56c286909fe5458f69e533c845b757fd2c35064d268e29d23e28ee7fb995a00c1ca7e1a4caf5070b129c27369f4a1393452c17e8708c1b0beb8ac59501
Maybe other drivers are affected as well.
All of the patches should probably be reverted. If people care enough they can try and get it into udev.
All patches put policy into the kernel, do weird ACPI lookups and cause MAC conflicts with NICs that might be up and running. And will claim too many r8512 devices in case there are multiple.
I propose to revert all of this or maybe add a module param (which should probably default to "off") just to give people a way to preserve their hacks.
If the BIOS did spoof we could try to keep that, but spoofing in the OS (at least in the kernel) sound very wrong and caused me to start the whole discussion after all my r8521 dongles all of a sudden had the same (already busy) MAC when moving to v5.15. That was on a Lenovo laptop but i am pretty sure Dell and HP would be affected as well.
When using another NIC you get another MAC, it is that simple. If that causes issues with DHCP/PXE deal with it. A MAC does not id a machine, maybe x509 radius does. Not a kernel story!
Henning