Checking what route exactly a RPF lookup for a given source uses is
essential for an administrator to debug multicast routing issues.  This
command provides exactly that, using the multicst RPF lookup function
and printing out its result to the CLI.

Cc: Everton Marques <everton.marq...@gmail.com>
Cc: Balaji G <balaji...@gmail.com>
Signed-off-by: David Lamparter <equi...@opensourcerouting.org>
---
 zebra/zebra_vty.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index f00e35e..29c01c3 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -31,6 +31,8 @@
 #include "zebra/zserv.h"
 
 static int do_show_ip_route(struct vty *vty, safi_t safi);
+static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
+                                      int mcast);
 
 /* General function for static route. */
 static int
@@ -255,6 +257,36 @@ DEFUN (show_ip_rpf,
   return do_show_ip_route(vty, SAFI_MULTICAST);
 }
 
+DEFUN (show_ip_rpf_addr,
+       show_ip_rpf_addr_cmd,
+       "show ip rpf A.B.C.D",
+       SHOW_STR
+       IP_STR
+       "Display RPF information for multicast source\n"
+       "IP multicast source address (e.g. 10.0.0.0)\n")
+{
+  struct in_addr addr;
+  struct route_node *rn;
+  struct rib *rib;
+  int ret;
+
+  ret = inet_aton (argv[0], &addr);
+  if (ret == 0)
+    {
+      vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  rib = rib_match_ipv4_multicast (addr, &rn);
+
+  if (rib)
+    vty_show_ip_route_detail (vty, rn, 1);
+  else
+    vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
+
+  return CMD_SUCCESS;
+}
+
 /* Static route configuration.  */
 DEFUN (ip_route, 
        ip_route_cmd,
@@ -655,7 +687,7 @@ DEFUN (no_ip_protocol,
 
 /* New RIB.  Detailed information for IPv4 route. */
 static void
-vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
+vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
 {
   struct rib *rib;
   struct nexthop *nexthop, *tnexthop;
@@ -663,8 +695,16 @@ vty_show_ip_route_detail (struct vty *vty, struct 
route_node *rn)
 
   RNODE_FOREACH_RIB (rn, rib)
     {
-      vty_out (vty, "Routing entry for %s/%d%s", 
-              inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
+      const char *mcast_info;
+      if (mcast)
+        {
+          rib_table_info_t *info = rn->table->info;
+          mcast_info = (info->safi == SAFI_MULTICAST)
+                       ? " using Multicast RIB"
+                       : " using Unicast RIB";
+        }
+      vty_out (vty, "Routing entry for %s/%d%s%s",
+              inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, mcast_info,
               VTY_NEWLINE);
       vty_out (vty, "  Known via \"%s\"", zebra_route_string (rib->type));
       vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
@@ -1092,7 +1132,7 @@ DEFUN (show_ip_route_addr,
       return CMD_WARNING;
     }
 
-  vty_show_ip_route_detail (vty, rn);
+  vty_show_ip_route_detail (vty, rn, 0);
 
   route_unlock_node (rn);
 
@@ -1132,7 +1172,7 @@ DEFUN (show_ip_route_prefix,
       return CMD_WARNING;
     }
 
-  vty_show_ip_route_detail (vty, rn);
+  vty_show_ip_route_detail (vty, rn, 0);
 
   route_unlock_node (rn);
 
@@ -2381,6 +2421,8 @@ zebra_vty_init (void)
 
   install_element (VIEW_NODE, &show_ip_rpf_cmd);
   install_element (ENABLE_NODE, &show_ip_rpf_cmd);
+  install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
+  install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd);
 
 #ifdef HAVE_IPV6
   install_element (CONFIG_NODE, &ipv6_route_cmd);
-- 
2.0.4


_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to