STG

Manage spanning tree groups

STG

Manage spanning tree groups (STGs). An STG is a set of VLANs that share one spanning-tree state per port. With this command you can create and remove groups, put VLANs in them, and read or set each port’s state. Sub-commands must be typed in full. Group and VLAN numbers can be decimal or 0x hexadecimal.

show, stp without a state, and default without a number only read.

Warning

Everything else changes STP state that SONiC’s SAI manages. A port set to block or disable stops forwarding, and SONiC has no record of why.

stg show [<id>]

With a group number, print STG <id>: contains <n> VLANs (<list>), with ranges shown as a-b. Without one, print group 0 and then every group, each with its VLANs and then one line per STP state that has ports, for example `` Forward: ce,xe``. Read-only.

On a SONiC switch every VLAN is in group 1 with all ports forwarding: VLAN 1, SONiC’s own VLANs, 4095, and a few internal VLAN numbers above 4095 that the SAI uses. Group 0 holds no VLANs and lists every port as Disable.

Hardware-validated

drivshell> stg show
STG 0: contains 0 VLANs
  Disable: ce,xe
STG 1: contains 8 VLANs (1,902,3999,4095,28673,29574,32671,45055)
  Forward: ce,xe
stg create [<id>]

Create a group with the given number, printing nothing. Without a number the next free one is used, and the shell prints Created spanning tree group <id>. Changes switch state. SONiC uses only group 1, so group 2 and up are free; remove a test group again with stg destroy.

Hardware-validated

drivshell> stg create 2
stg destroy <id>

Delete a group. Changes switch state.

Hardware-validated

drivshell> stg destroy 2
stg add <id> <vlan_id> [<vlan_id> ...]

Move one or more VLANs into a group. It stops at the first VLAN that fails. Changes switch state.

Unvalidated

drivshell> stg add 2 100 101
stg remove <id> <vlan_id> [<vlan_id> ...]

Take VLANs out of a group. They go back to the default group. Changes switch state.

Unvalidated

drivshell> stg remove 2 101
stg stp [<id> [<pbmp> <state>]]

With no argument, print every group’s ports grouped by STP state. With a group number, print that group only. With a port list and a state, set that state on those ports in that group. The states are Disable, Block, LIsten, LEarn and Forward. They may be shortened to their capital letters (d, b, li, le, f). The built-in help writes them in lower case. Setting a state changes switch state.

Hardware-validated

drivshell> stg stp 1
STG 1:
  Forward: ce,xe

Unvalidated — Put xe1 in forwarding state in STG 1

drivshell> stg stp 1 xe1 forward
stg default [<id>]

Print Default STG is <id>, or set the default group and print Default STG set to <id>. Without a number this only reads.

Unvalidated

drivshell> stg default

Built-in help

Usages:
      stg create [<id>]            - Create a STG; optionally specify ID
      stg destroy <id>             - Destroy a STG
      stg show [<id>]              - List STG(s)
      stg add <id> <vlan_id> [...]     - Add VLAN(s) to a STG
      stg remove <id> <vlan_id> [...]  - Remove VLAN(s) from a STG
      stg stp                      - Get span tree state, all ports/STGs
      stg stp <id>                 - Get span tree state of ports in STG
      stg stp <id> <pbmp> <state>  - Set span tree state of ports in STG
                                     (disable/block/listen/learn/forward)
      stg default [<id>]           - Show or set the default STG

Further reading

SDK-6.5.20 HSDK Getting Started Guide (GS-SDK6520-R), plus SDK-6.5.20/21/22 Release Notes (RN-SDK65xx-R), Cisco Nexus 9000 Series NX-OS Programmability Guide, Release 7.x – Broadcom Shell, Cisco Nexus 9000 Series NX-OS Troubleshooting Guide, Release 9.3(x) – Troubleshooting VLANs, H3C S12500-F系列交换机 Probe命令参考(R100x系列)-6W100, BISDN Linux bundle-debug-info support script, BCM-SDK命令的使用.pdf, 交换芯片Helix4 L2 L3功能验证, Edgecore AS5610-52X reverse engineering: Cumulus 2.5 baseline captures.