From: Abhishek N R Date: Wed, 9 Feb 2022 07:19:25 +0000 (-0800) Subject: pim6d: Implementing "show ipv6 pim statistics" CLI X-Git-Tag: pim6-testing-20220430~123^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=4f58b6aaa431128d53bf1adade64f4d34a8a7146;p=mirror%2Ffrr.git pim6d: Implementing "show ipv6 pim statistics" CLI Adding new show CLI to display pim statistics. Signed-off-by: Abhishek N R --- diff --git a/pimd/pim6_cmd.c b/pimd/pim6_cmd.c index 92ad73da25..91fdfb2650 100644 --- a/pimd/pim6_cmd.c +++ b/pimd/pim6_cmd.c @@ -811,6 +811,42 @@ DEFPY (show_ipv6_pim_secondary, return CMD_SUCCESS; } +DEFPY (show_ipv6_pim_statistics, + show_ipv6_pim_statistics_cmd, + "show ipv6 pim [vrf NAME] statistics [interface WORD$word] [json$json]", + SHOW_STR + IPV6_STR + PIM_STR + VRF_CMD_HELP_STR + "PIM statistics\n" + INTERFACE_STR + "PIM interface\n" + JSON_STR) +{ + struct pim_instance *pim; + struct vrf *v; + bool uj = !!json; + + v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); + + if (!v) + return CMD_WARNING; + + pim = pim_get_pim_instance(v->vrf_id); + + if (!pim) { + vty_out(vty, "%% Unable to find pim instance\n"); + return CMD_WARNING; + } + + if (word) + pim_show_statistics(pim, vty, word, uj); + else + pim_show_statistics(pim, vty, NULL, uj); + + return CMD_SUCCESS; +} + void pim_cmd_init(void) { if_cmd_init(pim_interface_config_write); @@ -868,4 +904,5 @@ void pim_cmd_init(void) install_element(VIEW_NODE, &show_ipv6_pim_rpf_cmd); install_element(VIEW_NODE, &show_ipv6_pim_rpf_vrf_all_cmd); install_element(VIEW_NODE, &show_ipv6_pim_secondary_cmd); + install_element(VIEW_NODE, &show_ipv6_pim_statistics_cmd); } diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 1a44646071..bbee3c943d 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -4885,9 +4885,9 @@ DEFUN (show_ip_pim_bsrp, return CMD_SUCCESS; } -DEFUN (show_ip_pim_statistics, +DEFPY (show_ip_pim_statistics, show_ip_pim_statistics_cmd, - "show ip pim [vrf NAME] statistics [interface WORD] [json]", + "show ip pim [vrf NAME] statistics [interface WORD$word] [json$json]", SHOW_STR IP_STR PIM_STR @@ -4897,17 +4897,26 @@ DEFUN (show_ip_pim_statistics, "PIM interface\n" JSON_STR) { - int idx = 2; - struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - bool uj = use_json(argc, argv); + struct pim_instance *pim; + struct vrf *v; + bool uj = !!json; - if (!vrf) + v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); + + if (!v) return CMD_WARNING; - if (argv_find(argv, argc, "WORD", &idx)) - pim_show_statistics(vrf->info, vty, argv[idx]->arg, uj); + pim = pim_get_pim_instance(v->vrf_id); + + if (!pim) { + vty_out(vty, "%% Unable to find pim instance\n"); + return CMD_WARNING; + } + + if (word) + pim_show_statistics(pim, vty, word, uj); else - pim_show_statistics(vrf->info, vty, NULL, uj); + pim_show_statistics(pim, vty, NULL, uj); return CMD_SUCCESS; }