diff mbox series

[1/3] base-files: failsafe: Fix IP configuration

Message ID 20210619183611.3334348-1-hauke@hauke-m.de
State Changes Requested
Delegated to: Hauke Mehrtens
Headers show
Series [1/3] base-files: failsafe: Fix IP configuration | expand

Commit Message

Hauke Mehrtens June 19, 2021, 6:36 p.m. UTC
Adapt the preinit_config_board() to the board.json network changes. It
now looks for the device and the ports variables to configure the LAN
network.

This works with swconfig configurations.

Fixes: FS#3866
Fixes: d42640e389a8 ("base-files: use "ports" array in board.json network for bridges")
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 .../files/lib/preinit/10_indicate_preinit      | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Comments

Martin Blumenstingl June 20, 2021, 2:42 p.m. UTC | #1
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.
On Sat, Jun 19, 2021 at 8:39 PM Hauke Mehrtens <hauke@hauke-m.de> wrote:
>
> Adapt the preinit_config_board() to the board.json network changes. It
> now looks for the device and the ports variables to configure the LAN
> network.
>
> This works with swconfig configurations.
>
> Fixes: FS#3866
> Fixes: d42640e389a8 ("base-files: use "ports" array in board.json network for bridges")
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> #
BT Home Hub 5A with DSA patches
Paul Spooren June 20, 2021, 10:42 p.m. UTC | #2
Not sure but is this PR related?

"base-files: bring up vlan interface too #2734"

https://github.com/openwrt/openwrt/pull/2734

On 6/19/21 8:36 AM, Hauke Mehrtens wrote:
> Adapt the preinit_config_board() to the board.json network changes. It
> now looks for the device and the ports variables to configure the LAN
> network.
>
> This works with swconfig configurations.
>
> Fixes: FS#3866
> Fixes: d42640e389a8 ("base-files: use "ports" array in board.json network for bridges")
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> ---
>   .../files/lib/preinit/10_indicate_preinit      | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
> index 3c5992979016..ae9fcfecc89e 100644
> --- a/package/base-files/files/lib/preinit/10_indicate_preinit
> +++ b/package/base-files/files/lib/preinit/10_indicate_preinit
> @@ -72,28 +72,34 @@ preinit_config_board() {
>   
>   	json_select network
>   		json_select "lan"
> -			json_get_vars ifname
> +			json_get_vars device
> +			json_get_values ports ports
>   		json_select ..
>   	json_select ..
>   
> -	[ -n "$ifname" ] || return
> +	[ -n "$device" -o -n "$ports" ] || return
> +
> +	# swconfig uses $device and DSA uses ports
> +	[ -z "$ports" ] && {
> +		ports="$device"
> +	}
>   
>   	# only use the first one
> -	ifname=${ifname%% *}
> +	ports=${ports%% *}
>   
>   	if [ -x /sbin/swconfig ]; then
>   		# configure the switch, if present
>   
>   		json_get_keys keys switch
>   		for key in $keys; do
> -			preinit_config_switch $key $ifname
> +			preinit_config_switch $key $ports
>   		done
>   	else
>   		# trim any vlan ids
> -		ifname=${ifname%\.*}
> +		ports=${ports%\.*}
>   	fi
>   
> -	pi_ifname=$ifname
> +	pi_ifname=$ports
>   
>   	preinit_ip_config $pi_ifname
>   }
Rafał Miłecki June 21, 2021, 1:58 p.m. UTC | #3
On 19.06.2021 20:36, Hauke Mehrtens wrote:
> Adapt the preinit_config_board() to the board.json network changes. It
> now looks for the device and the ports variables to configure the LAN
> network.
> 
> This works with swconfig configurations.
> 
> Fixes: FS#3866
> Fixes: d42640e389a8 ("base-files: use "ports" array in board.json network for bridges")
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

This fixes failsafe on bcm53xx (swconfig target). Thanks a lot.

Reviewed-by: Rafał Miłecki <rafal@milecki.pl>

[see 1 inline comment below]


