]> git.puffer.fish Git - mirror/frr.git/commitdiff
pim6d: Implementing "show ipv6 pim statistics" CLI
authorAbhishek N R <abnr@vmware.com>
Wed, 9 Feb 2022 07:19:25 +0000 (23:19 -0800)
committerAbhishek N R <abnr@vmware.com>
Tue, 29 Mar 2022 06:53:24 +0000 (23:53 -0700)
Adding new show CLI to display pim statistics.

Signed-off-by: Abhishek N R <abnr@vmware.com>
pimd/pim6_cmd.c
pimd/pim_cmd.c

index 92ad73da259093f3cdf2b1706c984001778a6575..91fdfb265059742b11d64a700afd5d2403b9a8e5 100644 (file)
@@ -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);
 }
index 1a44646071bb512f9dbd68061b324674ef5c76f5..bbee3c943d3dc6ec30c1725d28b288e1e0687b28 100644 (file)
@@ -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;
 }