[systemd-devel] Systemd setup DSA interfaces in port mode and bond them together?
Brian Hutchinson
b.hutchman at gmail.com
Thu Nov 18 22:25:20 UTC 2021
Hi Alvin,
On Thu, Nov 18, 2021 at 4:20 PM Alvin Šipraga <ALSI at bang-olufsen.dk> wrote:
> Hi Brian,
>
> On 11/18/21 01:20, Brian Hutchinson wrote:
> > Yet another update, I was able to get it working .. but feel like it is
> > a hack so comments welcome ... see below:
> >
>
> <snip>
>
> >
> > I tried and tried to get eth0 to come up before the bond was brought
> > up. I had everything named in lexical order but didn't appear to
> > matter. I added a eth0.network file and in it specified
> > |ActivationPolicy=|always-up and other things but could not get eth0 to
> > come up.
>
> What kernel version are you using? Since Linux 5.11 we have the
>
I'm using linux-fslc-imx 5.10.69
following two changes ([1] and [2]) which should automatically bring
> up/down the master (eth0) whenever user ports (lan1, lan2) are brought
> up/down. Please confirm whether or not you are using 5.11 or later.
>
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.
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.
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.
#!/bin/bash
# Create a redundant bond between ksz9567 DSA lan1 and lan2 interfaces
# Load bonding kernel module
modprobe bonding
# Bring up CPU interface (cpu to switch port 7 - the RGMII link)
ip link set eth0 up
# Create a bond
echo +bond0 > /sys/class/net/bonding_masters
# Set mode to active-backup (redundancy failover)
echo active-backup > /sys/class/net/bond0/bonding/mode
# Set time it takes (in ms) for slave to move when a link goes down
echo 1000 > /sys/class/net/bond0/bonding/miimon
# Add slaves to bond
echo +lan1 > /sys/class/net/bond0/bonding/slaves
echo +lan2 > /sys/class/net/bond0/bonding/slaves
# Set IP and netmask of the bond
ip addr add 192.168.0.4/24 dev bond0
# And bring bond up. Pings and network connectivity should work now
ip link set bond0 up
# For a board that doesn't have Ethernet switch hardware strapped to enable
at boot .. enable it now
i2cset -f -y 0 0x5f 0x03 0x00 0x01 i
> If you are using an older kernel, and systemd is version 243 or later,
>
I checked and I'm using 244.5
you can use the BindCarrier= setting (see [1]) in the [Network] section
> of your .network file(s) for lan1 and lan2. Something like this:
>
> [Match]
> Name=lan*
>
> [Network]
> BindCarrier=eth0
>
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
After=network-online.target service.
[ 4.367802] bond1: (slave lan2): Opening slave failed
[ 4.467561] bond1: (slave lan1): Opening slave failed
[ 4.640914] fec 30be0000.ethernet eth0: Link is Up - 1Gbps/Full - flow
control off
[ 5.104983] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Regards,
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20211118/bb71302f/attachment-0001.htm>
More information about the systemd-devel
mailing list