Prechádzať zdrojové kódy

realtek: avoid redundant configuration of MAC addresses

Only configure the eth0 MAC address when it is not already done in the
device tree. To do this, create a new variable "eth0_mac".

Also avoid setting "label_mac" for devices already having it defined in
the device tree.

Signed-off-by: Jan Hoffmann <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/21644
Signed-off-by: Hauke Mehrtens <[email protected]>
Jan Hoffmann 3 týždňov pred
rodič
commit
08ab732b25

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

@@ -45,6 +45,7 @@ realtek_setup_macs()
 	local board="$1"
 	local lan_list="$2"
 
+	local eth0_mac=""
 	local lan_mac=""
 	local lan_mac_start=""
 	local lan_mac_end=""
@@ -58,8 +59,7 @@ realtek_setup_macs()
 	tplink,t1600g-28ts-v3|\
 	xikestor,sks8300-8t|\
 	xikestor,sks8300-12e2t2x)
-		label_mac=$(get_mac_label)
-		lan_mac="$label_mac"
+		lan_mac=$(get_mac_label)
 		lan_mac_start=$lan_mac
 		;;
 	hpe,1920-8g|\
@@ -73,6 +73,7 @@ realtek_setup_macs()
 	hpe,1920-48g-poe)
 		label_mac=$(mtd_get_mac_binary factory 0x68)
 		lan_mac=$label_mac
+		eth0_mac=$lan_mac
 		mac_count1=$(hexdump -v -n 4 -s 0x110 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null)
 		mac_count2=$(hexdump -v -n 4 -s 0x114 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null)
 		lan_mac_start=$(macaddr_add $lan_mac 2)
@@ -91,15 +92,18 @@ realtek_setup_macs()
 		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
+		eth0_mac=$lan_mac
 		;;
 	xikestor,sks8300-8x)
 		lan_mac=$(mtd_get_mac_binary board-info 0x1f1)
 		lan_mac_start=$lan_mac
+		eth0_mac=$lan_mac
 		;;
 	xikestor,sks8310-8x)
 		lan_mac=$(mtd_get_mac_binary factory 0x80)
 		label_mac="$lan_mac"
 		lan_mac_start=$lan_mac
+		eth0_mac=$lan_mac
 		;;
 	allnet,all-sg8208m|\
 	apresia,aplgs120gtss|\
@@ -154,12 +158,14 @@ realtek_setup_macs()
 		label_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
 		[ -z "$lan_mac" ] && lan_mac=$label_mac
 		lan_mac_start=$lan_mac
+		eth0_mac=$lan_mac
 		;;
 	esac
 
+	[ -n "$eth0_mac" ] && ucidef_set_network_device_mac eth0 $eth0_mac
+
 	[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
 	[ -n "$lan_mac" ] && ucidef_set_bridge_mac "$lan_mac"
-	[ -n "$lan_mac" ] && ucidef_set_network_device_mac eth0 $lan_mac
 
 	[ -n "$lan_mac_start" ] && realtek_setup_macs_lan "$lan_list" "$lan_mac_start" "$lan_mac_end"