Skip to content

Commit

Permalink
Remove system neighbor DEL operation in m_toSync if SET operation for (
Browse files Browse the repository at this point in the history
…sonic-net#2853)

*Remove system neighbor DEL operation in m_toSync if SET operation for the same neighbor succeeds. This is to avoid mistakenly removing the system neighbor.

Fix sonic-net/sonic-buildimage#15266.
  • Loading branch information
ysmanman authored and StormLiangMS committed Aug 6, 2023
1 parent fa34230 commit 27b6457
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,17 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
{
SWSS_LOG_NOTICE("VOQ encap index updated for neighbor %s", kfvKey(t).c_str());
it = consumer.m_toSync.erase(it);

/* Remove remaining DEL operation in m_toSync for the same neighbor.
* Since DEL operation is supposed to be executed before SET for the same neighbor
* A remaining DEL after the SET operation means the DEL operation failed previously and should not be executed anymore
*/
auto rit = make_reverse_iterator(it);
while (rit != consumer.m_toSync.rend() && rit->first == key && kfvOp(rit->second) == DEL_COMMAND)
{
consumer.m_toSync.erase(next(rit).base());
SWSS_LOG_NOTICE("Removed pending system neighbor DEL operation for %s after SET operation", key.c_str());
}
}
continue;
}
Expand Down Expand Up @@ -1481,6 +1492,7 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
else
{
it++;
continue;
}
}
else
Expand All @@ -1489,6 +1501,17 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
SWSS_LOG_INFO("System neighbor %s already exists", kfvKey(t).c_str());
it = consumer.m_toSync.erase(it);
}

/* Remove remaining DEL operation in m_toSync for the same neighbor.
* Since DEL operation is supposed to be executed before SET for the same neighbor
* A remaining DEL after the SET operation means the DEL operation failed previously and should not be executed anymore
*/
auto rit = make_reverse_iterator(it);
while (rit != consumer.m_toSync.rend() && rit->first == key && kfvOp(rit->second) == DEL_COMMAND)
{
consumer.m_toSync.erase(next(rit).base());
SWSS_LOG_NOTICE("Removed pending system neighbor DEL operation for %s after SET operation", key.c_str());
}
}
else if (op == DEL_COMMAND)
{
Expand Down

0 comments on commit 27b6457

Please sign in to comment.