]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pim6d: Adding "show ipv6 pim channel" command
authorSai Gomathi N <nsaigomathi@vmware.com>
Fri, 25 Feb 2022 09:47:35 +0000 (01:47 -0800)
committerSai Gomathi N <nsaigomathi@vmware.com>
Mon, 4 Apr 2022 07:52:02 +0000 (00:52 -0700)
Adding new CLI to display pim channel informations.
Changing DEFUN to DEPFY for ""show ip pim channel"

Signed-off-by: Sai Gomathi N <nsaigomathi@vmware.com>
pimd/pim6_cmd.c
pimd/pim_cmd.c
pimd/pim_cmd_common.c

index a6f8a3e52ab9f0ecf8d03b9ff5d540f13cc0769e..d91c76984525a4d2f4f6e4a2ce345b1e7daec9ec 100644 (file)
@@ -1068,6 +1068,29 @@ DEFPY (show_ipv6_pim_state_vrf_all,
        return CMD_SUCCESS;
 }
 
+DEFPY (show_ipv6_pim_channel,
+       show_ipv6_pim_channel_cmd,
+       "show ipv6 pim [vrf NAME] channel [json$json]",
+       SHOW_STR
+       IPV6_STR
+       PIM_STR
+       VRF_CMD_HELP_STR
+       "PIM downstream channel info\n"
+       JSON_STR)
+{
+       struct vrf *v;
+       bool uj = !!json;
+
+       v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+       if (!v)
+               return CMD_WARNING;
+
+       pim_show_channel(v->info, vty, uj);
+
+       return CMD_SUCCESS;
+}
+
 void pim_cmd_init(void)
 {
        if_cmd_init(pim_interface_config_write);
@@ -1132,4 +1155,5 @@ void pim_cmd_init(void)
        install_element(VIEW_NODE, &show_ipv6_pim_upstream_rpf_cmd);
        install_element(VIEW_NODE, &show_ipv6_pim_state_cmd);
        install_element(VIEW_NODE, &show_ipv6_pim_state_vrf_all_cmd);
+       install_element(VIEW_NODE, &show_ipv6_pim_channel_cmd);
 }
index 67e32c8e4a212d6e30ecadf1b6453efa2dd55841..28cccdd20481e62d66144f1f9a1b7a5b5305ea88 100644 (file)
@@ -3228,9 +3228,9 @@ DEFPY (show_ip_pim_upstream_vrf_all,
        return CMD_SUCCESS;
 }
 
-DEFUN (show_ip_pim_channel,
+DEFPY (show_ip_pim_channel,
        show_ip_pim_channel_cmd,
-       "show ip pim [vrf NAME] channel [json]",
+       "show ip pim [vrf NAME] channel [json$json]",
        SHOW_STR
        IP_STR
        PIM_STR
@@ -3238,14 +3238,15 @@ DEFUN (show_ip_pim_channel,
        "PIM downstream channel info\n"
        JSON_STR)
 {
-       int idx = 2;
-       struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
-       bool uj = use_json(argc, argv);
+       struct vrf *v;
+       bool uj = !!json;
 
-       if (!vrf)
+       v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+       if (!v)
                return CMD_WARNING;
 
-       pim_show_channel(vrf->info, vty, uj);
+       pim_show_channel(v->info, vty, uj);
 
        return CMD_SUCCESS;
 }
index baea9da4e0970b973baf721866ddcba6c4fc7965..01cd5a1c169e21eb0216e048660b89d4c07a2e96 100644 (file)
@@ -1867,14 +1867,12 @@ static void pim_show_channel_helper(struct pim_instance *pim, struct vty *vty,
 {
        struct pim_upstream *up = ch->upstream;
        json_object *json_group = NULL;
-       char src_str[INET_ADDRSTRLEN];
-       char grp_str[INET_ADDRSTRLEN];
        json_object *json_row = NULL;
 
-       pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str));
-       pim_inet4_dump("<grp?>", up->sg.grp, grp_str, sizeof(grp_str));
-
        if (uj) {
+               char grp_str[PIM_ADDRSTRLEN];
+
+               snprintfrr(grp_str, sizeof(grp_str), "%pPAs", &up->sg.grp);
                json_object_object_get_ex(json, grp_str, &json_group);
 
                if (!json_group) {
@@ -1886,8 +1884,10 @@ static void pim_show_channel_helper(struct pim_instance *pim, struct vty *vty,
                json_object_pim_upstream_add(json_row, up);
                json_object_string_add(json_row, "interface",
                                       ch->interface->name);
-               json_object_string_add(json_row, "source", src_str);
-               json_object_string_add(json_row, "group", grp_str);
+               json_object_string_addf(json_row, "source", "%pPAs",
+                                       &up->sg.src);
+               json_object_string_addf(json_row, "group", "%pPAs",
+                                       &up->sg.grp);
 
                if (pim_macro_ch_lost_assert(ch))
                        json_object_boolean_true_add(json_row, "lostAssert");
@@ -1902,11 +1902,13 @@ static void pim_show_channel_helper(struct pim_instance *pim, struct vty *vty,
                        json_object_boolean_true_add(json_row,
                                                     "evaluateJoinDesired");
 
-               json_object_object_add(json_group, src_str, json_row);
+               json_object_object_addf(json_group, json_row, "%pPAs",
+                                       &up->sg.src);
 
        } else {
-               vty_out(vty, "%-16s %-15s %-15s %-10s %-5s %-10s %-11s %-6s\n",
-                       ch->interface->name, src_str, grp_str,
+               vty_out(vty,
+                       "%-16s %-15pPAs %-15pPAs %-10s %-5s %-10s %-11s %-6s\n",
+                       ch->interface->name, &up->sg.src, &up->sg.grp,
                        pim_macro_ch_lost_assert(ch) ? "yes" : "no",
                        pim_macro_chisin_joins(ch) ? "yes" : "no",
                        pim_macro_chisin_pim_include(ch) ? "yes" : "no",