[openwrt/openwrt] realtek: avoid redundant configuration of MAC addresses
LEDE Commits
lede-commits at lists.infradead.org
Mon Feb 9 16:40:29 PST 2026
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/08ab732b25de8dd1643837d4432be2f1e6856f69
commit 08ab732b25de8dd1643837d4432be2f1e6856f69
Author: Jan Hoffmann <jan at 3e8.eu>
AuthorDate: Thu Jan 22 20:30:10 2026 +0100
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 <jan at 3e8.eu>
Link: https://github.com/openwrt/openwrt/pull/21644
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
target/linux/realtek/base-files/etc/board.d/02_network | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/target/linux/realtek/base-files/etc/board.d/02_network b/target/linux/realtek/base-files/etc/board.d/02_network
index b06829c3d0..7b32997d61 100644
--- a/target/linux/realtek/base-files/etc/board.d/02_network
+++ b/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"
More information about the lede-commits
mailing list