From c44a84e820292b0236595eaf98da50748543fa08 Mon Sep 17 00:00:00 2001 From: vedganes Date: Tue, 25 Nov 2025 18:15:59 -0500 Subject: [PATCH] [mstp] Fix for passing internal index to stpsync 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 --- mstp/mstp_mgr.c | 31 +++++++++++++++---------------- mstp/mstp_util.c | 8 ++++---- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/mstp/mstp_mgr.c b/mstp/mstp_mgr.c index 9c67b37..1e5946a 100755 --- a/mstp/mstp_mgr.c +++ b/mstp/mstp_mgr.c @@ -281,7 +281,7 @@ static void mstpmgr_free_mstp_port(PORT_ID port_number) { /* 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); } mstpdata_free_port(port_number); } @@ -983,7 +983,7 @@ void mstpmgr_delete_member_port(MSTP_INDEX mstp_index, PORT_ID port_number) { if (!IS_MEMBER(cist_bridge->co.portmask, port_number)) return; - stpsync_del_port_state(ifname, mstp_index); + stpsync_del_port_state(ifname, mstputil_get_mstid(mstp_index)); clear_mask_bit(cist_bridge->co.portmask, port_number); } else @@ -999,7 +999,7 @@ void mstpmgr_delete_member_port(MSTP_INDEX mstp_index, PORT_ID port_number) { /* Delete MSTI port from APP DB*/ stpsync_del_mst_port_info(ifname, mstputil_get_mstid(mstp_index)); - stpsync_del_port_state(ifname, mstp_index); + stpsync_del_port_state(ifname, mstputil_get_mstid(mstp_index)); } if (IS_MEMBER(cist_bridge->co.portmask, port_number)) return; @@ -1608,7 +1608,7 @@ bool mstpmgr_config_instance_vlanmask(MSTP_MSTID mstid, VLAN_MASK *vlanmask) vlanmask_set_bit(&cbridge->vlanmask, vlan_id); if(mstpdata_is_vlan_present(vlan_id)) { - stpsync_add_vlan_to_instance(vlan_id, mstp_index); + stpsync_add_vlan_to_instance(vlan_id, mstid); } flag = true; } @@ -1631,7 +1631,7 @@ bool mstpmgr_config_instance_vlanmask(MSTP_MSTID mstid, VLAN_MASK *vlanmask) vlanmask_clear_bit(&cbridge->vlanmask, vlan_id); if(mstpdata_is_vlan_present(vlan_id)) { - stpsync_del_vlan_from_instance(vlan_id, mstp_index); + stpsync_del_vlan_from_instance(vlan_id, mstid); } flag = true; } @@ -2363,7 +2363,7 @@ void mstpmgr_process_vlan_mem_config_msg(void *msg) mst_id = MSTP_GET_MSTID(mstp_bridge, pmsg->vlan_id); mstp_index = MSTP_GET_INSTANCE_INDEX(mstp_bridge, mst_id); if (mstp_index != MSTP_INDEX_INVALID) - stpsync_add_vlan_to_instance(pmsg->vlan_id, mstp_index); + stpsync_add_vlan_to_instance(pmsg->vlan_id, mst_id); } } @@ -2394,7 +2394,7 @@ void mstpmgr_process_vlan_mem_config_msg(void *msg) { mstputil_set_kernel_bridge_port_state(mstp_index, port_id, FORWARDING); STP_LOG_INFO("[MST %d] Port %s FORWARDING", mst_id, port_list[port_count].intf_name); - stpsync_update_port_state(port_list[port_count].intf_name, mstp_index, FORWARDING); + stpsync_update_port_state(port_list[port_count].intf_name, mst_id, FORWARDING); continue; } } @@ -2429,7 +2429,7 @@ void mstpmgr_process_vlan_mem_config_msg(void *msg) /* For CIST index h/w port state wouldnt have updated, when vlan mask is empty. * So ensure to update the h/w port state*/ if (MSTP_IS_CIST_INDEX(mstp_index)) - stpsync_update_port_state(stp_intf_get_port_name(port_id), mstp_index, state); + stpsync_update_port_state(stp_intf_get_port_name(port_id), mst_id, state); } port_id= port_mask_get_next_port(port_mask, port_id); } @@ -2460,8 +2460,7 @@ void mstpmgr_process_vlan_mem_config_msg(void *msg) if(!mstpdata_is_vlan_present(pmsg->vlan_id)) { mst_id = MSTP_GET_MSTID(mstp_bridge, pmsg->vlan_id); - mstp_index = MSTP_GET_INSTANCE_INDEX(mstp_bridge, mst_id); - stpsync_del_vlan_from_instance(pmsg->vlan_id, mstp_index); + stpsync_del_vlan_from_instance(pmsg->vlan_id, mst_id); } } } @@ -2709,7 +2708,7 @@ void mstpmgr_process_inst_vlan_config_msg(void *msg) { mstputil_set_kernel_bridge_port_state(MSTP_INDEX_CIST, port_number, FORWARDING); /* stp disabled ports, make to forwarding */ - stpsync_update_port_state(stp_intf_get_port_name(port_number), MSTP_INDEX_CIST, FORWARDING); + stpsync_update_port_state(stp_intf_get_port_name(port_number), MSTP_MSTID_CIST, FORWARDING); port_number = port_mask_get_next_port(cist_stp_disabled_ports, port_number); } @@ -2735,7 +2734,7 @@ void mstpmgr_process_inst_vlan_config_msg(void *msg) { mstputil_set_kernel_bridge_port_state(mstp_index, port_number, FORWARDING); /* stp disabled ports, make to forwarding */ - stpsync_update_port_state(stp_intf_get_port_name(port_number), mstp_index, FORWARDING); + stpsync_update_port_state(stp_intf_get_port_name(port_number), mst_id, FORWARDING); STP_LOG_INFO("[MST %d] Port %d FORWARDING", mst_id , port_number); port_number = port_mask_get_next_port(msti_stp_disabled_ports, port_number); } @@ -2792,7 +2791,7 @@ void mstpmgr_process_inst_vlan_config_msg(void *msg) mstputil_set_kernel_bridge_port_state(MSTP_INDEX_CIST, port_number, FORWARDING); /* stp disabled ports, make to forwarding */ STP_LOG_INFO("[MST %d] Port %d FORWARDING", MSTP_MSTID_CIST, port_number); - stpsync_update_port_state(stp_intf_get_port_name(port_number), MSTP_INDEX_CIST, FORWARDING); + stpsync_update_port_state(stp_intf_get_port_name(port_number), MSTP_MSTID_CIST, FORWARDING); port_number = port_mask_get_next_port(cist_stp_disabled_ports, port_number); } @@ -3023,7 +3022,7 @@ bool mstpmgr_delete_control_port(PORT_ID port_id, bool delete_port) mstputil_set_kernel_bridge_port_state(mstp_index,port_id,FORWARDING); flag = mstpmgr_set_control_mask(mstp_index); if(!delete_port) - stpsync_update_port_state(stp_intf_get_port_name(port_id), mstp_index, FORWARDING); + stpsync_update_port_state(stp_intf_get_port_name(port_id), mstputil_get_mstid(mstp_index), FORWARDING); } } @@ -3034,7 +3033,7 @@ bool mstpmgr_delete_control_port(PORT_ID port_id, bool delete_port) mstputil_set_kernel_bridge_port_state(MSTP_INDEX_CIST, port_id,FORWARDING); flag = mstpmgr_set_control_mask(MSTP_INDEX_CIST); if(!delete_port) - stpsync_update_port_state(stp_intf_get_port_name(port_id), MSTP_INDEX_CIST, FORWARDING); + stpsync_update_port_state(stp_intf_get_port_name(port_id), MSTP_MSTID_CIST, FORWARDING); } if(flag) @@ -3249,4 +3248,4 @@ void mstpmgr_clear_statistics_all() mstpmgr_clear_port_statistics(port_number); port_number = port_mask_get_next_port(mstp_bridge->control_mask, port_number); } -} \ No newline at end of file +} diff --git a/mstp/mstp_util.c b/mstp/mstp_util.c index 5cb041c..80c504c 100755 --- a/mstp/mstp_util.c +++ b/mstp/mstp_util.c @@ -1090,14 +1090,14 @@ bool mstputil_set_port_state(MSTP_INDEX mstp_index, PORT_ID port_number, enum L2 if(ifname) { - stpsync_update_port_state(ifname, mstp_index, state); + stpsync_update_port_state(ifname, mst_id, state); } return true; } /*****************************************************************************/ -/* mstputil_flush: sets the port state for all the vlans associated */ -/* with the input mst instance to the input state */ +/* mstputil_flush: Flushes the FDB for a given port of a specific MST */ +/* insance if the fdb flush is pending after topology change */ /*****************************************************************************/ bool mstputil_flush(MSTP_INDEX mstp_index, PORT_ID port_number) { @@ -1110,7 +1110,7 @@ bool mstputil_flush(MSTP_INDEX mstp_index, PORT_ID port_number) ifname = stp_intf_get_port_name(port_number); if(!ifname) return false; - stpsync_flush_instance_port(ifname, mstp_index); + stpsync_flush_instance_port(ifname, mst_id); STP_LOG_INFO("[MST %d] %s flush", mst_id, ifname);