Skip to content

Commit dc621c9

Browse files
authored
Stale rif counter db removal (fix for sonic-net#2193)_ (sonic-net#2199)
To handle this , whenever RIF is deleted (removeRouterIntfs) , we ensure that these COUNTER_DB tables are deleted(handled in cleanUpRifFromCounterDb) .
1 parent eff725f commit dc621c9

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

orchagent/intfsorch.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,7 @@ bool IntfsOrch::removeRouterIntfs(Port &port)
12041204

12051205
const auto id = sai_serialize_object_id(port.m_rif_id);
12061206
removeRifFromFlexCounter(id, port.m_alias);
1207+
cleanUpRifFromCounterDb(id, port.m_alias);
12071208

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

1430+
void IntfsOrch::cleanUpRifFromCounterDb(const string &id, const string &name)
1431+
{
1432+
SWSS_LOG_ENTER();
1433+
string counter_key = getRifCounterTableKey(id);
1434+
string rate_key = getRifRateTableKey(id);
1435+
string rate_init_key = getRifRateInitTableKey(id);
1436+
m_counter_db->del(counter_key);
1437+
m_counter_db->del(rate_key);
1438+
m_counter_db->del(rate_init_key);
1439+
SWSS_LOG_NOTICE("CleanUp interface %s oid %s from counter db", name.c_str(),id.c_str());
1440+
}
1441+
14291442
string IntfsOrch::getRifFlexCounterTableKey(string key)
14301443
{
14311444
return string(RIF_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
14321445
}
14331446

1447+
string IntfsOrch::getRifCounterTableKey(string key)
1448+
{
1449+
return "COUNTERS:" + key;
1450+
}
1451+
1452+
string IntfsOrch::getRifRateTableKey(string key)
1453+
{
1454+
return "RATES:" + key;
1455+
}
1456+
1457+
string IntfsOrch::getRifRateInitTableKey(string key)
1458+
{
1459+
return "RATES:" + key + ":RIF";
1460+
}
1461+
1462+
1463+
14341464
void IntfsOrch::generateInterfaceMap()
14351465
{
14361466
m_updateMapsTimer->start();

orchagent/intfsorch.h

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ class IntfsOrch : public Orch
9090
unique_ptr<ProducerTable> m_flexCounterGroupTable;
9191

9292
std::string getRifFlexCounterTableKey(std::string s);
93+
std::string getRifCounterTableKey(std::string s);
94+
std::string getRifRateTableKey(std::string s);
95+
std::string getRifRateInitTableKey(std::string s);
96+
void cleanUpRifFromCounterDb(const string &id, const string &name);
9397

9498
bool addRouterIntfs(sai_object_id_t vrf_id, Port &port);
9599
bool removeRouterIntfs(Port &port);

0 commit comments

Comments
 (0)