]> git.ipfire.org Git - people/ms/network.git/commitdiff
bridge-stp: Make sure kernel knows about the STP state.
authorVitalii Demianets <vitas@nppfactor.kiev.ua>
Sun, 27 Nov 2011 11:08:25 +0000 (12:08 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 Nov 2011 11:08:25 +0000 (12:08 +0100)
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 <michael.tremer@ipfire.org>
bridge-stp

index 51765f7cee952a64cfa4b0f66f31b7ac1ff25f0d..f668ae2a5280c9413cd0af95ef3a5def9e1509d7 100755 (executable)
@@ -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