From: Vitalii Demianets Date: Sun, 27 Nov 2011 11:08:25 +0000 (+0100) Subject: bridge-stp: Make sure kernel knows about the STP state. X-Git-Tag: 004~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01c873274aee70213a5efb92203ec27a863c9c47;p=network.git bridge-stp: Make sure kernel knows about the STP state. From email: Yes, but it have issues: 1) After log ERROR script should return failure (!=0) - after all, user-space stp was not setup correctly and kernel should know it. So "exit 1" should be inserted in two places: after log ERROR "mstpd is not running. STP might not work." and after log ERROR "Unknown action given: ${action}." 2) If zone does not exist script also should return failure (!=0). Kernel should know that user-space stp was not started. 3) I assume your "assert " function returns failure(non-zero) too ;) 4) mstpctl MUST be run through exec call. 5) thanks to above "assert" in the start case can be omitted - execution flow will never go that far. 6) The final "exit 0" is superfluous. Signed-off-by: Michael Tremer --- diff --git a/bridge-stp b/bridge-stp index 51765f7c..f668ae2a 100755 --- a/bridge-stp +++ b/bridge-stp @@ -33,7 +33,7 @@ assert isset action # Exit immediately, if zone configuration does not exist. # This is for manually created bridges. if ! zone_exists ${zone}; then - exit 0 + exit 1 fi # Check if mstpd is running. If not, try to start it. @@ -42,6 +42,7 @@ if ! service_is_active mstpd; then if ! service_is_active mstpd; then log ERROR "mstpd is not running. STP might not work." + exit 1 fi fi @@ -49,16 +50,14 @@ fi case "${action}" in start) log DEBUG "Enabling STP for zone '${zone}'." - mstpctl notify-daemon-that-stp-is-on ${zone} - assert [ $? -eq 0 ] + exec mstpctl notify-daemon-that-stp-is-on ${zone} ;; stop) log DEBUG "Disabling STP for zone '${zone}'." - mstpctl notify-daemon-that-stp-is-off ${zone} + exec mstpctl notify-daemon-that-stp-is-off ${zone} ;; *) log ERROR "Unknown action given: ${action}." + exit 1 ;; esac - -exit 0