]> git.ipfire.org Git - people/stevee/network.git/commitdiff
bridge-stp: Tell mstpd that STP was enabled for a device.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Nov 2011 11:18:29 +0000 (11:18 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Nov 2011 11:18:29 +0000 (11:18 +0000)
mstpd needs to be told about wheather STP was enabled or
disabled for a bridge.
To stay with the old command "brctl stp red0 on/off", this
is done by the bridge-stp script that is called by the kernel.

bridge-stp

index 823a5d96b119358f66d29d131d220596649dd4df..51765f7cee952a64cfa4b0f66f31b7ac1ff25f0d 100755 (executable)
 #                                                                             #
 ###############################################################################
 
-# This script always returns 0 to prevent the kernel starting its own stp
-# implementation.
-# But in case no mstpd is not running, an error message will be logged.
-
 . /lib/network/functions
 
-service_is_active mstpd || \
-       log ERROR "mstpd is not running. STP might not work."
+# Change LOG_FACILITY that we will find our messages in syslog.
+LOG_FACILITY=$(basename ${0})
+
+zone=${1}
+action=${2}
+
+assert isset zone
+assert isset action
+
+# Exit immediately, if zone configuration does not exist.
+# This is for manually created bridges.
+if ! zone_exists ${zone}; then
+       exit 0
+fi
+
+# Check if mstpd is running. If not, try to start it.
+if ! service_is_active mstpd; then
+       service_start mstpd
+
+       if ! service_is_active mstpd; then
+               log ERROR "mstpd is not running. STP might not work."
+       fi
+fi
+
+# Tell mstpd that STP has to be enabled/disabled.
+case "${action}" in
+       start)
+               log DEBUG "Enabling STP for zone '${zone}'."
+               mstpctl notify-daemon-that-stp-is-on ${zone}
+               assert [ $? -eq 0 ]
+               ;;
+       stop)
+               log DEBUG "Disabling STP for zone '${zone}'."
+               mstpctl notify-daemon-that-stp-is-off ${zone}
+               ;;
+       *)
+               log ERROR "Unknown action given: ${action}."
+               ;;
+esac
 
 exit 0