]> git.ipfire.org Git - people/stevee/network.git/commitdiff
Some fixes when STP is disabled.
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 May 2011 15:52:50 +0000 (15:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 May 2011 15:52:50 +0000 (15:52 +0000)
functions.stp
hooks/zones/bridge
hooks/zones/bridge.ports/ethernet

index 6502130f45f990128d22146002dd4a2856f48d8f..d6c5c99676cd3b482c6dd5879d9c6067eb5f1141 100644 (file)
@@ -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}
 }
index 7fe89d63b7e2b3b2db2d3f0d2192891188556b6e..2d2aecb9a387bd6e20025fd95ca3813a4b4974a2 100755 (executable)
@@ -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}
index c249e1787ca90e09ab62c93d368cb516c5731e62..7383dc47d1ab777a4896d06f0723274f1d5d067b 100755 (executable)
@@ -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