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.

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
  • Loading branch information
Shu0T1an ChenG committed Aug 19, 2019
1 parent 65cbd55 commit 289c5f1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion 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

0 comments on commit 289c5f1

Please sign in to comment.