From: Michael Tremer Date: Thu, 26 May 2011 15:52:50 +0000 (+0000) Subject: Some fixes when STP is disabled. X-Git-Tag: 001~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36e3fd2f051ec57034c03f949419a45e3377b49d;p=network.git Some fixes when STP is disabled. --- diff --git a/functions.stp b/functions.stp index 6502130f..d6c5c996 100644 --- a/functions.stp +++ b/functions.stp @@ -108,6 +108,11 @@ function stp_bridge_get_protocol() { assert isset bridge + local enabled=$(__device_get_file ${bridge} "bridge/stp_state") + if ! enabled ${enabled}; then + return ${EXIT_OK} + fi + local mode=$(__rstpctl_bridge_get ${bridge} protocol_version) case "${mode}" in @@ -116,7 +121,12 @@ function stp_bridge_get_protocol() { ;; 2) echo "rstp" - ;; + ;; + # When rstpctl has an error, we assume that rstpd is not running and + # return the slow mode. + "") + echo "stp" + ;; esac } @@ -463,7 +473,10 @@ function stp_port_get_designated_root() { ;; esac - mac_format ${output:5:12} + if [ -n "${output}" ]; then + mac_format ${output:5:12} + return ${EXIT_OK} + fi return ${EXIT_ERROR} } diff --git a/hooks/zones/bridge b/hooks/zones/bridge index 7fe89d63..2d2aecb9 100755 --- a/hooks/zones/bridge +++ b/hooks/zones/bridge @@ -161,25 +161,27 @@ function _status() { exit ${EXIT_ERROR} fi - # XXX Add bridge stp priority here - # brctl does not give any information about that - cli_headline " Spanning Tree Protocol information:" - printf "${DEVICE_PRINT_LINE1}" "ID:" $(stp_bridge_get_id ${zone}) - printf "${DEVICE_PRINT_LINE1}" "Priority:" $(stp_bridge_get_priority ${zone}) + if [ -n "$(stp_bridge_get_protocol ${zone})" ]; then + printf "${DEVICE_PRINT_LINE1}" "Version:" $(stp_bridge_get_protocol ${zone}) + printf "${DEVICE_PRINT_LINE1}" "ID:" $(stp_bridge_get_id ${zone}) + printf "${DEVICE_PRINT_LINE1}" "Priority:" $(stp_bridge_get_priority ${zone}) + + if stp_bridge_is_root ${zone}; then + echo -e " ${COLOUR_BOLD}This bridge is root.${COLOUR_NORMAL}" + else + printf "${DEVICE_PRINT_LINE1}" "Designated root:" $(stp_bridge_get_designated_root ${zone}) + printf "${DEVICE_PRINT_LINE1}" "Root path cost:" $(stp_bridge_get_root_path_cost ${zone}) + fi + echo # Empty line - if stp_bridge_is_root ${zone}; then - echo -e " ${COLOUR_BOLD}This bridge is root.${COLOUR_NORMAL}" + # Topology information + printf "${DEVICE_PRINT_LINE1}" "Topology changing:" $(stp_bridge_get_topology_change_detected ${zone}) + printf "${DEVICE_PRINT_LINE1}" "Topology change time:" $(beautify_time $(stp_bridge_get_topology_change_timer ${zone})) + printf "${DEVICE_PRINT_LINE1}" "Topology change count:" $(stp_bridge_get_topology_change_count ${zone}) else - printf "${DEVICE_PRINT_LINE1}" "Designated root:" $(stp_bridge_get_designated_root ${zone}) - printf "${DEVICE_PRINT_LINE1}" "Root path cost:" $(stp_bridge_get_root_path_cost ${zone}) + echo -e " ${COLOUR_BOLD}STP is disabled.${COLOUR_NORMAL}" fi - echo # Empty line - - # Topology information - printf "${DEVICE_PRINT_LINE1}" "Topology changing:" $(stp_bridge_get_topology_change_detected ${zone}) - printf "${DEVICE_PRINT_LINE1}" "Topology change time:" $(beautify_time $(stp_bridge_get_topology_change_timer ${zone})) - printf "${DEVICE_PRINT_LINE1}" "Topology change count:" $(stp_bridge_get_topology_change_count ${zone}) cli_headline " Ports:" zone_ports_status ${zone} diff --git a/hooks/zones/bridge.ports/ethernet b/hooks/zones/bridge.ports/ethernet index c249e178..7383dc47 100755 --- a/hooks/zones/bridge.ports/ethernet +++ b/hooks/zones/bridge.ports/ethernet @@ -138,13 +138,15 @@ function _status() { printf " %-10s - " "${port}" if ! device_is_up ${port}; then echo -ne "${COLOUR_DOWN} DOWN ${COLOUR_NORMAL}" - else + elif [ -n "$(stp_bridge_get_protocol ${zone})" ]; then local state=$(stp_port_get_state ${zone} ${port}) local colour="COLOUR_STP_${state}" printf "${!colour}%10s${COLOUR_NORMAL}" ${state} echo -n " - DSR: $(stp_port_get_designated_root ${zone} ${port})" echo -n " - Cost: $(stp_port_get_cost ${zone} ${port})" + else + echo -ne "${COLOUR_UP} UP ${COLOUR_NORMAL}" fi echo