[systemd-devel] Systemd setup DSA interfaces in port mode and bond them together?

Brian Hutchinson b.hutchman at gmail.com
Tue Nov 16 00:58:08 UTC 2021


Hi,

I'm on a IMX8 platform and have a Microchip KSZ9567 Ethernet switch.  I can
use IP commands to manually bring lan1 and lan2 interfaces up and then
create a redundant/failover bond ... but I'm having difficulty figuring out
how to do this the "systemd" way.

My first attempt was to just have systemd run a script of all the commands
I do manually but during system startup there appears to be race conditions
so I have to set my service type to "Idle" and sometimes even that doesn't
work. So I want to exploit any systemd support for DSA and bonding.

Here is script my manual steps which is what I want systemd to ultimately
do:

#!/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

Thanks for any information, pointers etc.

Regards,

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20211115/bbba4055/attachment.htm>


More information about the systemd-devel mailing list