]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
qualcommax: ipq50xx: support interface renaming
authorRobert Marko <robimarko@gmail.com>
Fri, 5 Jun 2026 19:26:19 +0000 (21:26 +0200)
committerRobert Marko <robimarko@gmail.com>
Sat, 11 Jul 2026 20:26:44 +0000 (22:26 +0200)
Import the interface renaming script from filogic so we can use DTS
label or openwrt,netdev-name to name interfaces from DTS on non DSA
ports.

Link: https://github.com/openwrt/openwrt/pull/22381
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/qualcommax/ipq50xx/base-files/lib/preinit/04_set_netdev_label [new file with mode: 0755]

diff --git a/target/linux/qualcommax/ipq50xx/base-files/lib/preinit/04_set_netdev_label b/target/linux/qualcommax/ipq50xx/base-files/lib/preinit/04_set_netdev_label
new file mode 100755 (executable)
index 0000000..29921af
--- /dev/null
@@ -0,0 +1,23 @@
+set_netdev_labels() {
+       local dir
+       local label
+       local netdev
+
+       for dir in /sys/class/net/*; do
+               [ -r "$dir/device/of_node/label" ] || continue
+               read -r label < "$dir/device/of_node/label"
+               netdev="${dir##*/}"
+               [ "$netdev" = "$label" ] && continue
+               ip link set "$netdev" name "$label"
+       done
+
+       for dir in /sys/class/net/*; do
+               [ -r "$dir/device/of_node/openwrt,netdev-name" ] || continue
+               read -r label < "$dir/device/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