From: Michael Tremer Date: Fri, 18 Aug 2017 12:09:24 +0000 (+0000) Subject: bridge: Correctly apply STP priority X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fnetwork.git;a=commitdiff_plain;h=424b8280f0023d1c2907397aabb6a9a7ab1be0aa bridge: Correctly apply STP priority Fixes #10609 Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.stp b/src/functions/functions.stp index 7b08742a..340be031 100644 --- a/src/functions/functions.stp +++ b/src/functions/functions.stp @@ -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 diff --git a/src/hooks/zones/bridge b/src/hooks/zones/bridge index e90111ca..893f4523 100644 --- a/src/hooks/zones/bridge +++ b/src/hooks/zones/bridge @@ -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}"