Przeglądaj źródła

realtek: don't implicitly configure port MAC addresses

Currently, the 02_network script always configures MAC addresses for
each individual LAN port unless "lan_mac_start" is set to "skip". This
behaviour can be unexpected, and is also somewhat broken, as it even
continues to do so when "lan_mac_start" is empty.

Change it to only do the configuration if "lan_mac_start" is non-empty,
and also remove the fallback to "lan_mac", making this more obvious and
less error-prone.

Signed-off-by: Jan Hoffmann <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/21644
Signed-off-by: Hauke Mehrtens <[email protected]>
Jan Hoffmann 2 tygodni temu
rodzic
commit
0686fed2b4

+ 6 - 3
target/linux/realtek/base-files/etc/board.d/02_network

@@ -60,6 +60,7 @@ realtek_setup_macs()
 	xikestor,sks8300-12e2t2x)
 		label_mac=$(get_mac_label)
 		lan_mac="$label_mac"
+		lan_mac_start=$lan_mac
 		;;
 	hpe,1920-8g|\
 	hpe,1920-8g-poe-65w|\
@@ -83,26 +84,29 @@ realtek_setup_macs()
 	plasmacloud,psx8|\
 	plasmacloud,psx10|\
 	plasmacloud,psx28)
-		lan_mac_start=skip
 		lan_mac="$(get_mac_label)"
 		;;
 	tplink,tl-st1008f-v2|\
 	zyxel,xgs1010-12-a1)
 		lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
 		[ -z "$lan_mac" ] || [ "$lan_mac" = "00:e0:4c:00:00:00" ] && lan_mac=$(macaddr_random)
+		lan_mac_start=$lan_mac
 		;;
 	xikestor,sks8300-8x)
 		lan_mac=$(mtd_get_mac_binary board-info 0x1f1)
+		lan_mac_start=$lan_mac
 		;;
 	xikestor,sks8310-8x)
 		lan_mac=$(mtd_get_mac_binary factory 0x80)
 		label_mac="$lan_mac"
+		lan_mac_start=$lan_mac
 		;;
 	*)
 		lan_mac=$(mtd_get_mac_ascii u-boot-env2 mac_start)
 		lan_mac_end=$(mtd_get_mac_ascii u-boot-env2 mac_end)
 		label_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
 		[ -z "$lan_mac" ] && lan_mac=$label_mac
+		lan_mac_start=$lan_mac
 		;;
 	esac
 
@@ -110,8 +114,7 @@ realtek_setup_macs()
 	[ -n "$lan_mac" ] && ucidef_set_bridge_mac "$lan_mac"
 	[ -n "$lan_mac" ] && ucidef_set_network_device_mac eth0 $lan_mac
 
-	[ -z "$lan_mac_start" -a -n "$lan_mac" ] && lan_mac_start=$lan_mac
-	[ "$lan_mac_start" != "skip" ] && realtek_setup_macs_lan "$lan_list" "$lan_mac_start" "$lan_mac_end"
+	[ -n "$lan_mac_start" ] && realtek_setup_macs_lan "$lan_list" "$lan_mac_start" "$lan_mac_end"
 
 	[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
 }