diff --git a/src/bgp/bgp_server.cc b/src/bgp/bgp_server.cc index 26b05bc3c97..998361ca1fc 100644 --- a/src/bgp/bgp_server.cc +++ b/src/bgp/bgp_server.cc @@ -743,7 +743,7 @@ uint32_t BgpServer::SendTableStatsUve(bool first) const { rit != inst_mgr_->end(); ++rit) { RoutingInstanceStatsData instance_info; RoutingInstance::RouteTableList const rt_list = rit->GetTables(); - std::vector tables_stats; + std::map tables_stats; for (RoutingInstance::RouteTableList::const_iterator it = rt_list.begin(); it != rt_list.end(); ++it) { @@ -754,10 +754,6 @@ uint32_t BgpServer::SendTableStatsUve(bool first) const { string family = Address::FamilyToString(table->family()); bool changed = false; - if (first || table->stats()->get_address_family() != family) { - changed = true; - table->stats()->set_address_family(family); - } if (first || table->stats()->get_prefixes() != table->Size()) { changed = true; @@ -786,7 +782,11 @@ uint32_t BgpServer::SendTableStatsUve(bool first) const { } if (changed) { - tables_stats.push_back(*table->stats()); + + // Set the address family to be able to find to which family, + // the associated updated stats are applicable. + table->stats()->set_address_family(family); + tables_stats.insert(make_pair(family, *table->stats())); // Reset changed flags in the uve structure. memset(&(table->stats()->__isset), 0, diff --git a/src/bgp/bgp_table.sandesh b/src/bgp/bgp_table.sandesh index a0e163ece0a..9087da03f2f 100644 --- a/src/bgp/bgp_table.sandesh +++ b/src/bgp/bgp_table.sandesh @@ -7,7 +7,7 @@ include "bgp/table_info.sandesh" struct RoutingInstanceStatsData { 1: string name (key="ObjectRoutingInstance"); 2: optional bool deleted - 3: optional list table_stats (tags=".address_family"); + 3: optional map table_stats (tags=".address_family"); } /**