[openwrt/openwrt] mediatek: filogic: support openwrt,netdev-name for renaming interfaces

LEDE Commits lede-commits at lists.infradead.org
Fri Dec 20 09:19:32 PST 2024


aparcar pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/d4d6c48b6e055dca5480d49d44503d1175539485

commit d4d6c48b6e055dca5480d49d44503d1175539485
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Mon Nov 25 23:04:15 2024 +0000

    mediatek: filogic: support openwrt,netdev-name for renaming interfaces
    
    Add support in filogic subtarget for our own custom property
    `openwrt,netdev-name` in the device tree instead of `label` for
    renaming interfaces. This was suggested upstream to avoid potential
    conflicts [1].
    
    [1] https://lore.kernel.org/netdev/20240709124503.pubki5nwjfbedhhy@skbuf/
    
    Signed-off-by: Jonas Jelonek <jelonek.jonas at gmail.com>
---
 .../mediatek/filogic/base-files/lib/preinit/04_set_netdev_label   | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/target/linux/mediatek/filogic/base-files/lib/preinit/04_set_netdev_label b/target/linux/mediatek/filogic/base-files/lib/preinit/04_set_netdev_label
index 110e023b96..2c5e420f93 100644
--- a/target/linux/mediatek/filogic/base-files/lib/preinit/04_set_netdev_label
+++ b/target/linux/mediatek/filogic/base-files/lib/preinit/04_set_netdev_label
@@ -10,6 +10,14 @@ set_netdev_labels() {
 		[ "$netdev" = "$label" ] && continue
 		ip link set "$netdev" name "$label"
 	done
+
+	for dir in /sys/class/net/*; do
+		[ -r "$dir/of_node/openwrt,netdev-name" ] || continue
+		read -r label < "$dir/of_node/openwrt,netdev-name"
+		netdev="${dir##*/}"
+		[ "$netdev" = "$label" ] && continue
+		ip link set "$netdev" name "$label"
+	done
 }
 
 boot_hook_add preinit_main set_netdev_labels




More information about the lede-commits mailing list