Skip to content

Commit 141ccfd

Browse files
committed
ramips: mt7621: support openwrt,netdev-name for renaming interfaces
Edgerouter X currently has its eth1 port on the switch missing since there is a naming conflict currently. So, as the root cause is mixing kernel support for DSA interfaces having predictable names set via "label" property vs others having it assigned dynamically lets avoid the conflict by using our own custom property as suggested upstream [1]. So, add support via "openwrt,netdev-name" property and use it on ERX. Fixes: 2a25c6a ("ramips: get rid of downstream network device label patch") Fixes: #15643 Link: openwrt/openwrt#17062 Signed-off-by: Robert Marko <[email protected]> (cherry picked from commit 5695267)
1 parent a5b2911 commit 141ccfd

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

target/linux/ramips/dts/mt7621_ubnt_edgerouter-x-sfp.dts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@
6969
ports {
7070
port@5 {
7171
reg = <5>;
72-
label = "eth5";
72+
openwrt,netdev-name = "eth5";
7373
phy-handle = <&ephy7>;
7474
phy-mode = "rgmii-rxid";
7575
nvmem-cells = <&macaddr_factory_22 5>;
7676
nvmem-cell-names = "mac-address";
77+
/delete-property/ label;
7778
};
7879
};
7980
};

target/linux/ramips/dts/mt7621_ubnt_edgerouter-x.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
&gmac1 {
99
status = "okay";
10-
label = "eth0";
10+
openwrt,netdev-name = "eth0";
1111
phy-handle = <&ethphy0>;
1212

1313
nvmem-cells = <&macaddr_factory_22 0>;

target/linux/ramips/dts/mt7621_ubnt_edgerouter-x.dtsi

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,47 @@
2222
&gmac0 {
2323
nvmem-cells = <&macaddr_factory_22 0>;
2424
nvmem-cell-names = "mac-address";
25-
label = "dsa";
25+
openwrt,netdev-name = "dsa";
2626
};
2727

2828
&switch0 {
2929
ports {
3030
port@0 {
3131
status = "okay";
32-
label = "eth0";
32+
openwrt,netdev-name = "eth0";
33+
/delete-property/ label;
3334
};
3435

3536
port@1 {
3637
status = "okay";
37-
label = "eth1";
38+
openwrt,netdev-name = "eth1";
3839
nvmem-cells = <&macaddr_factory_22 1>;
3940
nvmem-cell-names = "mac-address";
41+
/delete-property/ label;
4042
};
4143

4244
port@2 {
4345
status = "okay";
44-
label = "eth2";
46+
openwrt,netdev-name = "eth2";
4547
nvmem-cells = <&macaddr_factory_22 2>;
4648
nvmem-cell-names = "mac-address";
49+
/delete-property/ label;
4750
};
4851

4952
port@3 {
5053
status = "okay";
51-
label = "eth3";
54+
openwrt,netdev-name = "eth3";
5255
nvmem-cells = <&macaddr_factory_22 3>;
5356
nvmem-cell-names = "mac-address";
57+
/delete-property/ label;
5458
};
5559

5660
port@4 {
5761
status = "okay";
58-
label = "eth4";
62+
openwrt,netdev-name = "eth4";
5963
nvmem-cells = <&macaddr_factory_22 4>;
6064
nvmem-cell-names = "mac-address";
65+
/delete-property/ label;
6166
};
6267
};
6368
};

target/linux/ramips/mt7621/base-files/lib/preinit/04_set_netdev_label

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ set_netdev_labels() {
1010
[ "$netdev" = "$label" ] && continue
1111
ip link set "$netdev" name "$label"
1212
done
13+
14+
for dir in /sys/class/net/*; do
15+
[ -r "$dir/of_node/openwrt,netdev-name" ] || continue
16+
read -r label < "$dir/of_node/openwrt,netdev-name"
17+
netdev="${dir##*/}"
18+
[ "$netdev" = "$label" ] && continue
19+
ip link set "$netdev" name "$label"
20+
done
1321
}
1422

1523
boot_hook_add preinit_main set_netdev_labels

0 commit comments

Comments
 (0)