Skip to content

[STP/MSTP] Circular dependency validation bug in config spanning-tree mst instance soft-locks instance creation #4629

Description

@mbze430

Component:
sonic-utilities / config/stp.py

SONiC Version/Build info:

SONiC Software Version: SONiC.202511.0-dirty-20260506.192100

Description:
There is a hard-coded circular dependency bug in the Click CLI configuration wrapper for Multiple Spanning Tree Protocol (MSTP) settings. The validation logic inside config spanning-tree mst instance vlan add and config spanning-tree mst instance priority strictly checks if an MST instance exists in the configuration database (CONFIG_DB) before allowing modifications. However, the CLI entirely lacks a command block (such as an add or create verb) under the parent instance group to initialize a new instance key. As a result, users are completely soft-locked from deploying multi-instance STP layouts via the standard CLI.

Steps to Reproduce:
Attempt to add a VLAN to a new MST instance:

Bash
sudo config spanning-tree mst instance vlan add 1 10
Output: Error: MST instance 1 does not exist. Please create it first.

Attempt to initialize the instance by setting its bridge priority:

Bash
sudo config spanning-tree mst instance priority 1 32768
Output: Error: MST instance 1 does not exist. Please create it first.

Inspect the subcommands available under config spanning-tree mst instance:

Bash
sudo config spanning-tree mst instance
Output:

Commands:
interface Configure MSTP instance interface settings
priority Configure bridge priority for an MST instance.
vlan VLAN to instance mapping for MST.
(Note the complete absence of a create or add verb to initialize the container).

Root Cause Analysis:
In /usr/local/lib/python3.13/dist-packages/config/stp.py, the validation blocks for both the priority and vlan commands enforce an explicit entry check against the STP_MST_INST table:

Python

Line 1786-1788 in config/stp.py

instance_key = f"MST_INSTANCE|{instance_id}"
if not db.get_entry('STP_MST_INST', instance_key):
ctx.fail(f"MST instance {instance_id} does not exist. Please create it first.")
Because db.get_entry() looks for a key that cannot be generated anywhere else via the CLI, the execution path hits a dead end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions