--- trunk/magellan-initscripts/etc/rc.d/init.d/network 2010/07/14 07:25:22 1090 +++ trunk/magellan-initscripts/etc/rc.d/init.d/network 2010/07/14 11:02:11 1092 @@ -64,6 +64,13 @@ local BRIDGE_INTERFACES local BRIDGE_STP + local BRIDGE_AGEING_TIME + local BRIDGE_PRIORITY + local BRIDGE_FORWARD_DELAY + local BRIDGE_HELLO_TIME + local BRIDGE_MAX_MESSAGE_AGE + local BRIDGE_PATH_COST + local BRIDGE_PORT_PRIORITY source ${file} eval value=\$$(echo ${var}) @@ -259,6 +266,73 @@ esac } +config_bridge_options() +{ + local iface="$1" + local i + local port + local cost + local prio + + # enable spanning-tree protocol + case ${BRIDGE_STP} in + on|off) brctl stp "${iface}" "${BRIDGE_STP}" ;; + *) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; + esac + + # configure ageing time + if [[ ! -z ${BRIDGE_AGEING_TIME} ]] + then + brctl setageing "${iface}" "${BRIDGE_AGEING_TIME}" + fi + + # configure bridge priority + if [[ ! -z ${BRIDGE_PRIORITY} ]] + then + brctl setbridgeprio "${iface}" "${BRIDGE_PRIORITY}" + fi + + # configure forward delay + if [[ ! -z ${BRIDGE_FORWARD_DELAY} ]] + then + brctl setfd "${iface}" "${BRIDGE_FORWARD_DELAY}" + fi + + # configure hello time + if [[ ! -z ${BRIDGE_HELLO_TIME} ]] + then + brctl sethello "${iface}" "${BRIDGE_HELLO_TIME}" + fi + + # configure maximal message age + if [[ ! -z ${BRIDGE_MAX_MESSAGE_AGE} ]] + then + brctl setmaxage "${iface}" "${BRIDGE_MAX_MESSAGE_AGE}" + fi + + # configure path cost for every port + if [[ ! -z ${BRIDGE_PATH_COST} ]] + then + for i in ${BRIDGE_PATH_COST} + do + port="${i%=*}" + cost="${i#*=}" + [[ ! -z ${port} ]] && brctl pathcost "${iface}" "${port}" "${cost}" + done + fi + + # configure port priority for every port + if [[ ! -z ${BRIDGE_PORT_PRIORITY} ]] + then + for i in ${BRIDGE_PORT_PRIORITY} + do + port="${i%=*}" + prio="${i#*=}" + [[ ! -z ${port} ]] && brctl setportprio "${iface}" "${port}" "${prio}" + done + fi +} + config_bridge_devices() { local iface="$1" @@ -294,31 +368,28 @@ case ${method} in add) # setup the bridge device - brctl addbr ${iface} + brctl addbr "${iface}" for bport in ${BRIDGE_INTERFACES} do # enter promiscous mode - ifconfig ${bport} 0.0.0.0 promisc + ifconfig "${bport}" 0.0.0.0 promisc # now setup the bridge - brctl addif ${iface} ${bport} + brctl addif "${iface}" "${bport}" done - # enable spanning-tree protocol - case ${BRIDGE_STP} in - on|off) brctl stp ${iface} ${BRIDGE_STP} ;; - *) echo "BRIDGE: unkown value \$BRIDGE_STP='$BRIDGE_STP'."; return 1 ;; - esac + # configure all other options + config_bridge_options "${iface}" ;; remove) for bport in ${BRIDGE_INTERFACE} do # bring the interface down - ifconfig ${bport} down + ifconfig "${bport}" down # remove the interface from the bridge - brctl delif ${iface} ${bport} + brctl delif "${iface}" "${bport}" done # bring the bridge down - brctl delbr ${iface} + brctl delbr "${iface}" ;; esac @@ -352,7 +423,7 @@ \#*|"") continue ;; esac echo -e ${COLOREDSTAR}"${message}" - route ${method} ${route} + route "${method}" "${route}" evaluate_retval done fi @@ -364,9 +435,9 @@ if [[ -z $1 ]] then - ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) + ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) else - if [[ -e ${network_settings}/net.$1 ]] + if [[ -e ${rc_network_settings}/net.$1 ]] then ALL_INTERFACES="$1" else @@ -381,7 +452,7 @@ for iface in ${ALL_INTERFACES} do # checkconfig - source ${network_settings}/net.${iface} || exit 1 + source ${rc_network_settings}/net.${iface} || exit 1 checkconfig # setup mac @@ -395,7 +466,7 @@ # setup bridges if [[ ${iface} = br[0-9]* ]] then - config_bridge_devices ${iface} add + config_bridge_devices "${iface}" add fi # now configure wireless_extensions @@ -427,7 +498,7 @@ if [[ -n ${GATEWAY} ]] then echo -e ${COLOREDSTAR}"Setting up default gateway for ${COLBLUE}${iface}${COLDEFAULT} ..." - route add default gateway ${GATEWAY} metric 1 dev ${iface} + route add default gateway "${GATEWAY}" metric 1 dev "${iface}" evaluate_retval unset GATEWAY @@ -472,9 +543,9 @@ { if [[ -z $1 ]] then - ALL_INTERFACES=$(onboot_interface_list ${network_settings}/net.*) + ALL_INTERFACES=$(onboot_interface_list ${rc_network_settings}/net.*) else - if [[ -e ${network_settings}/net.$1 ]] + if [[ -e ${rc_network_settings}/net.$1 ]] then ALL_INTERFACES="$1" else @@ -488,7 +559,7 @@ # get list of all devices for iface in ${ALL_INTERFACES} do - source ${network_settings}/net.${iface} || exit 1 + source ${rc_network_settings}/net.${iface} || exit 1 checkconfig if [[ -n ${GATEWAY} ]] @@ -505,7 +576,7 @@ # remove bridges if [[ ${iface} = br[0-9]* ]] then - config_bridge_devices ${iface} remove + config_bridge_devices "${iface}" remove fi # shutdown dhcp-daemon