<div dir="ltr"><div>Ok systemd experts.  I finally got my DSA driver bonding feature working like I want it ... now I'd just like to know the best way for systemd to set everything up.  This is on a custom board based off an i.MX8M Mini EVK.  I built the latest Yocto Dunfell release for the OS.</div><div><br></div><div><div><span style="font-family:monospace"><span style="font-family:monospace">I know systemd has api support for some of this stuff but I haven't convinced myself I know how to take the manual steps above and put them in a systemd framework "the right way" based on the few web links I've seen about systemd doing this kind of thing.</span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace"><br></span></span></div></div><div></div><div>I manually configure/test the system this way (I made a script that I have systemd service call as a first step hack.  I don't have systemd-netword enabled):</div><div><br></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">root@imx8mmevk:/etc/systemd/system# cat enable-redundancy-bond.service  </span><br>[Unit]
<br>Description=Create redundancy bond
<br>
<br>[Service]
<br>ExecStart=/usr/local/bin/enable-redundant-bond.sh
<br>
<br>[Install]
<br>WantedBy=multi-user.target</span></div><div><span style="font-family:monospace"><br></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)">root@imx8mmevk:/usr/local/bin# cat enable-redundant-bond.sh  </span><br>#!/bin/bash
<br>
<br># Create a redundant bond between ksz9567 DSA lan1 and lan2 interfaces (lan1 is on left - toward light tubes, lan2 is on right - toward BNC connectors
<br>
<br># 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">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></span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace"><br></span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace">At this point lan1 and lan2 from my switch act as individual network interfaces and are bonded ... if I unplug one the other takes over and I can see their status by:</span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace"><br></span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace"><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">root@imx8mmevk:~# cat /proc/net/bonding/bond0
</span><br>Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
<br>
<br>Bonding Mode: fault-tolerance (active-backup)
<br>Primary Slave: None
<br>Currently Active Slave: lan1
<br>MII Status: up
<br>MII Polling Interval (ms): 1000
<br>Up Delay (ms): 0
<br>Down Delay (ms): 0
<br>Peer Notification Delay (ms): 0
<br>
<br>Slave Interface: lan1
<br>MII Status: up
<br>Speed: 1000 Mbps
<br>Duplex: full
<br>Link Failure Count: 0
<br>Permanent HW addr: 06:48:7f:9e:a8:1c
<br>Slave queue ID: 0
<br>
<br>Slave Interface: lan2
<br>MII Status: up
<br>Speed: 100 Mbps
<br>Duplex: full
<br>Link Failure Count: 1
<br>Permanent HW addr: 7a:d2:c1:ed:fe:a7
<br>Slave queue ID: 0
<br>root@imx8mmevk:~#<br></span></span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace"><br></span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace"><br></span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace"></span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace">Thanks in advance for educating me.<br></span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace"><br></span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace">Regards,</span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace"><br></span></span></div><div><span style="font-family:monospace"><span style="font-family:monospace">Brian<br></span></span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 13, 2020 at 8:56 AM Brian Hutchinson <<a href="mailto:b.hutchman@gmail.com">b.hutchman@gmail.com</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"><div dir="ltr"><div>Hi,</div><div><br></div><div>I have my device tree exposing two Microchip KSZ9567 switch ports.  I need to use them as individual NIC's.<br></div><div><br></div><div>I've tested the DSA driver as individual nics and they work fine.  I do this with:</div><div><br></div><div> <span>ip</span> addr add <a href="http://192.168.0.4/24" target="_blank">192.168.0.4/24</a> dev lan1</div><div><span>ip</span> addr add <a href="http://192.168.2.4/24" target="_blank">192.168.2.4/24</a> dev lan2</div><div><br></div><div><span>ip</span> <span>link</span> <span>set</span> eth0 up</div><div><span>ip</span> <span>link</span> <span>set</span> lan1 up</div><div><span>ip</span> <span>link</span> <span>set</span> lan2 up</div><div><br></div><div>... but I have no clue how to do this with /etc/systemd/network scripts</div><div><br></div><div>The above was just testing/verifying my device tree and DSA driver and a step toward real goal.  Once I get two of the switch ports (the only two the hardware brings out) to act as individual NIC's my next goal is to bond them for redundancy.</div><div><br></div><div>I really have no clue how to do that and have struggled to even uncover relevant information.  The closest thing I've found is:</div><div><br></div><div>A discussion of DSA issues<br></div><div><a href="https://github.com/systemd/systemd/issues/7478" target="_blank">https://github.com/systemd/systemd/issues/7478</a></div><div><br></div><div>Bonding but doesn't look like my DSA case.<br></div><div><a href="https://kerlilow.me/blog/setting-up-systemd-networkd-with-bonding/#setting-up-the-bond" target="_blank">https://kerlilow.me/blog/setting-up-systemd-networkd-with-bonding/#setting-up-the-bond</a></div><div><br></div><div>I tried the above link and it looked like all I did was create a switch loop as the LED's on my switch went crazy when I connected both of my ethernet ports.</div><div><br></div><div>Anyone have experience with systemd and DSA and bonding?</div><div><br></div><div>Regards,</div><div><br></div><div>Brian<br></div></div>
</blockquote></div>