Skip to content

Commit

Permalink
[flowcounterrouter] Fix the Route remove flow for non-bound prefixes (s…
Browse files Browse the repository at this point in the history
…onic-net#2691)

*Update the isRouteAlreadyBound to consider both the maps for verifying whether the prefix is deleted or not.
  • Loading branch information
vivekrnv authored Mar 14, 2023
1 parent b44692c commit a2bd92f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
21 changes: 14 additions & 7 deletions orchagent/flex_counter/flowcounterrouteorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down

0 comments on commit a2bd92f

Please sign in to comment.