Skip to content

Commit

Permalink
[neighorch]: Return false when the next hop IP exists before adding
Browse files Browse the repository at this point in the history
It is possible that due to events reordering, a different next hop
entry with same IP will be inserted before the previous next hop
entry gets removed. Thus, return false here to prevent the new entry
from replacing the old one automatically.

Update the symmetric removeNextHop() function as well.

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
  • Loading branch information
Shu0T1an ChenG committed Sep 17, 2019
1 parent 3fb22e1 commit 2c944b6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ bool NeighOrch::addNextHop(IpAddress ipAddress, string alias)
{
SWSS_LOG_ENTER();

if (hasNextHop(ipAddress))
{
SWSS_LOG_ERROR("Next hop IP %s already exists",
ipAddress.to_string().c_str());
return false;
}

Port p;
if (!gPortsOrch->getPort(alias, p))
{
Expand All @@ -38,7 +45,6 @@ bool NeighOrch::addNextHop(IpAddress ipAddress, string alias)
return false;
}

assert(!hasNextHop(ipAddress));
sai_object_id_t rif_id = m_intfsOrch->getRouterIntfsId(alias);

vector<sai_attribute_t> next_hop_attrs;
Expand Down Expand Up @@ -213,7 +219,12 @@ bool NeighOrch::removeNextHop(IpAddress ipAddress, string alias)
{
SWSS_LOG_ENTER();

assert(hasNextHop(ipAddress));
if (!hasNextHop(ipAddress))
{
SWSS_LOG_ERROR("Next hop IP %s already removed",
ipAddress.to_string().c_str());
return false;
}

if (m_syncdNextHops[ipAddress].ref_count > 0)
{
Expand Down

0 comments on commit 2c944b6

Please sign in to comment.