Skip to content

Commit

Permalink
Merge pull request FRRouting#16850 from enkechen-panw/show-stat
Browse files Browse the repository at this point in the history
bgpd: add counters for redistributed and aggregated routes
  • Loading branch information
ton31337 authored Sep 18, 2024
2 parents da96ad0 + 25c290a commit 7a7ae88
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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}
};

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7a7ae88

Please sign in to comment.