Skip to content

Commit 130306f

Browse files
hurrianrobimarko
authored andcommitted
airoha: support openwrt,netdev-name for renaming interfaces
Add support to the airoha target for the OpenWrt-specific DT property `openwrt,netdev-name`. In particular, this is for interfaces under non-DSA `airoha_eth` interfaces. This will avoid conflicts with upstream code[1]; and maintain forward compatibility with OpenWrt configurations if/when `airoha_eth` becomes a full DSA driver. [1] https://lore.kernel.org/netdev/20240709124503.pubki5nwjfbedhhy@skbuf/ Borrowed from d4d6c48 (mediatek: filogic: support openwrt,netdev-name for renaming interfaces) Signed-off-by: Kenneth Kasilag <kenneth@kasilag.me> Link: openwrt#20475 Signed-off-by: Robert Marko <robimarko@gmail.com>
1 parent 120b70a commit 130306f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set_netdev_labels() {
2+
local dir
3+
local label
4+
local netdev
5+
6+
for dir in /sys/class/net/*; do
7+
[ -r "$dir/of_node/openwrt,netdev-name" ] || continue
8+
read -r label < "$dir/of_node/openwrt,netdev-name"
9+
netdev="${dir##*/}"
10+
[ "$netdev" = "$label" ] && continue
11+
ip link set "$netdev" name "$label"
12+
done
13+
}
14+
15+
boot_hook_add preinit_main set_netdev_labels

0 commit comments

Comments
 (0)