From 0a56b2cc22e7ee4e2e8ea926fc0ff81cbc299d34 Mon Sep 17 00:00:00 2001 From: Jirka Klimes Date: Thu, 5 Jun 2014 16:06:49 +0200 Subject: network-functions: handle BONDING_OPTS better --- sysconfig/network-scripts/network-functions | 32 ++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'sysconfig/network-scripts') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index a76d7432..8a9028fc 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -445,10 +445,36 @@ install_bonding_driver () if [ -f /sys/class/net/${DEVICE}/bonding/slaves -a $(wc -l < /sys/class/net/${DEVICE}/bonding/slaves) -eq 0 ]; then /sbin/ip link set dev ${DEVICE} down - # add the bits to setup driver parameters here + # parse options and put them to arrays for arg in $BONDING_OPTS ; do - key=${arg%%=*}; - value=${arg##*=}; + bopts_keys[${#bopts_keys[*]}]=${arg%%=*} + bopts_vals[${#bopts_vals[*]}]=${arg##*=} + done + + # add the bits to setup driver parameters here + # first set mode, miimon + for (( idx=0; idx < ${#bopts_keys[*]}; idx++ )) ; do + key=${bopts_keys[$idx]} + value=${bopts_vals[$idx]} + + if [ "${key}" = "mode" ] ; then + echo "${value}" > /sys/class/net/${DEVICE}/bonding/$key + bopts_keys[$idx]="" + fi + if [ "${key}" = "miimon" ] ; then + echo "${value}" > /sys/class/net/${DEVICE}/bonding/$key + bopts_keys[$idx]="" + fi + done + + # set all other remaining options + for (( idx=0; idx < ${#bopts_keys[*]}; idx++ )) ; do + key=${bopts_keys[$idx]} + value=${bopts_vals[$idx]} + + # option already set; take next + [[ -z "$key" ]] && continue + if [ "${key}" = "arp_ip_target" -a "${value:0:1}" != "+" ]; then OLDIFS=$IFS; IFS=','; -- cgit v1.2.1