From 7e51d6a4c85de575654c49f410ce3e173176d1a9 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 16 Oct 2024 00:10:28 +0100 Subject: [PATCH] mediatek: mt7622: add netdev rename preinit script Add preinit script to rename network interfaces according to the label provided in Device Tree. Fixes: b6d8297510 ("mediatek: mt7622: add Adtran SmartRG SDG-841t6 device") Signed-off-by: Daniel Golle --- .../base-files/lib/preinit/04_set_netdev_label | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 target/linux/mediatek/mt7622/base-files/lib/preinit/04_set_netdev_label diff --git a/target/linux/mediatek/mt7622/base-files/lib/preinit/04_set_netdev_label b/target/linux/mediatek/mt7622/base-files/lib/preinit/04_set_netdev_label new file mode 100644 index 0000000000..110e023b96 --- /dev/null +++ b/target/linux/mediatek/mt7622/base-files/lib/preinit/04_set_netdev_label @@ -0,0 +1,15 @@ +set_netdev_labels() { + local dir + local label + local netdev + + for dir in /sys/class/net/*; do + [ -r "$dir/of_node/label" ] || continue + read -r label < "$dir/of_node/label" + netdev="${dir##*/}" + [ "$netdev" = "$label" ] && continue + ip link set "$netdev" name "$label" + done +} + +boot_hook_add preinit_main set_netdev_labels -- 2.30.2