4 # bond=<bondname>[:<bondslaves>:[:<options>]]
6 # bondslaves is a comma-separated list of physical (ethernet) interfaces
7 # options is a comma-separated list on bonding options (modinfo bonding for details) in format compatible with initscripts
8 # if options include multi-valued arp_ip_target option, then its values should be separated by semicolon.
10 # bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr
13 # return if bond already parsed
14 [ -n "$bondname" ] && return
16 # Check if bond parameter is valid
17 if getarg bond= >/dev/null ; then
21 # We translate list of slaves to space-separated here to mwke it easier to loop over them in ifup
22 # Ditto for bonding options
27 set -- "$@" "${v%%:*}"
31 unset bondname bondslaves bondoptions
33 0) bondname=bond0; bondslaves="eth0 eth1" ;;
34 1) bondname=$1; bondslaves="eth0 eth1" ;;
35 2) bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;;
36 3) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;;
37 *) die "bond= requires zero to four parameters" ;;
41 unset bondname bondslaves bondoptions
43 # Parse bond for bondname, bondslaves, bondmode and bondoptions
44 if getarg bond >/dev/null; then
45 # Read bond= parameters if they exist
46 bond="$(getarg bond=)"
47 if [ ! "$bond" = "bond" ]; then
48 parsebond "$(getarg bond=)"
51 if [ -z "$bondname" ]; then
53 bondslaves="eth0 eth1"
55 # Make it suitable for initscripts export
56 bondoptions=$(str_replace "$bondoptions" ";" ",")
57 echo "bondname=$bondname" > /tmp/bond.info
58 echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.info
59 echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.info