diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 19e398fc88..d2ae35339c 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10618,6 +10618,8 @@ DEFUN (show_ip_bgp_large_community, bgp_show_type_lcommunity_all, NULL, uj); } +static int bgp_table_stats_single(struct vty *vty, struct bgp *bgp, afi_t afi, + safi_t safi, struct json_object *json_array); static int bgp_table_stats(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, struct json_object *json); @@ -10637,7 +10639,7 @@ DEFUN(show_ip_bgp_statistics_all, show_ip_bgp_statistics_all_cmd, bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, &bgp, false); - if (!bgp) + if (!idx) return CMD_WARNING; if (uj) @@ -11396,8 +11398,18 @@ static int bgp_table_stats_walker(struct thread *t) return 0; } -static int bgp_table_stats(struct vty *vty, struct bgp *bgp, afi_t afi, - safi_t safi, struct json_object *json_array) +static void bgp_table_stats_all(struct vty *vty, afi_t afi, safi_t safi, + struct json_object *json_array) +{ + struct listnode *node, *nnode; + struct bgp *bgp; + + for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) + bgp_table_stats_single(vty, bgp, afi, safi, json_array); +} + +static int bgp_table_stats_single(struct vty *vty, struct bgp *bgp, afi_t afi, + safi_t safi, struct json_object *json_array) { struct bgp_table_stats ts; unsigned int i; @@ -11615,6 +11627,17 @@ end_table_stats: return ret; } +static int bgp_table_stats(struct vty *vty, struct bgp *bgp, afi_t afi, + safi_t safi, struct json_object *json_array) +{ + if (!bgp) { + bgp_table_stats_all(vty, afi, safi, json_array); + return CMD_SUCCESS; + } + + return bgp_table_stats_single(vty, bgp, afi, safi, json_array); +} + enum bgp_pcounts { PCOUNT_ADJ_IN = 0, PCOUNT_DAMPED,