From: Reto Schneider <redacted>
The (optional) label property allows to specify customized interfaces
names.
The motivation behind this change is to allow embedded devices to keep
their first switch port be named "eth0", even when switching to the DSA
architecture. In order to do so, it must be possible to name the MAC
interface differently from eth0.
Signed-off-by: Reto Schneider <redacted>
---
Documentation/devicetree/bindings/net/mediatek-net.txt | 4 ++++
1 file changed, 4 insertions(+)
@@ -51,6 +51,9 @@ Required properties: is equal to 0 and the MAC uses fixed-link to connect with internal switch such as MT7530.+Optional properties:+- label: Name of interface, defaults to ethX if missing+ Example: eth: ethernet@1b100000 {
From: Reto Schneider <redacted>
Name the MAC interface name according to the label property. If the
property is missing, the default name (ethX) gets used.
Signed-off-by: Reto Schneider <redacted>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++
1 file changed, 4 insertions(+)
Please don't use strncpy() - this is a good example why strncpy() is bad
news.
* strncpy - Copy a length-limited, C-string
* @dest: Where to copy the string to
* @src: Where to copy the string from
* @count: The maximum number of bytes to copy
*
* The result is not %NUL-terminated if the source exceeds
* @count bytes.
Consequently, if "name" is IFNAMSIZ bytes or longer,
eth->netdev[id]->name will not be NUL terminated, and subsequent use
will run off the end of the string. strscpy() is safer to use here.
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Hi Russell,
On 13.06.21 14:20, Russell King (Oracle) wrote:
Please don't use strncpy() - this is a good example why strncpy() is bad
news.
* strncpy - Copy a length-limited, C-string
* @dest: Where to copy the string to
* @src: Where to copy the string from
* @count: The maximum number of bytes to copy
*
* The result is not %NUL-terminated if the source exceeds
* @count bytes.
Consequently, if "name" is IFNAMSIZ bytes or longer,
eth->netdev[id]->name will not be NUL terminated, and subsequent use
will run off the end of the string. strscpy() is safer to use here.
Thanks a lot for finding this (embarrassing mistake) and pointing me in
the right direction (did dot know about strscpy).
Will send v2 soon.
Kind regards,
Reto
From: Reto Schneider <redacted>
The (optional) label property allows to specify customized interfaces
names.
The motivation behind this change is to allow embedded devices to keep
their first switch port be named "eth0", even when switching to the DSA
architecture. In order to do so, it must be possible to name the MAC
interface differently from eth0.
Signed-off-by: Reto Schneider <redacted>
---
(no changes since v1)
Documentation/devicetree/bindings/net/mediatek-net.txt | 4 ++++
1 file changed, 4 insertions(+)
@@ -51,6 +51,9 @@ Required properties: is equal to 0 and the MAC uses fixed-link to connect with internal switch such as MT7530.+Optional properties:+- label: Name of interface, defaults to ethX if missing+ Example: eth: ethernet@1b100000 {
From: Reto Schneider <redacted>
Name the MAC interface name according to the label property. If the
property is missing, the default name (ethX) gets used.
Labels with more than IFNAMSIZ -1 characters will be truncated silently,
which seems to be what most of the code base does when using strscpy.
Signed-off-by: Reto Schneider <redacted>
---
Changes in v2:
- Avoid dangerous usage of strncpy
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++
1 file changed, 4 insertions(+)
From: Reto Schneider <redacted>
Name the MAC interface name according to the label property. If the
property is missing, the default name (ethX) gets used.
Signed-off-by: Reto Schneider <redacted>
Please solve naming issues in userspace via udev, thank you.