From: Michael Tremer Date: Fri, 25 Nov 2011 11:18:29 +0000 (+0000) Subject: bridge-stp: Tell mstpd that STP was enabled for a device. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c95a49ad4587c7537d70f546f8584d973c8b719;p=people%2Fstevee%2Fnetwork.git bridge-stp: Tell mstpd that STP was enabled for a device. 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. --- diff --git a/bridge-stp b/bridge-stp index 823a5d96..51765f7c 100755 --- a/bridge-stp +++ b/bridge-stp @@ -19,13 +19,46 @@ # # ############################################################################### -# 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