]> git.ipfire.org Git - people/stevee/network.git/commitdiff
bridge: Correctly apply STP priority
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2017 12:09:24 +0000 (12:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2017 12:09:24 +0000 (12:09 +0000)
Fixes #10609

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.stp
src/hooks/zones/bridge

index 7b08742acf306b8f804b46d732e73a1cdd6de60e..340be031c53acd739b977f78538197733e922352 100644 (file)
@@ -342,6 +342,34 @@ stp_port_set_cost() {
        __device_set_file "${bridge}" "brif/${port}/path_cost" "${cost}"
 }
 
+stp_port_get_priority() {
+       local bridge=${1}
+       assert isset bridge
+
+       local port=${2}
+       assert isset port
+
+       __device_get_file "${bridge}" "brif/${port}/priority"
+}
+
+stp_port_set_priority() {
+       assert [ $# -eq 3 ]
+
+       local bridge="${1}"
+       local port="${2}"
+       local priority="${3}"
+
+       # Nothing to do if the priority already matches
+       local old_priority="$(stp_port_get_priority "${bridge}" "${port}")"
+       if [ ${priority} -eq ${old_priority} ]; then
+               return ${EXIT_OK}
+       fi
+
+       log DEBUG "Setting STP priority to ${priority} on ${port}"
+
+       __device_set_file "${bridge}" "brif/${port}/priority" "${priority}"
+}
+
 stp_port_get_designated_root() {
        local bridge=${1}
        assert isset bridge
index e90111ca8286a4bad9f3f06c9e2e5e16836c128d..893f4523587cefe697a0e48f8845960166b751c9 100644 (file)
@@ -324,7 +324,9 @@ hook_port_up() {
                stp_port_set_cost "${zone}" "${port}" "${COST}"
        fi
 
-       # TODO Apply priority (#10609)
+       if isset PRIORITY; then
+               stp_port_set_priority "${zone}" "${port}" "${PRIORITY}"
+       fi
 
        # Make sure that the port is up
        port_up "${port}"