redmine
Committed by Artyom A Anikeev

added bonding mode configuration support

... ... @@ -18,6 +18,8 @@
CMD="$1"; shift;
DEFAULT_BONDING_MODE='802.3ad'
eerror() {
echo "$@" >&2
}
... ... @@ -363,12 +365,27 @@ case "$CMD" in
#CREATING OF NECESSARY D1Q
for D1Q_IFACE in ${D1Q_IFACES[@]}; do
# Fixing bond-ifaces if exists
SLAVES_VARIABLE="${D1Q_IFACE}_SLAVES"
SLAVES_VARIABLE="${SLAVES_VARIABLE//[.]/_}[@]"
MODE_VARIABLE="${D1Q_IFACE}_MODE"
MODE="${!MODE_VARIABLE}"; [[ "$MODE" = "" ]] && MODE="$DEFAULT_BONDING_MODE"
D1Q_EXISTS=0
for OLD_D1Q_IFACE in ${OLD_D1Q_IFACES[@]}; do
if [[ "$D1Q_IFACE" == "$OLD_D1Q_IFACE" ]]; then #it's here. Let's fix it.
OLD_SLAVES="`cat /sys/class/net/"$OLD_D1Q_IFACE"/bonding/slaves`"
OLD_BONDING_MODE="`cat /sys/class/net/"$OLD_D1Q_IFACE"/bonding/mode`"
if [[ "$OLD_BONDING_MODE" != "${MODE}" ]]; then
for OLD_SLAVE in ${OLD_SLAVES[@]}; do
echo "-$OLD_SLAVE" > /sys/class/net/"$OLD_D1Q_IFACE"/bonding/slaves
done
ip link set dev "$OLD_D1Q_IFACE" down
echo "$MODE" > /sys/class/net/"$OLD_D1Q_IFACE"/bonding/mode
OLD_SLAVES=()
fi
for SLAVE in "${!SLAVES_VARIABLE}"; do
SLAVE_EXISTS=0
for OLD_SLAVE in ${OLD_SLAVES[@]}; do
... ... @@ -389,9 +406,11 @@ case "$CMD" in
fi
done
# Creating bond-ifaces
if [[ "$D1Q_EXISTS" == 0 ]]; then #make all
#echo "echo '+$D1Q_IFACE' > /sys/class/net/bonding_masters"
echo "+$D1Q_IFACE" > /sys/class/net/bonding_masters
echo "$MODE" > /sys/class/net/"$D1Q_IFACE"/bonding/mode
for SLAVE in "${!SLAVES_VARIABLE}"; do
#echo "ip link set dev $SLAVE down" #enslaved int should be shutted down
... ...
... ... @@ -5,6 +5,8 @@ D1Q_IFACES=(bond0 bond1)
bond0_SLAVES=(eth0 eth1)
bond1_SLAVES=(eth2)
bond0_MODE=balance-rr
# vlan.subvlan:bridge-name
# if vlan.subvlan is set to "" then bridge is created without creating (and enslaving) the vlan interface
# if bridge is set to "" then vlan interface is created without creating the bridge (to be enslaved by)
... ...