]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pim6d: Moving reusable code to common api for "show pim statistics" command
authorAbhishek N R <abnr@vmware.com>
Thu, 9 Jun 2022 08:59:58 +0000 (01:59 -0700)
committerAbhishek N R <abnr@vmware.com>
Thu, 9 Jun 2022 08:59:58 +0000 (01:59 -0700)
Signed-off-by: Abhishek N R <abnr@vmware.com>
pimd/pim6_cmd.c
pimd/pim_cmd.c
pimd/pim_cmd_common.c
pimd/pim_cmd_common.h

index 2f073922132d6fb2205998ab174949a3ca2c2d37..74a9fd490ab104d6bf6fc8418de9513c972dcd1b 100644 (file)
@@ -859,28 +859,7 @@ DEFPY (show_ipv6_pim_statistics,
        "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;
+       return pim_show_statistics_helper(vrf, vty, word, !!json);
 }
 
 DEFPY (show_ipv6_pim_upstream,
index f8d0cf7eaf8e23c9dcc87ed9bcf41a7c5afe0061..1bdd68bf4a0fcd7007165bcde68fe2742eeee46a 100644 (file)
@@ -3442,28 +3442,7 @@ DEFPY (show_ip_pim_statistics,
        "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;
+       return pim_show_statistics_helper(vrf, vty, word, !!json);
 }
 
 DEFPY (show_ip_multicast,
index 303c9abe1309af1f8bd12ab6f04e5d729b9d6214..46f48e91a1bc924d86777e66955eb0660418afb6 100644 (file)
@@ -3887,3 +3887,29 @@ int pim_show_secondary_helper(const char *vrf, struct vty *vty)
 
        return CMD_SUCCESS;
 }
+
+int pim_show_statistics_helper(const char *vrf, struct vty *vty,
+                              const char *word, bool uj)
+{
+       struct pim_instance *pim;
+       struct vrf *v;
+
+       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;
+}
index c88dd48fe6b0a4a81809f9ad0a259b452220e923..4d5284b40ba4426a94b69dfca29e5f642519b42f 100644 (file)
@@ -138,6 +138,8 @@ int pim_show_rp_helper(const char *vrf, struct vty *vty, const char *group_str,
 int pim_show_rp_vrf_all_helper(struct vty *vty, const char *group_str,
                               const struct prefix *group, bool json);
 int pim_show_secondary_helper(const char *vrf, struct vty *vty);
+int pim_show_statistics_helper(const char *vrf, struct vty *vty,
+                              const char *word, bool uj);
 
 /*
  * Special Macro to allow us to get the correct pim_instance;