]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib, zebra: Abstract character selection for nexthop display
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 14 Jan 2019 21:32:26 +0000 (16:32 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 26 Jan 2019 01:14:38 +0000 (20:14 -0500)
When we are selecting nexthops for disply, abstract the notion
of what character we display to the end user about the status
of the nexthop.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/route_types.pl
zebra/zebra_vty.c

index 66384fe4492af8e3f59037dbf7c178557308e295..7435272761c631f5ddd69121ee4a0684363f9462 100755 (executable)
@@ -121,7 +121,7 @@ sub codelist {
        }
        $str =~ s/ $//;
        push @lines, $str . "\\n\" \\\n";
-       push @lines, "  \"       > - selected route, * - FIB route\\n\\n\"";
+       push @lines, "  \"       > - selected route, * - FIB route, q - queued route, f - failed route\\n\\n\"";
        return join("", @lines);
 }
 
index 902c726511d96983b6286ee7cc408e3f658e7437..d866c0845253f7e7767e6064ba773e08a8830438 100644 (file)
@@ -161,6 +161,18 @@ DEFUN (show_ip_rpf_addr,
        return CMD_SUCCESS;
 }
 
+static char re_status_output_char(struct route_entry *re, struct nexthop *nhop)
+{
+       if (CHECK_FLAG(nhop->flags, NEXTHOP_FLAG_FIB)) {
+               if (CHECK_FLAG(nhop->flags, NEXTHOP_FLAG_DUPLICATE))
+                       return ' ';
+               else
+                       return '*';
+       }
+
+       return ' ';
+}
+
 /* New RIB.  Detailed information for IPv4 route. */
 static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
                                     int mcast)
@@ -229,12 +241,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
                        char addrstr[32];
 
                        vty_out(vty, "  %c%s",
-                               CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
-                                       ? CHECK_FLAG(nexthop->flags,
-                                                    NEXTHOP_FLAG_DUPLICATE)
-                                                 ? ' '
-                                                 : '*'
-                                       : ' ',
+                               re_status_output_char(re, nexthop),
                                nexthop->rparent ? "  " : "");
 
                        switch (nexthop->type) {
@@ -594,9 +601,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
                                CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)
                                        ? '>'
                                        : ' ',
-                               CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
-                                       ? '*'
-                                       : ' ',
+                               re_status_output_char(re, nexthop),
                                srcdest_rnode2str(rn, buf, sizeof buf));
 
                        /* Distance and metric display. */
@@ -607,12 +612,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
                                               re->metric);
                } else {
                        vty_out(vty, "  %c%*c",
-                               CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
-                                       ? CHECK_FLAG(nexthop->flags,
-                                                    NEXTHOP_FLAG_DUPLICATE)
-                                                 ? ' '
-                                                 : '*'
-                                       : ' ',
+                               re_status_output_char(re, nexthop),
                                len - 3 + (2 * nexthop_level(nexthop)), ' ');
                }