Skip to content

Commit

Permalink
Stale rif counter db removal (fix for sonic-net#2193)_ (sonic-net#2199)
Browse files Browse the repository at this point in the history
To handle this , whenever RIF is deleted (removeRouterIntfs) , we ensure that these COUNTER_DB tables are deleted(handled in cleanUpRifFromCounterDb) .
  • Loading branch information
sumanbrcm authored May 12, 2022
1 parent eff725f commit dc621c9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
30 changes: 30 additions & 0 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ bool IntfsOrch::removeRouterIntfs(Port &port)

const auto id = sai_serialize_object_id(port.m_rif_id);
removeRifFromFlexCounter(id, port.m_alias);
cleanUpRifFromCounterDb(id, port.m_alias);

sai_status_t status = sai_router_intfs_api->remove_router_interface(port.m_rif_id);
if (status != SAI_STATUS_SUCCESS)
Expand Down Expand Up @@ -1426,11 +1427,40 @@ void IntfsOrch::removeRifFromFlexCounter(const string &id, const string &name)
SWSS_LOG_DEBUG("Unregistered interface %s from Flex counter", name.c_str());
}

void IntfsOrch::cleanUpRifFromCounterDb(const string &id, const string &name)
{
SWSS_LOG_ENTER();
string counter_key = getRifCounterTableKey(id);
string rate_key = getRifRateTableKey(id);
string rate_init_key = getRifRateInitTableKey(id);
m_counter_db->del(counter_key);
m_counter_db->del(rate_key);
m_counter_db->del(rate_init_key);
SWSS_LOG_NOTICE("CleanUp interface %s oid %s from counter db", name.c_str(),id.c_str());
}

string IntfsOrch::getRifFlexCounterTableKey(string key)
{
return string(RIF_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
}

string IntfsOrch::getRifCounterTableKey(string key)
{
return "COUNTERS:" + key;
}

string IntfsOrch::getRifRateTableKey(string key)
{
return "RATES:" + key;
}

string IntfsOrch::getRifRateInitTableKey(string key)
{
return "RATES:" + key + ":RIF";
}



void IntfsOrch::generateInterfaceMap()
{
m_updateMapsTimer->start();
Expand Down
4 changes: 4 additions & 0 deletions orchagent/intfsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class IntfsOrch : public Orch
unique_ptr<ProducerTable> m_flexCounterGroupTable;

std::string getRifFlexCounterTableKey(std::string s);
std::string getRifCounterTableKey(std::string s);
std::string getRifRateTableKey(std::string s);
std::string getRifRateInitTableKey(std::string s);
void cleanUpRifFromCounterDb(const string &id, const string &name);

bool addRouterIntfs(sai_object_id_t vrf_id, Port &port);
bool removeRouterIntfs(Port &port);
Expand Down

0 comments on commit dc621c9

Please sign in to comment.