]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Show group-type under `show ip pim rp-info`
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 2 Mar 2022 11:30:51 +0000 (13:30 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Sat, 12 Mar 2022 08:41:07 +0000 (10:41 +0200)
And filter by group for PIM.

```
exit1-debian-11# show ip pim rp-info
RP address       group/prefix-list   OIF               I am RP    Source   Group-Type
192.168.10.17    238.0.0.0/24        eth2              no         Static   ASM
192.168.10.110   232.0.0.0/24        eth2              no         Static   SSM
exit1-debian-11# show ip pim rp-info 238.0.0.0/24
RP address       group/prefix-list   OIF               I am RP    Source   Group-Type
192.168.10.17    238.0.0.0/24        eth2              no         Static   ASM
exit1-debian-11# show ip pim rp-info 238.0.0.0/24 json
{
  "192.168.10.17":[
    {
      "rpAddress":"192.168.10.17",
      "outboundInterface":"eth2",
      "iAmRP":false,
      "group":"238.0.0.0/24",
      "source":"Static",
      "groupType":"ASM"
    }
  ]
}
exit1-debian-11#
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
doc/user/pim.rst
pimd/pim_cmd.c
pimd/pim_rp.c
pimd/pim_rp.h
pimd/pim_ssm.h

index 1c3a0110aca9d28bc04f2046c89b70b15973c9bb..30363dfdf6a901525caabc4ac061f47fa2e0a5af 100644 (file)
@@ -505,10 +505,12 @@ cause great confusion.
    Display information about a S,G pair and how the RPF would be chosen. This
    is especially useful if there are ECMP's available from the RPF lookup.
 
-.. clicmd:: show ip pim rp-info
+.. clicmd:: show ip pim [vrf NAME] rp-info [A.B.C.D/M] [json]
 
    Display information about RP's that are configured on this router.
 
+   You can filter the output by specifying an arbitrary group.
+
 .. clicmd:: show ip pim rpf
 
    Display information about currently being used S,G's and their RPF lookup
index a9b57cabbe75e5e26f28ccb09c4c9341a193ac73..4232a021fb0e69e06f72fbbbdf4b6b34a2f440ff 100644 (file)
@@ -5340,39 +5340,56 @@ DEFUN (show_ip_pim_upstream_rpf,
 
 DEFUN (show_ip_pim_rp,
        show_ip_pim_rp_cmd,
-       "show ip pim [vrf NAME] rp-info [json]",
+       "show ip pim [vrf NAME] rp-info [A.B.C.D/M] [json]",
        SHOW_STR
        IP_STR
        PIM_STR
        VRF_CMD_HELP_STR
        "PIM RP information\n"
+       "Multicast Group range\n"
        JSON_STR)
 {
        int idx = 2;
        struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
        bool uj = use_json(argc, argv);
+       struct prefix *range = NULL;
 
        if (!vrf)
                return CMD_WARNING;
 
-       pim_rp_show_information(vrf->info, vty, uj);
+       if (argv_find(argv, argc, "A.B.C.D/M", &idx)) {
+               range = prefix_new();
+               (void)str2prefix(argv[idx]->arg, range);
+               apply_mask(range);
+       }
+
+       pim_rp_show_information(vrf->info, range, vty, uj);
 
        return CMD_SUCCESS;
 }
 
 DEFUN (show_ip_pim_rp_vrf_all,
        show_ip_pim_rp_vrf_all_cmd,
-       "show ip pim vrf all rp-info [json]",
+       "show ip pim vrf all rp-info [A.B.C.D/M] [json]",
        SHOW_STR
        IP_STR
        PIM_STR
        VRF_CMD_HELP_STR
        "PIM RP information\n"
+       "Multicast Group range\n"
        JSON_STR)
 {
+       int idx = 0;
        bool uj = use_json(argc, argv);
        struct vrf *vrf;
        bool first = true;
+       struct prefix *range = NULL;
+
+       if (argv_find(argv, argc, "A.B.C.D/M", &idx)) {
+               range = prefix_new();
+               (void)str2prefix(argv[idx]->arg, range);
+               apply_mask(range);
+       }
 
        if (uj)
                vty_out(vty, "{ ");
@@ -5384,7 +5401,7 @@ DEFUN (show_ip_pim_rp_vrf_all,
                        first = false;
                } else
                        vty_out(vty, "VRF: %s\n", vrf->name);
-               pim_rp_show_information(vrf->info, vty, uj);
+               pim_rp_show_information(vrf->info, range, vty, uj);
        }
        if (uj)
                vty_out(vty, "}\n");
index 00a1e1b58c01f1e7e17ea0ed8659f21487be5a79..99727cf837453df9c3150facfab24fba0dc6c27f 100644 (file)
@@ -49,6 +49,7 @@
 #include "pim_zebra.h"
 #include "pim_bsm.h"
 #include "pim_util.h"
+#include "pim_ssm.h"
 
 /* Cleanup pim->rpf_hash each node data */
 void pim_rp_list_hash_clean(void *data)
@@ -1145,7 +1146,8 @@ int pim_rp_config_write(struct pim_instance *pim, struct vty *vty,
        return count;
 }
 
-void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
+void pim_rp_show_information(struct pim_instance *pim, struct prefix *range,
+                            struct vty *vty, bool uj)
 {
        struct rp_info *rp_info;
        struct rp_info *prev_rp_info = NULL;
@@ -1160,11 +1162,22 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
                json = json_object_new_object();
        else
                vty_out(vty,
-                       "RP address       group/prefix-list   OIF               I am RP    Source\n");
+                       "RP address       group/prefix-list   OIF               I am RP    Source   Group-Type\n");
        for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
                if (pim_rpf_addr_is_inaddr_any(&rp_info->rp))
                        continue;
 
+#if PIM_IPV == 4
+               pim_addr group = rp_info->group.u.prefix4;
+#else
+               pim_addr group = rp_info->group.u.prefix6;
+#endif
+               const char *group_type =
+                       pim_is_grp_ssm(pim, group) ? "SSM" : "ASM";
+
+               if (range && !prefix_same(&rp_info->group, range))
+                       continue;
+
                if (rp_info->rp_src == RP_SRC_STATIC)
                        strlcpy(source, "Static", sizeof(source));
                else if (rp_info->rp_src == RP_SRC_BSR)
@@ -1214,6 +1227,8 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
                                                        "%pFX",
                                                        &rp_info->group);
                        json_object_string_add(json_row, "source", source);
+                       json_object_string_add(json_row, "groupType",
+                                              group_type);
 
                        json_object_array_add(json_rp_rows, json_row);
                } else {
@@ -1236,7 +1251,8 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
                        else
                                vty_out(vty, "no");
 
-                       vty_out(vty, "%14s\n", source);
+                       vty_out(vty, "%14s", source);
+                       vty_out(vty, "%6s\n", group_type);
                }
                prev_rp_info = rp_info;
        }
index 29834f8e5e5cb83620cb648da8fe2786b0e9f902..04faeb5f26b30a6179ea2394c5e7b7cbafad907d 100644 (file)
@@ -78,8 +78,8 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, pim_addr group);
 #define I_am_RP(P, G)  pim_rp_i_am_rp ((P), (G))
 #define RP(P, G)       pim_rp_g ((P), (G))
 
-void pim_rp_show_information(struct pim_instance *pim, struct vty *vty,
-                            bool uj);
+void pim_rp_show_information(struct pim_instance *pim, struct prefix *range,
+                            struct vty *vty, bool uj);
 void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr);
 int pim_rp_list_cmp(void *v1, void *v2);
 struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,
index 117713b86629252e29f58b52289e1a20cc74d90e..c6b6978218dd554dc1cafd89a3af154b9e2da83f 100644 (file)
@@ -34,7 +34,7 @@ struct pim_ssm {
 
 void pim_ssm_prefix_list_update(struct pim_instance *pim,
                                struct prefix_list *plist);
-int pim_is_grp_ssm(struct pim_instance *pim, pim_addr group_addr);
+extern int pim_is_grp_ssm(struct pim_instance *pim, pim_addr group_addr);
 int pim_ssm_range_set(struct pim_instance *pim, vrf_id_t vrf_id,
                      const char *plist_name);
 void *pim_ssm_init(void);