summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2007-09-25 12:43:58 +0200
committerWilly Tarreau <w@1wt.eu>2007-09-25 12:43:58 +0200
commit8dce1b07d4a49c98d1f451bd23a7db0fc560f89e (patch)
treedc91884fe208a61145149fd6ad00176e209a8ccd
parent* network: add the ability to rename an interface ("replace") (diff)
downloadinit-scripts-8dce1b07d4a49c98d1f451bd23a7db0fc560f89e.tar.gz
* network: add support for bridge
-rwxr-xr-xsbin/init.d/network35
1 files changed, 31 insertions, 4 deletions
diff --git a/sbin/init.d/network b/sbin/init.d/network
index 02f1bd3..01002a2 100755
--- a/sbin/init.d/network
+++ b/sbin/init.d/network
@@ -44,6 +44,8 @@ option duplex standard_option
option speed standard_option
option auto standard_option
option slave multiple_option
+option bridge multiple_option
+option bridge_stp boolean_option 0
option sysctl multiple_option
option modprobe multiple_option
option lladdr standard_option
@@ -64,10 +66,9 @@ function do_help {
echo
echo " - ip addr <address>, arp <ip> <mac>|pub, dhcp, route <dest> <-|gw> [<args>]"
echo " - media auto|{full|fdx|100full|100fdx}|{half|hdx|100half|100hdx}"
- echo " - duplex {half|full}"
- echo " - speed {10|100|1000}"
- echo " - auto {on|off}"
+ echo " - duplex {half|full} ; speed {10|100|1000} ; auto {on|off}"
echo " - slave <interface*>"
+ echo " - bridge <interface*> ; bridge_stp {on|off}"
echo " - sysctl <var>=<val>"
echo " - modprobe <module> <arg*>"
echo " - load|unload <command> <arg*>"
@@ -269,6 +270,23 @@ function do_start {
done
arg=0
+ # configure the bridge
+ if [ ${#opt_bridge[*]} -gt 0 ]; then
+ brctl addbr $instname
+ [ "${opt_bridge_stp}" == "1" ] && brctl stp $instname on
+ [ "${opt_bridge_stp}" != "1" ] && brctl setfd $instname 0
+ for arg in ${opt_bridge[*]}; do
+ if ! ( do_status $svcname $arg || \
+ ip li set dev $arg up || \
+ do_start $svcname $arg ) >/dev/null 2>&1; then
+ echo " ==> FAILED! need to start iface $arg before $instname"
+ else
+ brctl addif $instname $arg >/dev/null 2>&1
+ ip addr flush dev $arg >/dev/null 2>&1
+ fi
+ done
+ fi
+
# Create the VLAN interface if it does not exist yet.
if ! grep -qE "^[ ]*($instname|$repl):" /proc/net/dev >/dev/null 2>&1; then
# A dot in an interface name means physical_if.vlanid
@@ -286,7 +304,7 @@ function do_start {
fi
fi
- ip link set "$repl" down >/dev/null 2>&1
+ [ ${#opt_bridge[*]} -gt 0 ] || ip link set "$repl" down >/dev/null 2>&1
ip addr flush dev "$repl" >/dev/null 2>&1
# Rename the interface if needed.
@@ -515,6 +533,15 @@ function do_stop {
# We have to remove the interface now.
[ -z "${instname//*.*/}" ] && vconfig rem $instname >/dev/null
+ if [ ${#opt_bridge[*]} -gt 0 ]; then
+ for arg in ${opt_bridge[*]}; do
+ do_status $svcname $arg && ip li set dev $arg down >/dev/null 2>&1
+ ip addr flush dev $arg >/dev/null 2>&1
+ brctl delif $instname $arg >/dev/null 2>&1
+ done
+ brctl delbr $instname
+ fi
+
arg=${#opt_modprobe[*]}
while [ $arg -gt 0 ]; do
arg=$[$arg-1]