]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Add "show ip pim rp-info" command
authorDonald Sharp <sharpd@cumulusnetwroks.com>
Tue, 23 Aug 2016 20:22:14 +0000 (16:22 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:07 +0000 (20:26 -0500)
List the RP information we have configured.

Fix bug where we were not properly initializing some code

Ticket: CM-12617
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_cmd.c
pimd/pim_rp.c
pimd/pim_rp.h
pimd/pim_zebra.c

index bd3a85abb04ef498c2a4b24d64ea9d3e4b93626f..bbc1de344328e08012816bcf48e74cd270bc3b72 100644 (file)
@@ -2004,6 +2004,19 @@ DEFUN (show_ip_pim_upstream_rpf,
   return CMD_SUCCESS;
 }
 
+DEFUN (show_ip_pim_rp,
+       show_ip_pim_rp_cmd,
+       "show ip pim rp-info ",
+       SHOW_STR
+       IP_STR
+       PIM_STR
+       "PIM RP information\n")
+{
+  pim_rp_show_information (vty);
+
+  return CMD_SUCCESS;
+}
+
 DEFUN (show_ip_pim_rpf,
        show_ip_pim_rpf_cmd,
        "show ip pim rpf",
@@ -4863,6 +4876,7 @@ void pim_cmd_init()
   install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
   install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
   install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_rp_cmd);
   install_element (VIEW_NODE, &show_ip_multicast_cmd);
   install_element (VIEW_NODE, &show_ip_mroute_cmd);
   install_element (VIEW_NODE, &show_ip_mroute_count_cmd);
index 84de87076446f81eea5920c2a0cd80cfd372ff1c..7a356a7689457bcfc1b28d98fe71b0cb8df73796 100644 (file)
@@ -26,6 +26,8 @@
 #include "linklist.h"
 #include "prefix.h"
 #include "memory.h"
+#include "vty.h"
+#include "vrf.h"
 
 #include "pimd.h"
 #include "pim_vty.h"
@@ -35,6 +37,7 @@
 #include "pim_rpf.h"
 #include "pim_sock.h"
 #include "pim_memory.h"
+#include "pim_iface.h"
 
 struct rp_info
 {
@@ -148,6 +151,24 @@ pim_rp_find_match_group (struct prefix *group)
   return NULL;
 }
 
+static void
+pim_rp_check_interfaces (struct rp_info *rp_info)
+{
+  struct listnode *node;
+  struct interface *ifp;
+
+  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
+    {
+      struct pim_interface *pim_ifp = ifp->info;
+
+      if (!pim_ifp)
+        continue;
+
+      if (pim_ifp->primary_address.s_addr == rp_info->rp.rpf_addr.s_addr)
+       rp_info->i_am_rp = 1;
+    }
+}
+
 int
 pim_rp_new (const char *rp, const char *group_range)
 {
@@ -185,6 +206,7 @@ pim_rp_new (const char *rp, const char *group_range)
       XFREE (MTYPE_PIM_RP, rp_info);
       if (!pim_rp_setup ())
         return -2;
+      pim_rp_check_interfaces (rp_all);
       return 0;
     }
 
@@ -210,6 +232,7 @@ pim_rp_new (const char *rp, const char *group_range)
   if (!pim_rp_setup ())
     return -2;
 
+  pim_rp_check_interfaces (rp_info);
   return 0;
 }
 
@@ -453,3 +476,22 @@ pim_rp_check_is_my_ip_address (struct in_addr group, struct in_addr dest_addr)
     
   return 0;
 }
+
+void
+pim_rp_show_information (struct vty *vty)
+{
+  struct rp_info *rp_info;
+  struct listnode *node;
+
+  vty_out (vty, "RP Addr           Group   Oif    I_am_RP%s", VTY_NEWLINE);
+  for (ALL_LIST_ELEMENTS_RO (qpim_rp_list, node, rp_info))
+    {
+      char buf[48];
+      vty_out (vty, "%-10s  %-10s  %-10s%-10d%s",
+      inet_ntoa (rp_info->rp.rpf_addr),
+              prefix2str(&rp_info->group, buf, 48),
+              rp_info->rp.source_nexthop.interface->name,
+              rp_info->i_am_rp, VTY_NEWLINE);
+    }
+  return;
+}
index be50bbb18b5955c4f29a62e1fb807d5a55ac519e..c9dfa201f19ad2307364276ad1a22cc4f975803d 100644 (file)
@@ -42,4 +42,6 @@ struct pim_rpf *pim_rp_g (struct in_addr group);
 
 #define I_am_RP(G)  pim_rp_i_am_rp ((G))
 #define RP(G)       pim_rp_g ((G))
+
+void pim_rp_show_information (struct vty *vty);
 #endif
index b171fbb7021738562ed577ed7d7cd43d56672581..aa1121c8a228e2a34fb9c76e11de210a12341b90 100644 (file)
@@ -506,6 +506,7 @@ static int on_rpf_cache_refresh(struct thread *t)
   qpim_rpf_cache_refresh_last = pim_time_monotonic_sec();
   ++qpim_rpf_cache_refresh_events;
 
+  pim_rp_setup ();
   return 0;
 }
 
@@ -659,6 +660,7 @@ static int redist_read_ipv4_route(int command, struct zclient *zclient,
 
   sched_rpf_cache_refresh();
 
+  pim_rp_setup ();
   return 0;
 }