From 289c5f1379210727f3cc4fbce7f5f3b849648a25 Mon Sep 17 00:00:00 2001 From: Shu0T1an ChenG Date: Mon, 19 Aug 2019 11:39:46 -0700 Subject: [PATCH] [neighorch]: Return false when the next hop IP exists before adding 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 --- orchagent/neighorch.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index f4168418008..1d26d1eb2a3 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -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)) { @@ -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 next_hop_attrs;