diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 8355099c355..5293ce12c0e 100644 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -122,6 +122,11 @@ ucidef_set_network_device_path() { _ucidef_set_network_device_common $1 path $2 } +ucidef_set_network_device_path_port() { + _ucidef_set_network_device_common $1 path $2 + _ucidef_set_network_device_common $1 port $3 +} + ucidef_set_network_device_gro() { _ucidef_set_network_device_common $1 gro $2 } diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit index a8f7758c841..12f8fc2e210 100644 --- a/package/base-files/files/lib/preinit/10_indicate_preinit +++ b/package/base-files/files/lib/preinit/10_indicate_preinit @@ -65,12 +65,27 @@ preinit_config_switch() { preinit_config_port() { local original + local dev_port local netdev="$1" local path="$2" + local port="$3" [ -d "/sys/devices/$path/net" ] || return - original="$(ls "/sys/devices/$path/net" | head -1)" + + if [ -z "$port" ]; then + original="$(ls "/sys/devices/$path/net" | head -1)" + else + for device in /sys/devices/$path/net/*; do + dev_port="$(cat "$device/dev_port")" + if [ "$dev_port" = "$port" ]; then + original="${device##*/}" + break + fi + done + + [ -z "$original" ] && return + fi [ "$netdev" = "$original" ] && return @@ -109,7 +124,8 @@ preinit_config_board() { json_select "network_device" json_select "$netdev" json_get_vars path path - [ -n "$path" ] && preinit_config_port "$netdev" "$path" + json_get_vars port port + [ -n "$path" ] && preinit_config_port "$netdev" "$path" "$port" json_select .. json_select .. done