Skip to content

Commit

Permalink
Fix stporch init exception (#3449)
Browse files Browse the repository at this point in the history
What I did
Fixed stporch init exception
Why I did it
SAI retrieval of STP attributes may return either SAI_STATUS_NOT_SUPPORTED or SAI_STATUS_NOT_IMPLEMENTED. An exception has been added to handle such failures, preventing Orchagent from starting on systems where STP is not supported
  • Loading branch information
divyachandralekha authored Jan 6, 2025
1 parent eadb549 commit c20902f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions orchagent/stporch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ StpOrch::StpOrch(DBConnector * db, DBConnector * stateDb, vector<string> &tableN

sai_attribute_t attr;
sai_status_t status;
bool ret = false;

m_stpTable = unique_ptr<Table>(new Table(stateDb, STATE_STP_TABLE_NAME));

Expand All @@ -28,12 +29,13 @@ StpOrch::StpOrch(DBConnector * db, DBConnector * stateDb, vector<string> &tableN
attrs.push_back(attr);

status = sai_switch_api->get_switch_attribute(gSwitchId, (uint32_t)attrs.size(), attrs.data());
if (status != SAI_STATUS_SUCCESS)
if (status == SAI_STATUS_SUCCESS)
{
throw runtime_error("StpOrch initialization failure");
m_defaultStpId = attrs[0].value.oid;
ret = true;
}
m_defaultStpId = attrs[0].value.oid;

SWSS_LOG_NOTICE("StpOrch initialization %s", (ret == true)?"success":"failure");
};


Expand Down

0 comments on commit c20902f

Please sign in to comment.