From a2bd92fbc0c4daf5e2038120e77baa314825193e Mon Sep 17 00:00:00 2001 From: Vivek Date: Tue, 14 Mar 2023 15:04:44 -0700 Subject: [PATCH] [flowcounterrouter] Fix the Route remove flow for non-bound prefixes (#2691) *Update the isRouteAlreadyBound to consider both the maps for verifying whether the prefix is deleted or not. --- .../flex_counter/flowcounterrouteorch.cpp | 21 ++++++++++++------- orchagent/routeorch.cpp | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/orchagent/flex_counter/flowcounterrouteorch.cpp b/orchagent/flex_counter/flowcounterrouteorch.cpp index 49107cfce6..9f5e6e2355 100644 --- a/orchagent/flex_counter/flowcounterrouteorch.cpp +++ b/orchagent/flex_counter/flowcounterrouteorch.cpp @@ -602,18 +602,25 @@ bool FlowCounterRouteOrch::isRouteAlreadyBound(const RoutePattern &route_pattern { SWSS_LOG_ENTER(); - auto iter = mBoundRouteCounters.find(route_pattern); - if (iter == mBoundRouteCounters.end()) + auto iter_bound = mBoundRouteCounters.find(route_pattern); + if (iter_bound != mBoundRouteCounters.end()) { - auto pending_iter = mPendingAddToFlexCntr.find(route_pattern); - if (pending_iter != mPendingAddToFlexCntr.end()) + if (iter_bound->second.find(ip_prefix) != iter_bound->second.end()) { - return pending_iter->second.find(ip_prefix) != pending_iter->second.end(); + return true; + } + } + + auto iter_pending = mPendingAddToFlexCntr.find(route_pattern); + if (iter_pending != mPendingAddToFlexCntr.end()) + { + if (iter_pending->second.find(ip_prefix) != iter_pending->second.end()) + { + return true; } - return false; } - return iter->second.find(ip_prefix) != iter->second.end(); + return false; } void FlowCounterRouteOrch::createRouteFlowCounterByPattern(const RoutePattern &route_pattern, size_t current_bound_count) diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 4b68979da7..d6762505f4 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -2467,7 +2467,6 @@ bool RouteOrch::removeRoutePost(const RouteBulkContext& ctx) } else { - gFlowCounterRouteOrch->handleRouteRemove(vrf_id, ipPrefix); it_route_table->second.erase(ipPrefix); /* Notify about the route next hop removal */ @@ -2478,6 +2477,8 @@ bool RouteOrch::removeRoutePost(const RouteBulkContext& ctx) m_syncdRoutes.erase(vrf_id); m_vrfOrch->decreaseVrfRefCount(vrf_id); } + + gFlowCounterRouteOrch->handleRouteRemove(vrf_id, ipPrefix); } return true;