[openwrt/openwrt] mediatek: mt7622: add netdev rename preinit script
LEDE Commits
lede-commits at lists.infradead.org
Tue Oct 15 16:12:12 PDT 2024
dangole pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/7e51d6a4c85de575654c49f410ce3e173176d1a9
commit 7e51d6a4c85de575654c49f410ce3e173176d1a9
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Wed Oct 16 00:10:28 2024 +0100
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 <daniel at makrotopia.org>
---
.../mt7622/base-files/lib/preinit/04_set_netdev_label | 15 +++++++++++++++
1 file changed, 15 insertions(+)
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
More information about the lede-commits
mailing list