mediatek: filogic: support openwrt,netdev-name for renaming interfaces
authorJonas Jelonek <jelonek.jonas@gmail.com>
Mon, 25 Nov 2024 23:04:15 +0000 (23:04 +0000)
committerPaul Spooren <mail@aparcar.org>
Fri, 20 Dec 2024 17:19:09 +0000 (18:19 +0100)
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@gmail.com>
target/linux/mediatek/filogic/base-files/lib/preinit/04_set_netdev_label

index 110e023b962d3dfb86883d7bd840458ecece67ce..2c5e420f93bd17b4f2340edc32b88610a7b5fd90 100644 (file)
@@ -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