]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: add counters for redistributed and aggregated routes 16850/head
authorEnke Chen <enchen@paloaltonetworks.com>
Tue, 17 Sep 2024 22:12:05 +0000 (15:12 -0700)
committerEnke Chen <enchen@paloaltonetworks.com>
Tue, 17 Sep 2024 22:13:49 +0000 (15:13 -0700)
Add counters for redistributed routes, and local aggregates to the
output of "show ip bgp statistics".

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
bgpd/bgp_route.c

index f10a84dce9a6942a297ac6fbefbcd0afecad7335..d799ea0bd8544b99f572deb57e9d5040a7146bc4 100644 (file)
@@ -13672,6 +13672,8 @@ enum bgp_stats {
        BGP_STATS_ASPATH_MAXSIZE,
        BGP_STATS_ASPATH_TOTSIZE,
        BGP_STATS_ASN_HIGHEST,
+       BGP_STATS_REDISTRIBUTED,
+       BGP_STATS_LOCAL_AGGREGATES,
        BGP_STATS_MAX,
 };
 
@@ -13701,6 +13703,8 @@ static const char *table_stats_strs[][2] = {
        [BGP_STATS_ASPATH_TOTSIZE] = {"Average AS-Path size (bytes)",
                                      "averageAsPathSizeBytes"},
        [BGP_STATS_ASN_HIGHEST] = {"Highest public ASN", "highestPublicAsn"},
+       [BGP_STATS_REDISTRIBUTED] = {"Redistributed routes", "totalRedistributed"},
+       [BGP_STATS_LOCAL_AGGREGATES] = {"Local aggregates", "totalLocalAggregates"},
        [BGP_STATS_MAX] = {NULL, NULL}
 };
 
@@ -13750,6 +13754,15 @@ static void bgp_table_stats_rn(struct bgp_dest *dest, struct bgp_dest *top,
                               ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)))
                        ts->counts[BGP_STATS_AGGREGATES]++;
 
+               if (pi->peer == ts->table->bgp->peer_self) {
+                       if (pi->sub_type == BGP_ROUTE_REDISTRIBUTE)
+                               ts->counts[BGP_STATS_REDISTRIBUTED]++;
+
+                       if ((pi->type == ZEBRA_ROUTE_BGP) &&
+                           (pi->sub_type == BGP_ROUTE_AGGREGATE))
+                               ts->counts[BGP_STATS_LOCAL_AGGREGATES]++;
+               }
+
                /* as-path stats */
                if (pi->attr->aspath) {
                        unsigned int hops = aspath_count_hops(pi->attr->aspath);