]> git.ipfire.org Git - network.git/blobdiff - src/helpers/bridge-stp
ipsec-connection: add description feature
[network.git] / src / helpers / bridge-stp
index c98d6a1beea4ba6c6aa3d162649c3fd070a9e4bd..307453859fe0d7f1cbb153720a441673ff3a88f8 100644 (file)
 #                                                                             #
 ###############################################################################
 
-EXIT_USERSPACE_STP=0
-EXIT_KERNEL_STP=1
-
 # Change LOG_FACILITY that we will find our messages in syslog.
 LOG_FACILITY=$(basename ${0})
 
 . /usr/lib/network/functions
 
-# Read network configuration.
-network_config_read
+# Read network settings
+network_settings_read
 
 zone=${1}
 assert isset zone
@@ -42,60 +39,26 @@ if ! zone_exists ${zone}; then
        exit ${EXIT_KERNEL_STP}
 fi
 
-# Read zone configuration.
-zone_config_read ${zone}
+# Read zone settings
+zone_settings_read "${zone}" --ignore-superfluous-settings STP
 
 # Make sure STP is enabled for this zone.
-assert enabled STP
-
-log DEBUG "Configured STP mode is '${STP_MODE}'"
-
-case "${STP_MODE}" in
-       rstp)
-               # Check if mstpd is running. If not, try to start it.
-               if ! service_is_active mstpd; then
-                       service_start "mstpd.service"
-
-                       if ! service_is_active "mstpd.service"; then
-                               log ERROR "mstpd is not running. STP might not work."
-                               exit 1
-                       fi
-               fi
-
-               # Set the right protocol that should be used.
-               # Do this after the bridge has been added.
-               (
-                       sleep 2
-                       stp_bridge_set_protocol "${zone}" "${STP_MODE}"
-               ) &
-
-               # Tell mstpd that STP has to be enabled/disabled.
-               case "${action}" in
-                       start)
-                               log DEBUG "Enabling userspace STP for zone '${zone}'"
-                               exec mstpctl addbridge ${zone}
-                               ;;
-                       stop)
-                               log DEBUG "Disabling userspace STP for zone '${zone}'"
-                               exec mstpctl delbridge ${zone}
-                               ;;
-               esac
+if ! enabled STP; then
+       log ERROR "The kernel tried to enable STP for zone ${zone}"
+       log ERROR "but our configuration disagrees"
+       exit ${EXIT_STP_ERROR}
+fi
 
-               log ERROR "Could not properly exec mstpctl."
+case "${action}" in
+       start)
+               log INFO "STP activated for ${zone}"
+               exit ${EXIT_STP_KERNEL}
                ;;
-       stp)
-               case "${action}" in
-                       start)
-                               log DEBUG "Enabling kernel STP for zone '${zone}'"
-                               exit ${EXIT_KERNEL_STP}
-                               ;;
-                       stop)
-                               log DEBUG "Disabling kernel STP for zone '${zone}'"
-                               exit ${EXIT_OK}
-                               ;;
-               esac
+       stop)
+               log INFO "STP deactivated for ${zone}"
+               exit ${EXIT_OK}
                ;;
+       *)
+               log ERROR "Unknown action: ${action}"
+               exit ${EXIT_STP_ERROR}
 esac
-
-# Fall back to kernel STP.
-exit ${EXIT_KERNEL_STP}