summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pimd/pim6_cmd.c23
-rw-r--r--pimd/pim_cmd.c23
-rw-r--r--pimd/pim_cmd_common.c26
-rw-r--r--pimd/pim_cmd_common.h2
4 files changed, 30 insertions, 44 deletions
diff --git a/pimd/pim6_cmd.c b/pimd/pim6_cmd.c
index 2f07392213..74a9fd490a 100644
--- a/pimd/pim6_cmd.c
+++ b/pimd/pim6_cmd.c
@@ -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,
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index f8d0cf7eaf..1bdd68bf4a 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -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,
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index 303c9abe13..46f48e91a1 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -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;
+}
diff --git a/pimd/pim_cmd_common.h b/pimd/pim_cmd_common.h
index c88dd48fe6..4d5284b40b 100644
--- a/pimd/pim_cmd_common.h
+++ b/pimd/pim_cmd_common.h
@@ -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;