Skip to content

Commit 729b863

Browse files
PrabhuSreenivasandaall
authored andcommitted
fixed unsupported resource issue (#1641)
Fix sonic-net/sonic-buildimage#6563 **What I did** Instead of erasing unsupported resource from m_resourcesMap, mark it as unsupported. **Why I did it** Erasing an entry while iterating using range based iterator makes the iterator invalid. Also removing a resource from the m_resourcesMap impacts cross access while iterating other maps (eg crmUsedCntsTableMap). **How I verified it** Added a new unsupported resource for testing and verified the logs.
1 parent 277769d commit 729b863

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

orchagent/crmorch.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,12 @@ void CrmOrch::getResAvailableCounters()
436436

437437
for (auto &res : m_resourcesMap)
438438
{
439+
// ignore unsupported resources
440+
if (res.second.resStatus != CrmResourceStatus::CRM_RES_SUPPORTED)
441+
{
442+
continue;
443+
}
444+
439445
sai_attribute_t attr;
440446
attr.id = crmResSaiAvailAttrMap.at(res.first);
441447

@@ -462,8 +468,8 @@ void CrmOrch::getResAvailableCounters()
462468
SAI_STATUS_IS_ATTR_NOT_SUPPORTED(status) ||
463469
SAI_STATUS_IS_ATTR_NOT_IMPLEMENTED(status))
464470
{
465-
// remove unsupported resources from map
466-
m_resourcesMap.erase(res.first);
471+
// mark unsupported resources
472+
res.second.resStatus = CrmResourceStatus::CRM_RES_NOT_SUPPORTED;
467473
SWSS_LOG_NOTICE("Switch attribute %u not supported", attr.id);
468474
break;
469475
}

orchagent/crmorch.h

+7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ enum class CrmThresholdType
3737
CRM_FREE,
3838
};
3939

40+
enum class CrmResourceStatus
41+
{
42+
CRM_RES_SUPPORTED,
43+
CRM_RES_NOT_SUPPORTED,
44+
};
45+
4046
class CrmOrch : public Orch
4147
{
4248
public:
@@ -77,6 +83,7 @@ class CrmOrch : public Orch
7783
std::map<std::string, CrmResourceCounter> countersMap;
7884

7985
uint32_t exceededLogCounter = 0;
86+
CrmResourceStatus resStatus = CrmResourceStatus::CRM_RES_SUPPORTED;
8087
};
8188

8289
std::chrono::seconds m_pollingInterval;

0 commit comments

Comments
 (0)