<div dir="ltr"><div dir="ltr"><div>Hi Alvin,</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 18, 2021 at 4:20 PM Alvin Šipraga <<a href="mailto:ALSI@bang-olufsen.dk">ALSI@bang-olufsen.dk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Brian,<br>
<br>
On 11/18/21 01:20, Brian Hutchinson wrote:<br>
> Yet another update, I was able to get it working .. but feel like it is<br>
> a hack so comments welcome ... see below:<br>
><br>
<br>
<snip><br>
<br>
><br>
> I tried and tried to get eth0 to come up before the bond was brought<br>
> up. I had everything named in lexical order but didn't appear to<br>
> matter. I added a eth0.network file and in it specified<br>
> |ActivationPolicy=|always-up and other things but could not get eth0 to<br>
> come up.<br>
<br>
What kernel version are you using? Since Linux 5.11 we have the <br></blockquote><div><br></div><div>I'm using linux-fslc-imx 5.10.69</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
following two changes ([1] and [2]) which should automatically bring <br>
up/down the master (eth0) whenever user ports (lan1, lan2) are brought <br>
up/down. Please confirm whether or not you are using 5.11 or later.<br></blockquote><div><br></div><div>I don't think that will work either. eth0 has to be up and stay up or DSA driver won't work at all. eth0 has to be up or the slaves can't be added to the bond.</div><div><br></div><div>If you look back up the thread where I'm doing the commands manually (I'll re-copy below) ... the first thing is to bring eth0 up. If that doesn't happen, nothing else works.</div><div><br></div><div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">These are the manual steps that work. This is what I'm trying to automate the "systemd way". I read that "bond0" is somehow reserved so my systemd.netdev and .network files use bond1.<br></span></span></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></span></span></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">#!/bin/bash
</span><br>
<br># Create a redundant bond between ksz9567 DSA lan1 and lan2 interfaces <br>
<br></span></div><div><span style="font-family:monospace"># Load bonding kernel module
<br>modprobe bonding
<br>
<br># Bring up CPU interface (cpu to switch port 7 - the RGMII link)
<br>ip link set eth0 up
<br>
<br># Create a bond
<br>echo +bond0 > /sys/class/net/bonding_masters
<br>
<br># Set mode to active-backup (redundancy failover)
<br>echo active-backup > /sys/class/net/bond0/bonding/mode
<br>
<br># Set time it takes (in ms) for slave to move when a link goes down
<br>echo 1000 > /sys/class/net/bond0/bonding/miimon
<br>
<br># Add slaves to bond
<br>
<br>echo +lan1 > /sys/class/net/bond0/bonding/slaves
<br>echo +lan2 > /sys/class/net/bond0/bonding/slaves
<br>
<br># Set IP and netmask of the bond
<br>ip addr add <a href="http://192.168.0.4/24" target="_blank">192.168.0.4/24</a> dev bond0
<br>
<br># And bring bond up. Pings and network connectivity should work now
<br>ip link set bond0 up
<br>
<br># For a board that doesn't have Ethernet switch hardware strapped to enable at boot .. enable it now
<br>i2cset -f -y 0 0x5f 0x03 0x00 0x01 i<br></span></div></div><div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
If you are using an older kernel, and systemd is version 243 or later, <br></blockquote><div><br></div><div>I checked and I'm using 244.5</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
you can use the BindCarrier= setting (see [1]) in the [Network] section <br>
of your .network file(s) for lan1 and lan2. Something like this:<br>
<br>
[Match]<br>
Name=lan*<br>
<br>
[Network]<br>
BindCarrier=eth0<br></blockquote><div><br></div><div>I added the BindCarrier=eth0 in both of my DSA lan1 and lan2 .network files. I got the same result as before ... dmesg reports lan1 and lan2 slaves are brought up before eth0 ... and so they fail. The only thing so far that works is to bring eth0 up with a network-pre.target service. And I'm doing the i2c command to enable my switch in a<code> After=network-online.target service.<br></code></div><div><br></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">[ 4.367802] bond1: (slave lan2): Opening slave failed
</span><br>[ 4.467561] bond1: (slave lan1): Opening slave failed</span></div><div><span style="font-family:monospace"><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">[ 4.640914] fec 30be0000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
</span><br>[ 5.104983] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready<br></span>
<br></span></div><div>Regards,</div><div><br></div><div>Brian<br>
</div></div></div>