From 468b6f4400b1f374af354fac708ba2125c8872ee Mon Sep 17 00:00:00 2001 From: Sarita Patra Date: Thu, 16 May 2019 09:58:28 -0700 Subject: [PATCH] pimd: new cli command show ip mroute summary Introduced a new command "show ip mroute summary" to display total number of (*, G) and (S, G) mroutes created and number of mroutes installed in the kernel. Signed-off-by: Sarita Patra --- doc/user/pim.rst | 6 ++++ pimd/pim_cmd.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) diff --git a/doc/user/pim.rst b/doc/user/pim.rst index 414423ae7c..d05127059b 100644 --- a/doc/user/pim.rst +++ b/doc/user/pim.rst @@ -322,6 +322,12 @@ cause great confusion. Display information about installed into the kernel S,G mroutes and in addition display data about packet flow for the mroutes. +.. index:: show ip mroute summary +.. clicmd:: show ip mroute summary + + Display total number of S,G mroutes and number of S,G mroutes installed + into the kernel. + .. index:: show ip pim assert .. clicmd:: show ip pim assert diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index a2357067f9..fe910591a6 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -5705,6 +5705,97 @@ DEFUN (show_ip_mroute_count_vrf_all, return CMD_SUCCESS; } +static void show_mroute_summary(struct pim_instance *pim, struct vty *vty) +{ + struct listnode *node; + struct channel_oil *c_oil; + struct static_route *s_route; + uint32_t starg_sw_mroute_cnt = 0; + uint32_t sg_sw_mroute_cnt = 0; + uint32_t starg_hw_mroute_cnt = 0; + uint32_t sg_hw_mroute_cnt = 0; + + vty_out(vty, "Mroute Type Installed/Total\n"); + + for (ALL_LIST_ELEMENTS_RO(pim->channel_oil_list, node, c_oil)) { + if (!c_oil->installed) { + if (c_oil->oil.mfcc_origin.s_addr == INADDR_ANY) + starg_sw_mroute_cnt++; + else + sg_sw_mroute_cnt++; + } else { + if (c_oil->oil.mfcc_origin.s_addr == INADDR_ANY) + starg_hw_mroute_cnt++; + else + sg_hw_mroute_cnt++; + } + } + + for (ALL_LIST_ELEMENTS_RO(pim->static_routes, node, s_route)) { + if (!s_route->c_oil.installed) { + if (s_route->c_oil.oil.mfcc_origin.s_addr == INADDR_ANY) + starg_sw_mroute_cnt++; + else + sg_sw_mroute_cnt++; + } else { + if (s_route->c_oil.oil.mfcc_origin.s_addr == INADDR_ANY) + starg_hw_mroute_cnt++; + else + sg_hw_mroute_cnt++; + } + } + + vty_out(vty, "%-20s %d/%d\n", "(*, G)", starg_hw_mroute_cnt, + starg_sw_mroute_cnt + starg_hw_mroute_cnt); + vty_out(vty, "%-20s %d/%d\n", "(S, G)", sg_hw_mroute_cnt, + sg_sw_mroute_cnt + sg_hw_mroute_cnt); + vty_out(vty, "------\n"); + vty_out(vty, "%-20s %d/%d\n", "Total", + (starg_hw_mroute_cnt + sg_hw_mroute_cnt), + (starg_sw_mroute_cnt + + starg_hw_mroute_cnt + + sg_sw_mroute_cnt + + sg_hw_mroute_cnt)); +} + +DEFUN (show_ip_mroute_summary, + show_ip_mroute_summary_cmd, + "show ip mroute [vrf NAME] summary", + SHOW_STR + IP_STR + MROUTE_STR + VRF_CMD_HELP_STR + "Summary of all mroutes\n") +{ + int idx = 2; + struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); + + if (!vrf) + return CMD_WARNING; + + show_mroute_summary(vrf->info, vty); + return CMD_SUCCESS; +} + +DEFUN (show_ip_mroute_summary_vrf_all, + show_ip_mroute_summary_vrf_all_cmd, + "show ip mroute vrf all summary", + SHOW_STR + IP_STR + MROUTE_STR + VRF_CMD_HELP_STR + "Summary of all mroutes\n") +{ + struct vrf *vrf; + + RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { + vty_out(vty, "VRF: %s\n", vrf->name); + show_mroute_summary(vrf->info, vty); + } + + return CMD_SUCCESS; +} + DEFUN (show_ip_rib, show_ip_rib_cmd, "show ip rib [vrf NAME] A.B.C.D", @@ -10085,6 +10176,8 @@ void pim_cmd_init(void) install_element(VIEW_NODE, &show_ip_mroute_vrf_all_cmd); install_element(VIEW_NODE, &show_ip_mroute_count_cmd); install_element(VIEW_NODE, &show_ip_mroute_count_vrf_all_cmd); + install_element(VIEW_NODE, &show_ip_mroute_summary_cmd); + install_element(VIEW_NODE, &show_ip_mroute_summary_vrf_all_cmd); install_element(VIEW_NODE, &show_ip_rib_cmd); install_element(VIEW_NODE, &show_ip_ssmpingd_cmd); install_element(VIEW_NODE, &show_debugging_pim_cmd); -- 2.39.5