Skip to content

Commit cb1b3f4

Browse files
authored
Remove system neighbor DEL operation in m_toSync if SET operation for (#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.
1 parent 5b27c20 commit cb1b3f4

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

orchagent/neighorch.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,17 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
14201420
{
14211421
SWSS_LOG_NOTICE("VOQ encap index updated for neighbor %s", kfvKey(t).c_str());
14221422
it = consumer.m_toSync.erase(it);
1423+
1424+
/* Remove remaining DEL operation in m_toSync for the same neighbor.
1425+
* Since DEL operation is supposed to be executed before SET for the same neighbor
1426+
* A remaining DEL after the SET operation means the DEL operation failed previously and should not be executed anymore
1427+
*/
1428+
auto rit = make_reverse_iterator(it);
1429+
while (rit != consumer.m_toSync.rend() && rit->first == key && kfvOp(rit->second) == DEL_COMMAND)
1430+
{
1431+
consumer.m_toSync.erase(next(rit).base());
1432+
SWSS_LOG_NOTICE("Removed pending system neighbor DEL operation for %s after SET operation", key.c_str());
1433+
}
14231434
}
14241435
continue;
14251436
}
@@ -1481,6 +1492,7 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
14811492
else
14821493
{
14831494
it++;
1495+
continue;
14841496
}
14851497
}
14861498
else
@@ -1489,6 +1501,17 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
14891501
SWSS_LOG_INFO("System neighbor %s already exists", kfvKey(t).c_str());
14901502
it = consumer.m_toSync.erase(it);
14911503
}
1504+
1505+
/* Remove remaining DEL operation in m_toSync for the same neighbor.
1506+
* Since DEL operation is supposed to be executed before SET for the same neighbor
1507+
* A remaining DEL after the SET operation means the DEL operation failed previously and should not be executed anymore
1508+
*/
1509+
auto rit = make_reverse_iterator(it);
1510+
while (rit != consumer.m_toSync.rend() && rit->first == key && kfvOp(rit->second) == DEL_COMMAND)
1511+
{
1512+
consumer.m_toSync.erase(next(rit).base());
1513+
SWSS_LOG_NOTICE("Removed pending system neighbor DEL operation for %s after SET operation", key.c_str());
1514+
}
14921515
}
14931516
else if (op == DEL_COMMAND)
14941517
{

0 commit comments

Comments
 (0)