]> git.puffer.fish Git - mirror/frr.git/commitdiff
pim6d: Moving reusable code to common api for "show pim upstream rpf" command
authorAbhishek N R <abnr@vmware.com>
Thu, 9 Jun 2022 10:10:21 +0000 (03:10 -0700)
committerAbhishek N R <abnr@vmware.com>
Thu, 9 Jun 2022 10:10:21 +0000 (03:10 -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 998e0d1d7451f2be0efd38c640cbf44da4432999..7f057dd509d01115e64ec176c1c21f0df49b3da6 100644 (file)
@@ -913,25 +913,7 @@ DEFPY (show_ipv6_pim_upstream_rpf,
        "PIM upstream source rpf\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_upstream_rpf(pim, vty, uj);
-
-       return CMD_SUCCESS;
+       return pim_show_upstream_rpf_helper(vrf, vty, !!json);
 }
 
 DEFPY (show_ipv6_pim_state,
index 54e1aae4d11160ff1df99eaa48ae07f0b38f82e6..225d79c2e1ea0996d4d092592ba0e26b2ab497aa 100644 (file)
@@ -3131,25 +3131,7 @@ DEFPY (show_ip_pim_upstream_rpf,
        "PIM upstream source rpf\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_upstream_rpf(pim, vty, uj);
-
-       return CMD_SUCCESS;
+       return pim_show_upstream_rpf_helper(vrf, vty, !!json);
 }
 
 DEFPY (show_ip_pim_rp,
index 26a6e8a1c3aaa2b53035b3a3c199320bbc47f783..4c0a126225962293133c3618f4077d907a55cfcd 100644 (file)
@@ -4003,3 +4003,25 @@ int pim_show_upstream_join_desired_helper(const char *vrf, struct vty *vty,
 
        return CMD_SUCCESS;
 }
+
+int pim_show_upstream_rpf_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_upstream_rpf(pim, vty, uj);
+
+       return CMD_SUCCESS;
+}
index 038f7f4d7ff31303312f6a3b51c0dfe632f2f628..0ce62d82dc703c5f3d854217cd9dc85fa2bc824d 100644 (file)
@@ -145,6 +145,7 @@ int pim_show_upstream_helper(const char *vrf, struct vty *vty, pim_addr s_or_g,
 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);
+int pim_show_upstream_rpf_helper(const char *vrf, struct vty *vty, bool uj);
 
 /*
  * Special Macro to allow us to get the correct pim_instance;