Search
j0ke.net Open Build Service
>
Projects
>
GFS
>
sysconfig
> sysconfig_ifup_set_bonding_options_twice.190377.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File sysconfig_ifup_set_bonding_options_twice.190377.patch of Package sysconfig (Revision 1)
Currently displaying revision
1
,
show latest
--- scripts/functions 2006-06-02 11:51:54.000000000 +0000 +++ scripts/functions 2006-12-10 10:54:44.000000000 +0000 @@ -151,8 +151,15 @@ # Usage: load_bond $INTERFACE $BONDING_MODULE_OPTIONS # Module option 'max_bonds' will be ignored. Use one configuration file per # bonding interface instead. +# If first argument is '_no_fail_' then failures in setting interface options +# will not return an error. load_bond() { - local NIF OPT OPT_NAME OPT_VALUE IF=$1 + local NIF OPT OPT_NAME OPT_VALUE OLD_OPT_VALUE OLD_OPT_VALUE_2 IF NOFAIL + if [ "$1" == _no_fail_ ] ; then + NOFAIL=1 + shift + fi + IF=$1 test -z "$IF" && return 0 shift if [ -d /sys/class/net/$IF -a ! -d /sys/class/net/$IF/bonding ] ; then @@ -194,11 +201,31 @@ echo "-$IF" > /sys/class/net/bonding_masters return 1 # or continue? I guess its better to fail completely fi - if ! echo "$OPT_VALUE" > /sys/class/net/$IF/bonding/$OPT_NAME ; then + # Some options may only be changed if the interface is up and slaves are + # already assigned. Others may only be changed if it is down. To avoid + # unneccessary error messages or warnings we check first if the option + # already has the specified value. + # Special case for option 'mode': this sysfs attribute contains two + # words. A string describing the mode and the corresponding number. We + # have to compare both. + read OLD_OPT_VALUE OLD_OPT_VALUE_2 < /sys/class/net/$IF/bonding/$OPT_NAME + if [ "$OLD_OPT_VALUE" == "$OPT_VALUE" \ + -o \( "$OPT_NAME" == mode -a "$OLD_OPT_VALUE_2" == "$OPT_VALUE" \) \ + ] ; then + info_mesg "Bonding interface '$IF':" \ + "option '$OPT_NAME' is already set to '$OPT_VALUE'" + continue + fi + info_mesg "Bonding interface '$IF':" \ + "Setting option '$OPT_NAME' to '$OPT_VALUE'" + if ! echo "$OPT_VALUE" > /sys/class/net/$IF/bonding/$OPT_NAME \ + 2>/dev/null ; then err_mesg "Option '$OPT_NAME' of interface '$IF' cannot be set to" \ "'$OPT_VALUE'." + # Should we continue? Its better to fail if not requested differently + test "$NOFAIL" == 1 && continue echo "-$IF" > /sys/class/net/bonding_masters - return 1 # or continue? I guess its better to fail completely + return 1 fi done return 0 --- scripts/ifup 2006-12-10 10:40:37.000000000 +0000 +++ scripts/ifup 2006-12-10 10:54:44.000000000 +0000 @@ -919,6 +919,9 @@ "correctly\n$MESSAGE" exit $R_ERROR fi + # Some option have to be changed after ifenslave (e.g. primary) + # Therefore we call load_bond() a second time + load_bond $INTERFACE $BONDING_MODULE_OPTS fi fi