Skip to content

Commit

Permalink
Update FDB CRM counters based on return value (sonic-net#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
prsunny authored Apr 6, 2018
1 parent e217519 commit d711d2c
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,21 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj

update.add = true;

(void)m_entries.insert(update.entry);
SWSS_LOG_DEBUG("FdbOrch notification: mac %s was inserted into bv_id 0x%lx", update.entry.mac.to_string().c_str(), entry->bv_id);
{
auto ret = m_entries.insert(update.entry);

gCrmOrch->incCrmResUsedCounter(CrmResourceType::CRM_FDB_ENTRY);
SWSS_LOG_DEBUG("FdbOrch notification: mac %s was inserted into bv_id 0x%lx",
update.entry.mac.to_string().c_str(), entry->bv_id);

if (ret.second)
{
gCrmOrch->incCrmResUsedCounter(CrmResourceType::CRM_FDB_ENTRY);
}
else
{
SWSS_LOG_INFO("FdbOrch notification: mac %s is duplicate", update.entry.mac.to_string().c_str());
}
}

for (auto observer: m_observers)
{
Expand All @@ -62,10 +73,15 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj
case SAI_FDB_EVENT_MOVE:
update.add = false;

(void)m_entries.erase(update.entry);
SWSS_LOG_DEBUG("FdbOrch notification: mac %s was removed from bv_id 0x%lx", update.entry.mac.to_string().c_str(), entry->bv_id);
{
auto ret = m_entries.erase(update.entry);
SWSS_LOG_DEBUG("FdbOrch notification: mac %s was removed from bv_id 0x%lx", update.entry.mac.to_string().c_str(), entry->bv_id);

gCrmOrch->decCrmResUsedCounter(CrmResourceType::CRM_FDB_ENTRY);
if (ret)
{
gCrmOrch->decCrmResUsedCounter(CrmResourceType::CRM_FDB_ENTRY);
}
}

for (auto observer: m_observers)
{
Expand Down

0 comments on commit d711d2c

Please sign in to comment.