From: Ameya Dharkar Date: Fri, 10 May 2019 19:05:47 +0000 (-0700) Subject: Zebra: "show ip/ipv6 route/fib prefix" prefix not found cases X-Git-Tag: frr-7.2~370^2 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=ad2e7233a4f0a06eff74216b1de8f9d5a92c1a91;p=mirror_frr.git Zebra: "show ip/ipv6 route/fib prefix" prefix not found cases 1. If prefix not found, print "{}" for json 2. Print "Network not in table" for route option 3. Print "Network not in FIB" for fib option 4. Take care of "show ip route/fib vrf all prefix" command. Signed-off-by: Ameya Dharkar --- diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 71cf8d79f..613668dbd 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1229,6 +1229,7 @@ DEFPY (show_route_detail, struct route_node *rn; bool use_fib = !!fib; rib_dest_t *dest; + bool network_found = false; if (address_str) prefix_str = address_str; @@ -1254,6 +1255,13 @@ DEFPY (show_route_detail, continue; } + dest = rib_dest_from_rnode(rn); + if (use_fib && !dest->selected_fib) { + route_unlock_node(rn); + continue; + } + + network_found = true; if (json) vty_show_ip_route_detail_json(vty, rn, use_fib); @@ -1262,6 +1270,20 @@ DEFPY (show_route_detail, route_unlock_node(rn); } + + if (!network_found) { + if (json) + vty_out(vty, "{}\n"); + else { + if (use_fib) + vty_out(vty, + "%% Network not in FIB\n"); + else + vty_out(vty, + "%% Network not in RIB\n"); + } + return CMD_WARNING; + } } else { vrf_id_t vrf_id = VRF_DEFAULT; @@ -1273,26 +1295,26 @@ DEFPY (show_route_detail, return CMD_SUCCESS; rn = route_node_match(table, &p); - if (!rn) { - 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) { - if (use_fib) - vty_out(vty, "%% Network not in FIB\n"); - else - vty_out(vty, "%% Network not in table\n"); - route_unlock_node(rn); + if (rn) + dest = rib_dest_from_rnode(rn); + + if (!rn || (!address_str && rn->p.prefixlen != p.prefixlen) || + (use_fib && dest && !dest->selected_fib)) { + if (json) + vty_out(vty, "{}\n"); + else { + if (use_fib) + vty_out(vty, + "%% Network not in FIB\n"); + else + vty_out(vty, + "%% Network not in table\n"); + } + if (rn) + 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, use_fib); else