diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 58b8eb995e..9b642b316d 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -2964,12 +2964,10 @@ bool RouteOrch::removeRoutePost(const RouteBulkContext& ctx) return true; } -bool RouteOrch::isRouteExists(const IpPrefix& prefix) +bool RouteOrch::isRouteExists(sai_object_id_t vrf_id, const IpPrefix& prefix) { SWSS_LOG_ENTER(); - sai_object_id_t& vrf_id = gVirtualRouterId; - sai_route_entry_t route_entry; route_entry.vr_id = vrf_id; route_entry.switch_id = gSwitchId; diff --git a/orchagent/routeorch.h b/orchagent/routeorch.h index a903dc42e0..54ddaf2b00 100644 --- a/orchagent/routeorch.h +++ b/orchagent/routeorch.h @@ -253,7 +253,7 @@ class RouteOrch : public ZmqOrch, public Subject const NextHopGroupKey getSyncdRouteNhgKey(sai_object_id_t vrf_id, const IpPrefix& ipPrefix); bool createFineGrainedNextHopGroup(sai_object_id_t &next_hop_group_id, vector &nhg_attrs); bool removeFineGrainedNextHopGroup(sai_object_id_t &next_hop_group_id); - bool isRouteExists(const IpPrefix& prefix); + bool isRouteExists(sai_object_id_t vrf_id, const IpPrefix& prefix); bool removeRoutePrefix(const IpPrefix& prefix); void addLinkLocalRouteToMe(sai_object_id_t vrf_id, IpPrefix linklocal_prefix); diff --git a/orchagent/vnetorch.cpp b/orchagent/vnetorch.cpp index 57fd236b08..7bc7deb086 100644 --- a/orchagent/vnetorch.cpp +++ b/orchagent/vnetorch.cpp @@ -1192,7 +1192,7 @@ bool VNetRouteOrch::doRouteTask(const string& vnet, IpPrefix& ipP prefixToRemove = adv_prefix; } auto prefixSubnet = prefixToRemove.getSubnet(); - if(gRouteOrch && gRouteOrch->isRouteExists(prefixSubnet)) + if(gRouteOrch && gRouteOrch->isRouteExists(vr_id, prefixSubnet)) { if (!gRouteOrch->removeRoutePrefix(prefixSubnet)) { @@ -2501,7 +2501,9 @@ void VNetRouteOrch::updateVnetTunnel(const BfdUpdate& update) ipPrefixsubnet = adv_prefix.getSubnet(); } } - if(gRouteOrch && gRouteOrch->isRouteExists(ipPrefixsubnet)) + + sai_object_id_t vr_id = vrf_obj->getVRidIngress(); + if(gRouteOrch && gRouteOrch->isRouteExists(vr_id, ipPrefixsubnet)) { if (!gRouteOrch->removeRoutePrefix(ipPrefixsubnet)) { @@ -2749,7 +2751,7 @@ void VNetRouteOrch::updateVnetTunnelCustomMonitor(const MonitorUpdate& update) } } auto prefixsubnet = prefixToUse.getSubnet(); - if (gRouteOrch && gRouteOrch->isRouteExists(prefixsubnet)) + if (gRouteOrch && gRouteOrch->isRouteExists(vr_id, prefixsubnet)) { if (!gRouteOrch->removeRoutePrefix(prefixsubnet)) {