>   .../files/lib/preinit/10_indicate_preinit      | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
> index 3c5992979016..ae9fcfecc89e 100644
> --- a/package/base-files/files/lib/preinit/10_indicate_preinit
> +++ b/package/base-files/files/lib/preinit/10_indicate_preinit
> @@ -72,28 +72,34 @@ preinit_config_board() {
>   
>   	json_select network
>   		json_select "lan"
> -			json_get_vars ifname
> +			json_get_vars device
> +			json_get_values ports ports
>   		json_select ..
>   	json_select ..
>   
> -	[ -n "$ifname" ] || return
> +	[ -n "$device" -o -n "$ports" ] || return
> +
> +	# swconfig uses $device and DSA uses ports
> +	[ -z "$ports" ] && {
> +		ports="$device"
> +	}
>   
>   	# only use the first one
> -	ifname=${ifname%% *}
> +	ports=${ports%% *}

Using "ports" variable up to this point is perfectly fine. Here however I think ifname would be more clear. What about:
ifname=${ports%% *}


>   	if [ -x /sbin/swconfig ]; then
>   		# configure the switch, if present
>   
>   		json_get_keys keys switch
>   		for key in $keys; do
> -			preinit_config_switch $key $ifname
> +			preinit_config_switch $key $ports
>   		done
>   	else
>   		# trim any vlan ids
> -		ifname=${ifname%\.*}
> +		ports=${ports%\.*}
>   	fi
>   
> -	pi_ifname=$ifname
> +	pi_ifname=$ports
>   
>   	preinit_ip_config $pi_ifname
>   }
Hauke Mehrtens June 21, 2021, 6:22 p.m. UTC | #4
On 6/21/21 12:42 AM, Paul Spooren wrote:
> Not sure but is this PR related?
> 
> "base-files: bring up vlan interface too #2734"
> 
> https://github.com/openwrt/openwrt/pull/2734
> 
This looks like a different problem, I am not sure if we run into it 
with our current code.

Hauke
Hauke Mehrtens June 21, 2021, 6:24 p.m. UTC | #5
On 6/21/21 3:58 PM, Rafał Miłecki wrote:
> On 19.06.2021 20:36, Hauke Mehrtens wrote:
>> Adapt the preinit_config_board() to the board.json network changes. It
>> now looks for the device and the ports variables to configure the LAN
>> network.
>>
>> This works with swconfig configurations.
>>
>> Fixes: FS#3866
>> Fixes: d42640e389a8 ("base-files: use "ports" array in board.json 
>> network for bridges")
>> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> 
> This fixes failsafe on bcm53xx (swconfig target). Thanks a lot.
> 
> Reviewed-by: Rafał Miłecki <rafal@milecki.pl>
> 
> [see 1 inline comment below]
> 
> 
>>   .../files/lib/preinit/10_indicate_preinit      | 18 ++++++++++++------
>>   1 file changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit 
>> b/package/base-files/files/lib/preinit/10_indicate_preinit
>> index 3c5992979016..ae9fcfecc89e 100644
>> --- a/package/base-files/files/lib/preinit/10_indicate_preinit
>> +++ b/package/base-files/files/lib/preinit/10_indicate_preinit
>> @@ -72,28 +72,34 @@ preinit_config_board() {
>>       json_select network
>>           json_select "lan"
>> -            json_get_vars ifname
>> +            json_get_vars device
>> +            json_get_values ports ports
>>           json_select ..
>>       json_select ..
>> -    [ -n "$ifname" ] || return
>> +    [ -n "$device" -o -n "$ports" ] || return
>> +
>> +    # swconfig uses $device and DSA uses ports
>> +    [ -z "$ports" ] && {
>> +        ports="$device"
>> +    }
>>       # only use the first one
>> -    ifname=${ifname%% *}
>> +    ports=${ports%% *}
> 
> Using "ports" variable up to this point is perfectly fine. Here however 
> I think ifname would be more clear. What about:
> ifname=${ports%% *}

I will change it to ifname

Hauke
diff mbox series

Patch

diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
index 3c5992979016..ae9fcfecc89e 100644
--- a/package/base-files/files/lib/preinit/10_indicate_preinit
+++ b/package/base-files/files/lib/preinit/10_indicate_preinit
@@ -72,28 +72,34 @@  preinit_config_board() {
 
 	json_select network
 		json_select "lan"
-			json_get_vars ifname
+			json_get_vars device
+			json_get_values ports ports
 		json_select ..
 	json_select ..
 
-	[ -n "$ifname" ] || return
+	[ -n "$device" -o -n "$ports" ] || return
+
+	# swconfig uses $device and DSA uses ports
+	[ -z "$ports" ] && {
+		ports="$device"
+	}
 
 	# only use the first one
-	ifname=${ifname%% *}
+	ports=${ports%% *}
 
 	if [ -x /sbin/swconfig ]; then
 		# configure the switch, if present
 
 		json_get_keys keys switch
 		for key in $keys; do
-			preinit_config_switch $key $ifname
+			preinit_config_switch $key $ports
 		done
 	else
 		# trim any vlan ids
-		ifname=${ifname%\.*}
+		ports=${ports%\.*}
 	fi
 
-	pi_ifname=$ifname
+	pi_ifname=$ports
 
 	preinit_ip_config $pi_ifname
 }