diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index ef6da962e3..1479f3591e 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -975,6 +975,7 @@ void RouteOrch::doTask(Consumer& consumer) // Go through the bulker results auto it_prev = consumer.m_toSync.begin(); m_bulkNhgReducedRefCnt.clear(); + m_bulkNhReducedRefCnt.clear(); while (it_prev != it) { KeyOpFieldsValuesTuple t = it_prev->second; @@ -1070,6 +1071,13 @@ void RouteOrch::doTask(Consumer& consumer) removeNextHopGroup(it_nhg.first); } } + for (auto& it_nh : m_bulkNhReducedRefCnt) + { + if (it_nh.isMplsNextHop() && (m_neighOrch->getNextHopRefCount(it_nh) == 0)) + { + m_neighOrch->removeMplsNextHop(it_nh); + } + } } } @@ -2608,7 +2616,7 @@ bool RouteOrch::removeRoutePost(const RouteBulkContext& ctx) if (nexthop.isMplsNextHop() && (m_neighOrch->getNextHopRefCount(nexthop) == 0)) { - m_neighOrch->removeMplsNextHop(nexthop); + m_bulkNhReducedRefCnt.push_back(nexthop); } else if (nexthop.isSrv6NextHop() && (m_neighOrch->getNextHopRefCount(nexthop) == 0)) diff --git a/orchagent/routeorch.h b/orchagent/routeorch.h index 595af46081..55be18cfec 100644 --- a/orchagent/routeorch.h +++ b/orchagent/routeorch.h @@ -253,6 +253,8 @@ class RouteOrch : public Orch, public Subject std::set> m_bulkNhgReducedRefCnt; /* m_bulkNhgReducedRefCnt: nexthop, vrf_id */ + std::vector m_bulkNhReducedRefCnt; + std::set m_SubnetDecapTermsCreated; ProducerStateTable m_appTunnelDecapTermProducer;