]> git.proxmox.com Git - mirror_frr.git/commitdiff
Zebra: "show ip/ipv6 route/fib prefix" prefix not found cases
authorAmeya Dharkar <adharkar@vmware.com>
Fri, 10 May 2019 19:05:47 +0000 (12:05 -0700)
committerAmeya Dharkar <adharkar@vmware.com>
Fri, 10 May 2019 19:12:44 +0000 (12:12 -0700)
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 <adharkar@vmware.com>
zebra/zebra_vty.c

index 71cf8d79f8f0afd49bc1c574a86d4ade71eb2b17..613668dbd3467ed354960ba6ab23ff6c23ce0b4f 100644 (file)
@@ -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