Set bond primary

adamb

Famous Member
Mar 1, 2012
1,322
72
113
Trying to figure out how to set the primary slave on an active-backup setup.

Code:
root@tapecephhost2:~# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None               <--------- There has to be a way to set this?
Currently Active Slave: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth2
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: a0:36:9f:4e:b7:50
Slave queue ID: 0

Slave Interface: eth4
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: a0:36:9f:52:16:c0
Slave queue ID: 0

From what I have read I should be able to simply set bond_primary and it should work but it doesn't seem to. Does anyone know how to achieve this? I want one nic in the active-backup setup to be primary at all times when it is connected. This should be quite simple.
 
an old debian bug, It has long been in debian bugzilla
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699445

my patch:

Code:
--- /etc/network/if-pre-up.d/ifenslave.old       2015-05-22 17:12:59.181899294 +0500
+++ /etc/network/if-pre-up.d/ifenslave  2014-12-11 16:40:39.000000000 +0500
@@ -103,6 +103,16 @@
                        fi
                fi
        done
+
+       # primary must be set after mode (because only supported in some modes) and after enslavement.
+       # The first slave in bond-primary found in current slaves becomes the primary.
+       # If no slave in bond-primary is found, then primary does not change.
+       for slave in $IF_BOND_PRIMARY ; do
+               if grep -sq "\\<$slave\\>" "/sys/class/net/$BOND_MASTER/bonding/slaves" ; then
+                       sysfs primary "$slave"
+                       break
+               fi
+       done
 }

 setup_master()
 
Last edited:
an old debian bug, It has long been in debian bugzilla
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699445

my patch:

--- /etc/network/if-pre-up.d/ifenslave.old 2015-05-22 17:12:59.181899294 +0500
+++ /etc/network/if-pre-up.d/ifenslave 2014-12-11 16:40:39.000000000 +0500
@@ -103,6 +103,16 @@
fi
fi
done
+
+ # primary must be set after mode (because only supported in some modes) and after enslavement.
+ # The first slave in bond-primary found in current slaves becomes the primary.
+ # If no slave in bond-primary is found, then primary does not change.
+ for slave in $IF_BOND_PRIMARY ; do
+ if grep -sq "\\<$slave\\>" "/sys/class/net/$BOND_MASTER/bonding/slaves" ; then
+ sysfs primary "$slave"
+ break
+ fi
+ done
}

setup_master()

Per the link it looks like it was fixed. Im not quite sure how to apply the patch, or do I need to look for a newer version if ifenslave? I appreciate the input!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!