]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: don't implicitly configure port MAC addresses
authorJan Hoffmann <jan@3e8.eu>
Thu, 22 Jan 2026 19:21:35 +0000 (20:21 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Tue, 10 Feb 2026 00:39:52 +0000 (01:39 +0100)
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 <jan@3e8.eu>
Link: https://github.com/openwrt/openwrt/pull/21644
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/realtek/base-files/etc/board.d/02_network

index 32b41da0a9dbddc228398de384ee434022c10f39..f08579281e8fa730ef4588db4bcaf6ba3866c0fe 100644 (file)
@@ -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
 }