Bonding of hotpluggable interface fails after un- and re-plug the last device
0
votes
0
answers
80
views
I want to bond the network interfaces of two USB-tethered android phones connected to a Raspberry Pi 4. So when one person leaves and takes his phone, it "fail-overs" to the second phone without a short interruption you would normally have without bonding.
The problem is that the bonding network interface disappears when I remove and replug the last phone (and activate USB tethering again).
This is how I set up the bonding interface. I use
systemd-networkd
:
/etc/systemd/network/bond1.netdev
[NetDev]
Name=bond1
Description=Bonds usb network interfaces
Kind=bond
[Bond]
Mode=active-backup
MIIMonitorSec=100
/etc/systemd/network/bond1.network
[Match]
Name=usb*
[Network]
Bond=bond1
/etc/systemd/network/bond1-net.network
[Match]
Name=bond1
[Network]
DHCP=yes
This configuration seems to work as long as at least one usb network interface is there and is not removed/replugged. As soon as I un- and replug (i.e. not upon removal) the last phone and activate USB-tethering the usb0
network interface appears again and bond1
immediatly disappears and I have to restart systemd-networkd
to let it reappear again.
After removing all bonded usb network interface ip link
still lists bond1:
5: bond1: mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
link/ether 4e:db:45:d2:25:c0 brd ff:ff:ff:ff:ff:ff
After replugging and enabling usb tethering bond1
is gone and dmesg
says:
[ 1345.285781] bond1: (slave usb0): making interface the new active one
[ 1345.286004] bond1: (slave usb0): Enslaving as an active interface with an up link
[ 1346.647947] bond1: (slave usb0): Releasing backup interface
[ 1346.682264] bond1 (unregistering): Released all slaves
So at first it re-adds the usb interface again but then releases all interfaces and unregisters bond1
.
Then I tried to find a solution and found the following hints:
Add these lines to /etc/systemd/network/bond1.netdev
[NetDev]
Name=bond1
Kind=bond
Removable=no # Added
[Bond]
Mode=active-backup
MiimonSec=100
PrimaryReselectPolicy=better # Added
IgnoreCarrierLoss=1 # Added
And add udev rules to manually re-add the usb interfaces:
SUBSYSTEM=="net", ACTION=="add", KERNEL=="usb0", RUN+="/usr/bin/ip link set usb0 master bond1"
SUBSYSTEM=="net", ACTION=="add", KERNEL=="usb1", RUN+="/usr/bin/ip link set usb1 master bond1"
But that does not help or change the behavior in any way. Does anyone know what might help to fix this problem?
Asked by Michaelvsk
(103 rep)
Sep 26, 2024, 05:22 PM