From 14718643743d70ff27e0ed6d6f5a131732f6e392 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 25 Feb 2020 10:19:34 +0100 Subject: [PATCH] bgpd: add show bgp l2vpn evpn statistics [json] support add show bgp l2vpn evpn statistics [json] support. Signed-off-by: Philippe Guibert --- bgpd/bgp_route.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index a9bb240a6..8acc65659 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10618,6 +10618,49 @@ DEFUN (show_ip_bgp_statistics_all, return CMD_SUCCESS; } +/* BGP route print out function without JSON */ +DEFUN (show_ip_bgp_l2vpn_evpn_statistics, + show_ip_bgp_l2vpn_evpn_statistics_cmd, + "show [ip] bgp [ VIEWVRFNAME] [l2vpn [evpn]] statistics [json]", + SHOW_STR + IP_STR + BGP_STR + BGP_INSTANCE_HELP_STR + L2VPN_HELP_STR + EVPN_HELP_STR + "BGP RIB advertisement statistics\n" + JSON_STR) +{ + afi_t afi = AFI_L2VPN; + safi_t safi = SAFI_EVPN; + struct bgp *bgp = NULL; + int idx = 0, ret; + bool uj = use_json(argc, argv); + struct json_object *json_afi_safi = NULL, *json = NULL; + + bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, + &bgp, false); + if (!idx) + return CMD_WARNING; + + if (uj) + json_afi_safi = json_object_new_array(); + else + json_afi_safi = NULL; + + ret = bgp_table_stats(vty, bgp, afi, safi, json_afi_safi); + + if (uj) { + json = json_object_new_object(); + json_object_object_add(json, get_afi_safi_str(afi, safi, true), + json_afi_safi); + vty_out(vty, "%s", json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); + json_object_free(json); + } + return ret; +} + /* BGP route print out function without JSON */ DEFUN (show_ip_bgp_afi_safi_statistics, show_ip_bgp_afi_safi_statistics_cmd, @@ -13365,6 +13408,7 @@ void bgp_route_init(void) install_element(VIEW_NODE, &show_ip_bgp_instance_all_cmd); install_element(VIEW_NODE, &show_ip_bgp_cmd); install_element(VIEW_NODE, &show_ip_bgp_afi_safi_statistics_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_statistics_cmd); install_element(VIEW_NODE, &show_ip_bgp_json_cmd); install_element(VIEW_NODE, &show_ip_bgp_route_cmd); install_element(VIEW_NODE, &show_ip_bgp_regexp_cmd); -- 2.39.2