Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swss: Fixing race condition for rif counters #2488

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,6 @@ 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 @@ -1500,45 +1499,11 @@ void IntfsOrch::removeRifFromFlexCounter(const string &id, const string &name)
SWSS_LOG_DEBUG("Unregistered interface %s from Flex counter", name.c_str());
}

/*
TODO A race condition can exist when swss removes the counter from COUNTERS DB
and at the same time syncd is inserting a new entry in COUNTERS DB. Therefore
all the rif counters cleanup code should move to syncd
*/
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: 0 additions & 4 deletions orchagent/intfsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ 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, string loopbackAction);
bool removeRouterIntfs(Port &port);
Expand Down