Using bonding with Xen bridging on RHEL5

I ran into a chicken and egg problem recently, while trying to configure Xen’s bridging interfaces on top of bonding interfaces.

This setup is for HA (High Availability), since with 4 network interfaces on the system, connected to two different switch cards or stack units, and configured as 2 LACP bonding interfaces in RHEL5, you can have any network cable or switch card/unit go down in flames and still have the network working.

The problem is that RHEL5 apparently always starts the bonding interfaces before the bridging interfaces. And for interfaces to be part of a bridge, they must be brought up after the bridge. This is the case and works fine with regular ethernet interfaces, but not with bonding interfaces (based on my own testing).

I’ve tried looking for some options to put in the ifcfg-* files to no avail. Maybe there is something I’ve missed… so then I dug deeper and saw this interesting bit at the very bottom of the /etc/sysconfig/network-scripts/ifup-post file :

if [ -x /sbin/ifup-local ]; then
    /sbin/ifup-local ${DEVICE}

So since that program doesn’t exist by default, I hacked up a quick one that does what I need, namely add the already started bonding interfaces to the bridging interfaces when they are finally started. Here it is :

# Ugly way to get bonding interfaces into bridges, since the bonding are
# started before the bridges by init scripts, thus can't be added to the
# bridges initially. We add bonding here, when bridges go up.
# Note that we check for "BRIDGE=br0" in the ifcfg-bond0 anyway, so it needs
# to be present at least commented out as "#BRIDGE=br0" to work.


case "${IFNUM}" in
    grep -q "BRIDGE=${IFACE}" /etc/sysconfig/network-scripts/ifcfg-bond${IFNUM} && brctl addif ${IFACE} bond${IFNUM} &>/dev/null
    exit 0

Adapt to your bridges names, but that’s it. Things now work as intended.

Leave a Reply

Your email address will not be published. Required fields are marked *