From 622da92f356a5cda26d994ba260b107da5abd921 Mon Sep 17 00:00:00 2001 From: Abhishek N R Date: Thu, 9 Jun 2022 02:57:49 -0700 Subject: [PATCH] pim6d: Moving reusable code to common api for "show pim upstream join desired" command Signed-off-by: Abhishek N R --- pimd/pim6_cmd.c | 20 +------------------- pimd/pim_cmd.c | 20 +------------------- pimd/pim_cmd_common.c | 23 +++++++++++++++++++++++ pimd/pim_cmd_common.h | 2 ++ 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/pimd/pim6_cmd.c b/pimd/pim6_cmd.c index 446395272e..998e0d1d74 100644 --- a/pimd/pim6_cmd.c +++ b/pimd/pim6_cmd.c @@ -900,25 +900,7 @@ DEFPY (show_ipv6_pim_upstream_join_desired, "PIM upstream join-desired\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; - } - - pim_show_join_desired(pim, vty, uj); - - return CMD_SUCCESS; + return pim_show_upstream_join_desired_helper(vrf, vty, !!json); } DEFPY (show_ipv6_pim_upstream_rpf, diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index ac16fd1b7f..54e1aae4d1 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -3118,25 +3118,7 @@ DEFPY (show_ip_pim_upstream_join_desired, "PIM upstream join-desired\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; - } - - pim_show_join_desired(pim, vty, uj); - - return CMD_SUCCESS; + return pim_show_upstream_join_desired_helper(vrf, vty, !!json); } DEFPY (show_ip_pim_upstream_rpf, diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 1159ebd3dd..26a6e8a1c3 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -3980,3 +3980,26 @@ int pim_show_upstream_vrf_all_helper(struct vty *vty, bool json) return CMD_SUCCESS; } + +int pim_show_upstream_join_desired_helper(const char *vrf, struct vty *vty, + 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; + } + + pim_show_join_desired(pim, vty, uj); + + return CMD_SUCCESS; +} diff --git a/pimd/pim_cmd_common.h b/pimd/pim_cmd_common.h index 013db79599..038f7f4d7f 100644 --- a/pimd/pim_cmd_common.h +++ b/pimd/pim_cmd_common.h @@ -143,6 +143,8 @@ int pim_show_statistics_helper(const char *vrf, struct vty *vty, int pim_show_upstream_helper(const char *vrf, struct vty *vty, pim_addr s_or_g, pim_addr g, bool json); int pim_show_upstream_vrf_all_helper(struct vty *vty, bool json); +int pim_show_upstream_join_desired_helper(const char *vrf, struct vty *vty, + bool uj); /* * Special Macro to allow us to get the correct pim_instance; -- 2.39.5