Skip to content

[mstp] Fix for incorrectly passing mst internal index to stpsync#77

Open
vganesan-nokia wants to merge 1 commit intosonic-net:masterfrom
vganesan-nokia:mstp-sync-idx-2-id-fix
Open

[mstp] Fix for incorrectly passing mst internal index to stpsync#77
vganesan-nokia wants to merge 1 commit intosonic-net:masterfrom
vganesan-nokia:mstp-sync-idx-2-id-fix

Conversation

@vganesan-nokia
Copy link
Contributor

@vganesan-nokia vganesan-nokia commented Nov 25, 2025

What was added
Changes to fix wrongly passing mst internal index to stpsync api-s, which expect instance id. For MSTP, since the internal index and MST instance ids are not one-to-one mapped (for example, for CIST, the MST instance id 0 but the internal index 64). With these changes, the index are converted to MST instance id and passed to stpsync api-s

Verified

  • Tested with with two instances (Default CIST and MST instance 1) in a triangle setup where all the three nodes were connected by 2 parallel links. The CIST had index 64 and MST 1 had index 0. The id 0 (for CIST) and 1 (MST 1) were correctly passed to stpsync and the ASIC records were created correct with corect instances. Configured 2 vlans. One VLAN was mapped to MST 1 and unmapped VLAN in CIST.
  • No forwarding loops and high rate MAC move were observed (i.e., the STP records and port states for the correct insance were programmed correctly)

Changes to fix wrongly passing mst internal index to stpsync api-s, which
expect instance id. For MSTP, since the internal index and MST instance
ids are not one-to-one mapped (for example, for CIST, the MST instance
id 0 but the internal index 64). With these changes, the index are
converted to MST instance id and passed to stpsync api-s

Signed-off-by: vedganes <veda.ganesan@nokia.com>
@vganesan-nokia
Copy link
Contributor Author

@divyachandralekha, would you please review this?

/* Delete CIST port from APP DB*/
stpsync_del_mst_port_info(ifname, MSTP_MSTID_CIST);
stpsync_del_port_state(ifname, MSTP_INDEX_CIST);
stpsync_del_port_state(ifname, MSTP_MSTID_CIST);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vganesan-nokia
This call is intended for orchagent, and orchagent operates based on the MSTP index, not the MST ID.The MST ID is local to the STPd context and is used only for configuration and display purposes.

Therefore, for this call — as well as the other modified calls below — mstp_index is the correct parameter to use.

Copy link
Contributor Author

@vganesan-nokia vganesan-nokia Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@divyachandralekha, thanks for the review comment.

In orchangent there is mapping between the given number (either MST ID or MSTP index or any number) and the OID of the created STP instance m_stpInstOId (Refer src/sonic-swss/orchagent/stporch.cpp addStpInstance(), for example). So, functinoality-wise orchagent is indifferent to MST ID (which is user given) or any internal number (like MSTP index corrsponding to the user given MST ID). As long we choose one (either MST ID or internal MSTP index corresponding to the user given MST ID) and use it consistently the MSTP works.

However, based on the orchagent code, it seems the STP_PORT_STATE_TABLE records in APPL_DB use the key STP_PORT_STATE_TABLE:<interface name>:<instance id>. If we use internal MSTP index, we'll see the port state records of CIST with key STP_PORT_STATE_TABLE:<interface name>:64 and the port records for non CIST MST ID (say MST 1), we'll see those records with key STP_PORT_STATE_TABLE:<interface name>:0. This is bit confusing and also the apis related to stp instance in src/sonic-stp/stpsync/stp_sync.cpp and the orchagent functions for STP_PORT_STATE_TABLE indicate using instance.

If passing mstp_index is the preferred way, I'll close this PR. But, I would recommend to document the schema for APPL_DB STP_PORT_STATE_TABLE to indicate that the key has internal MSTP index but not the user given MST ID and add a fv pair in this records to give MST ID of the index in the key in addition to the state value.

I'll be happy to update the HLD: STP_PORT_STATE_TABLE. to provide the schema details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants