diff mbox series

[2/3] base-files: failsafe: Start also CPU interface for DSA

Message ID 20210619183611.3334348-2-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
On a DSA switch the ports have an upper device, the CPU device, e.g.
eth0. This device has to be in up state to bring up the lower devices
like lan1.

Parse the link device from "ip link show" and bring it into up stated
before bringing up the actual interface.

This is needed to make network in failsafe on systems with DSA work.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 package/base-files/files/lib/preinit/10_indicate_preinit | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Qingfang Deng June 20, 2021, 8:32 a.m. UTC | #1
On Sat, Jun 19, 2021 at 08:36:10PM +0200, Hauke Mehrtens wrote:
> On a DSA switch the ports have an upper device, the CPU device, e.g.
> eth0. This device has to be in up state to bring up the lower devices
> like lan1.
> 
> Parse the link device from "ip link show" and bring it into up stated
> before bringing up the actual interface.
> 
> This is needed to make network in failsafe on systems with DSA work.


Hi Hauke,

You may instead backport the upstream commit 9d5ef190e561
("net: dsa: automatically bring up DSA master when opening user port").

> 
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> ---
>  package/base-files/files/lib/preinit/10_indicate_preinit | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
> index ae9fcfecc89e..a3bc289dd663 100644
> --- a/package/base-files/files/lib/preinit/10_indicate_preinit
> +++ b/package/base-files/files/lib/preinit/10_indicate_preinit
> @@ -12,6 +12,12 @@ preinit_ip_config() {
>  	fi
>  
>  	grep -q "$netdev" /proc/net/dev || return
> +	
> +	# Get the link interface e.g. eth0 in lan1@eth0
> +	iflink=$(ip link show dev ${netdev} |sed -nr 's/.*@([a-zA-Z0-9]*): .*/\1/p')
> +	if [ -n "$iflink" ]; then
> +		ip link set dev $iflink up
> +	fi
>  
>  	if [ -n "$vid" ]; then
>  		ip link add link $netdev name $1 type vlan id $vid
Sven Roederer June 20, 2021, 2:30 p.m. UTC | #2
Am Samstag, 19. Juni 2021, 20:36:10 CEST schrieb Hauke Mehrtens:
> On a DSA switch the ports have an upper device, the CPU device, e.g.
> eth0. This device has to be in up state to bring up the lower devices
> like lan1.
> 
> Parse the link device from "ip link show" and bring it into up stated
> before bringing up the actual interface.
> 
> This is needed to make network in failsafe on systems with DSA work.
> 

Hauke, 

I tested you patches on the Mikrotik RB750Gr3 and WDR3600 (as I did in 
FS#3866), this time with customized IP-adresses and patches applied to 
OpenWrt-21.02.
For the WDR3600 the issue was fixed, but for the RB750 there is no network.
I was not able to usr IPv6 link-local, OpenWrt default 192.168.1.1 or my 
custom IP-Address.

The Rb750 is DSA, so it seems there is still something wrong. I'll retest with 
current master soon, to rule out issues based on 21.02-rc3.

Sven
Martin Blumenstingl June 20, 2021, 2:43 p.m. UTC | #3
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:
>
> On a DSA switch the ports have an upper device, the CPU device, e.g.
> eth0. This device has to be in up state to bring up the lower devices
> like lan1.
>
> Parse the link device from "ip link show" and bring it into up stated
> before bringing up the actual interface.
>
> This is needed to make network in failsafe on systems with DSA work.
>
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
if you're keeping this patch instead of going with the backport you can add my:
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> #
BT Home Hub 5A with DSA patches
Hauke Mehrtens June 20, 2021, 3:11 p.m. UTC | #4
On 6/20/21 4:30 PM, Sven Roederer wrote:
> Am Samstag, 19. Juni 2021, 20:36:10 CEST schrieb Hauke Mehrtens:
>> On a DSA switch the ports have an upper device, the CPU device, e.g.
>> eth0. This device has to be in up state to bring up the lower devices
>> like lan1.
>>
>> Parse the link device from "ip link show" and bring it into up stated
>> before bringing up the actual interface.
>>
>> This is needed to make network in failsafe on systems with DSA work.
>>
> 
> Hauke,
> 
> I tested you patches on the Mikrotik RB750Gr3 and WDR3600 (as I did in
> FS#3866), this time with customized IP-adresses and patches applied to
> OpenWrt-21.02.
> For the WDR3600 the issue was fixed, but for the RB750 there is no network.
> I was not able to usr IPv6 link-local, OpenWrt default 192.168.1.1 or my
> custom IP-Address.
> 
> The Rb750 is DSA, so it seems there is still something wrong. I'll retest with
> current master soon, to rule out issues based on 21.02-rc3.
> 
> Sven

Hi,

I tried it on a lantiq device with the DSA patches applied and it works 
fine.

Could you please share the content of this file: /tmp/board.json
and the output of "ip addr" while in failsafe on a broken device please.

You need all 3 patches and I am not aware of a difference between master 
and 21.02 in this area, but I only tried it on top of master.

Hauke
Hauke Mehrtens June 20, 2021, 3:13 p.m. UTC | #5
On 6/20/21 10:32 AM, DENG Qingfang wrote:
> On Sat, Jun 19, 2021 at 08:36:10PM +0200, Hauke Mehrtens wrote:
>> On a DSA switch the ports have an upper device, the CPU device, e.g.
>> eth0. This device has to be in up state to bring up the lower devices
>> like lan1.
>>
>> Parse the link device from "ip link show" and bring it into up stated
>> before bringing up the actual interface.
>>
>> This is needed to make network in failsafe on systems with DSA work.
> 
> 
> Hi Hauke,
> 
> You may instead backport the upstream commit 9d5ef190e561
> ("net: dsa: automatically bring up DSA master when opening user port").

Thanks for the hint, I was not aware of this patch.

I tried this kernel patch and it works good without my script patch, I 
anyway do not like the parsing of the "ip link show" output.

I would prefer to just backport this kernel patch instead, it applies 
without problems.

Hauke
Rafał Miłecki June 21, 2021, 2:57 p.m. UTC | #6
On 19.06.2021 20:36, Hauke Mehrtens wrote:
> On a DSA switch the ports have an upper device, the CPU device, e.g.
> eth0. This device has to be in up state to bring up the lower devices
> like lan1.
> 
> Parse the link device from "ip link show" and bring it into up stated
> before bringing up the actual interface.
> 
> This is needed to make network in failsafe on systems with DSA work.
> 
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

Idea behind this patch sounds OK (screen scraping of "ip" maybe a bit less).

The problem is this patch *breaks* network on normal (non-failsafe)
bcm4908 (DSA target) boot. I don't know why. In ifconfig interfaces look
OK. In "brctl show" everything seems fine too.

I've to keep debugging that problem. Meanwhile I'll also try kernel
patch.

This patch doesn't affect (break or fix) bcm53xx with swconfig.
Rafał Miłecki June 21, 2021, 3:27 p.m. UTC | #7
On 21.06.2021 16:57, Rafał Miłecki wrote:
> On 19.06.2021 20:36, Hauke Mehrtens wrote:
>> On a DSA switch the ports have an upper device, the CPU device, e.g.
>> eth0. This device has to be in up state to bring up the lower devices
>> like lan1.
>>
>> Parse the link device from "ip link show" and bring it into up stated
>> before bringing up the actual interface.
>>
>> This is needed to make network in failsafe on systems with DSA work.
>>
>> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> 
> Idea behind this patch sounds OK (screen scraping of "ip" maybe a bit less).
> 
> The problem is this patch *breaks* network on normal (non-failsafe)
> bcm4908 (DSA target) boot. I don't know why. In ifconfig interfaces look
> OK. In "brctl show" everything seems fine too.
> 
> I've to keep debugging that problem. Meanwhile I'll also try kernel
> patch.
> 
> This patch doesn't affect (break or fix) bcm53xx with swconfig.

I forgot to tell: it *does* fix failsafe on bcm4908 (DSA target). It
just breaks normal boot network.

I tested kernel commit 9d5ef190e561 ("net: dsa: automatically bring up
DSA master when opening user port") and it breaks by network on bcm4908
just the same. So maybe it's some kernel / b53 / bcm4908enet bug. I'll
keep debugging that.
Sven Roederer June 24, 2021, 9:13 p.m. UTC | #8
Am Sonntag, 20. Juni 2021, 17:11:08 CEST schrieb Hauke Mehrtens:
> On 6/20/21 4:30 PM, Sven Roederer wrote:
> > 
> > The Rb750 is DSA, so it seems there is still something wrong. I'll retest
> > with current master soon, to rule out issues based on 21.02-rc3.
> > 
> > Sven
> 
> Hi,
> 
> I tried it on a lantiq device with the DSA patches applied and it works
> fine.
> 

Hauke,

I found some tme to test and and confirm the this patch-series also fixes the 
issue on the RB750Gr3 with DSA.
As it takes much longer till the network is up, in comparison to 19.07, it 
seems that I gave up to quickly.

IÄve seen you pushed some updated patch-sets already, so my comment here might 
be only for reference.

Sven
Hauke Mehrtens June 26, 2021, 11:10 a.m. UTC | #9
On 6/24/21 11:13 PM, Sven Roederer wrote:
> Am Sonntag, 20. Juni 2021, 17:11:08 CEST schrieb Hauke Mehrtens:
>> On 6/20/21 4:30 PM, Sven Roederer wrote:
>>>
>>> The Rb750 is DSA, so it seems there is still something wrong. I'll retest
>>> with current master soon, to rule out issues based on 21.02-rc3.
>>>
>>> Sven
>>
>> Hi,
>>
>> I tried it on a lantiq device with the DSA patches applied and it works
>> fine.
>>
> 
> Hauke,
> 
> I found some tme to test and and confirm the this patch-series also fixes the
> issue on the RB750Gr3 with DSA.
> As it takes much longer till the network is up, in comparison to 19.07, it
> seems that I gave up to quickly.
> 
> IÄve seen you pushed some updated patch-sets already, so my comment here might
> be only for reference.

Hi Sven,

Thanks for reporting back.

These patches should fix networking in failsafe for all targets. I am 
surprised that it takes long till the networking in failsafe works on 
the RB750Gr3 (mt7621), but if it works at all this is already good.

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 ae9fcfecc89e..a3bc289dd663 100644
--- a/package/base-files/files/lib/preinit/10_indicate_preinit
+++ b/package/base-files/files/lib/preinit/10_indicate_preinit
@@ -12,6 +12,12 @@  preinit_ip_config() {
 	fi
 
 	grep -q "$netdev" /proc/net/dev || return
+	
+	# Get the link interface e.g. eth0 in lan1@eth0
+	iflink=$(ip link show dev ${netdev} |sed -nr 's/.*@([a-zA-Z0-9]*): .*/\1/p')
+	if [ -n "$iflink" ]; then
+		ip link set dev $iflink up
+	fi
 
 	if [ -n "$vid" ]; then
 		ip link add link $netdev name $1 type vlan id $vid