From 3a3be633cc77996a055d73fee55bab47e8838963 Mon Sep 17 00:00:00 2001 From: Ameya Dharkar Date: Thu, 9 May 2019 13:36:59 -0700 Subject: [PATCH] Zebra: Add "show ip/ipv6 fib [json]" CLI - review comments 1 According to the review comments, added "Network not in FIB" message when we do not have a FIB route present for given prefix. Signed-off-by: Ameya Dharkar --- zebra/zebra_vty.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 727fff93c6..71cf8d79f8 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1227,6 +1227,8 @@ DEFPY (show_route_detail, struct route_table *table; struct prefix p; struct route_node *rn; + bool use_fib = !!fib; + rib_dest_t *dest; if (address_str) prefix_str = address_str; @@ -1253,9 +1255,10 @@ DEFPY (show_route_detail, } if (json) - vty_show_ip_route_detail_json(vty, rn, !!fib); + vty_show_ip_route_detail_json(vty, rn, + use_fib); else - vty_show_ip_route_detail(vty, rn, 0, !!fib); + vty_show_ip_route_detail(vty, rn, 0, use_fib); route_unlock_node(rn); } @@ -1271,19 +1274,29 @@ DEFPY (show_route_detail, rn = route_node_match(table, &p); if (!rn) { - vty_out(vty, "%% Network not in table\n"); + if (use_fib) + vty_out(vty, "%% Network not in FIB\n"); + else + vty_out(vty, "%% Network not in table\n"); return CMD_WARNING; } if (!address_str && rn->p.prefixlen != p.prefixlen) { - vty_out(vty, "%% Network not in table\n"); + if (use_fib) + vty_out(vty, "%% Network not in FIB\n"); + else + vty_out(vty, "%% Network not in table\n"); route_unlock_node(rn); return CMD_WARNING; } + dest = rib_dest_from_rnode(rn); + if (use_fib && !dest->selected_fib) + vty_out(vty, "%% Network not in FIB\n"); + if (json) - vty_show_ip_route_detail_json(vty, rn, !!fib); + vty_show_ip_route_detail_json(vty, rn, use_fib); else - vty_show_ip_route_detail(vty, rn, 0, !!fib); + vty_show_ip_route_detail(vty, rn, 0, use_fib); route_unlock_node(rn); } -- 2.39.5