echo "$(<${path})"
}
+function __device_set_file() {
+ assert [ $# -eq 3 ]
+
+ local device="${1}"
+ local file="${2}"
+ local value="${3}"
+
+ local path="${SYS_CLASS_NET}/${device}/${file}"
+ if [ ! -w "${path}" ]; then
+ log DEBUG "Cannot write to file '${file}' (${value})"
+ return ${EXIT_ERROR}
+ fi
+
+ echo "${value}" > "${path}"
+}
+
function device_get_rx_bytes() {
local device=${1}
return ${EXIT_ERROR}
}
+function stp_port_set_cost() {
+ assert [ $# -eq 3 ]
+
+ local bridge="${1}"
+ local port="${2}"
+ local cost="${3}"
+
+ local old_cost="$(stp_port_get_cost "${bridge}" "${port}")"
+ if [ "${cost}" -eq "${old_cost}" ]; then
+ return ${EXIT_OK}
+ fi
+
+ log DEBUG "Setting STP path costs of port '${port}' (bridge '${bridge}') to '${cost}'"
+
+ if stp_is_userspace "${bridge}"; then
+ cmd mstpctl setportpathcost "${bridge}" "${port}" "${cost}"
+ else
+ __device_set_file "${bridge}" "brif/${port}/path_cost" "${cost}"
+ fi
+}
+
function stp_port_get_designated_root() {
local bridge=${1}
assert isset bridge
local zone="${1}"
local port="${2}"
+ config_read "$(zone_dir "${zone}")/ports/${port}" ${HOOK_PORT_SETTINGS}
+
port_up "${port}"
# Set same MTU to device that the bridge has got
bridge_attach_device "${zone}" "${port}"
- # XXX must set cost and prio here
+ if isset COST; then
+ stp_port_set_cost "${zone}" "${port}" "${COST}"
+ fi
+
+ # TODO Apply priority (#10609)
exit ${EXIT_OK}
}