From f3132e14942108d3b4abf29b0c3102805ce038ca Mon Sep 17 00:00:00 2001 From: Ananth Suryanarayana Date: Tue, 20 Sep 2016 13:31:17 -0700 Subject: [PATCH] Remove instance stats uve upon instance deletion Also send infeasible paths count as part of table stats uve Change-Id: I8ef25b52ec643eb1f2111893846004c8047836f7 Partial-Bug: #1576437 --- src/bgp/bgp_server.cc | 7 +++++++ src/bgp/routing-instance/routing_instance.cc | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/bgp/bgp_server.cc b/src/bgp/bgp_server.cc index dd2d89c2e4d..f14e15bf8f2 100644 --- a/src/bgp/bgp_server.cc +++ b/src/bgp/bgp_server.cc @@ -773,6 +773,13 @@ uint32_t BgpServer::SendTableStatsUve(bool first) const { table->GetSecondaryPathCount()); } + if (first || table->stats()->get_infeasible_paths() != + table->GetInfeasiblePathCount()) { + changed = true; + table->stats()->set_infeasible_paths( + table->GetSecondaryPathCount()); + } + uint64_t total_paths = table->stats()->get_primary_paths() + table->stats()->get_secondary_paths() + table->stats()->get_infeasible_paths(); diff --git a/src/bgp/routing-instance/routing_instance.cc b/src/bgp/routing-instance/routing_instance.cc index 9c1c55eac85..64fa0d5fded 100644 --- a/src/bgp/routing-instance/routing_instance.cc +++ b/src/bgp/routing-instance/routing_instance.cc @@ -13,6 +13,7 @@ #include "bgp/bgp_factory.h" #include "bgp/bgp_log.h" #include "bgp/bgp_server.h" +#include "bgp/bgp_table_types.h" #include "bgp/routing-instance/iroute_aggregator.h" #include "bgp/routing-instance/iservice_chain_mgr.h" #include "bgp/routing-instance/istatic_route_mgr.h" @@ -426,6 +427,12 @@ void RoutingInstanceMgr::DestroyRoutingInstance(RoutingInstance *rtinstance) { RTINSTANCE_LOG(Destroy, rtinstance, SandeshLevel::SYS_DEBUG, RTINSTANCE_LOG_FLAG_ALL); + // Delete instance stats uve. + RoutingInstanceStatsData instance_info; + instance_info.set_name(rtinstance->name()); + instance_info.set_deleted(true); + RoutingInstanceStats::Send(instance_info); + // Remove call here also deletes the instance. const string name = rtinstance->name(); instances_.Remove(rtinstance->name(), rtinstance->index());