summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2015-01-22 19:12:35 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2015-01-30 01:12:45 +0100
commitca2b105f3bdd8859117756dc8d8c2406e28af28b (patch)
treeb1b7b1030a224413bf632baffe3058f16fd67e8d
parent240c56f3a41cb7018460ba6e36c9b559c897e3d0 (diff)
downloadquagga-ca2b105f3bdd8859117756dc8d8c2406e28af28b.tar.bz2
quagga-ca2b105f3bdd8859117756dc8d8c2406e28af28b.tar.xz
zebra: add "show ip rpf" to get result of RPF lookup
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.marques@gmail.com> Cc: Balaji G <balajig81@gmail.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
-rw-r--r--zebra/zebra_vty.c52
1 files changed, 47 insertions, 5 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index f00e35ef..29c01c3c 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);