sivel/bonding — pull request #8 by biyiklioglu (2014-06-29 15:06:00+00:00)
Title: Corrected the set_iface_flag function to work for interfaces named with more than 4 chars (e.g., eth10, eth11 ...).

Hi,

Firstly thank you very much for this great script. It removes the burden of finding the bonding pairs if you have a large number of interfaces.

Unfortunately, bonding.py didn't work for a system with more than 10 interfaces.

The problem is:

set_iface_flag function function does not work for interfaces named with more than 4 chars (e.g., eth10, eth11 ...)

Because, ifname is assumed to have 4 chars on line 145:
ifreq = struct.pack('4s12xH', ifname, flags)

Since, set_iface_flag is used in the peers detection to enable the DOWN interfaces, It can not enable interfaces eth10, eth11, etc. and the peers detection does not work as expected.

I am not sure whether we have to hard-code the interface name length but I have made it to work for me by changing the line to

ifreq = struct.pack('16sH', ifname, flags)