summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_vty.c')
-rw-r--r--zebra/zebra_vty.c140
1 files changed, 64 insertions, 76 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 1573646ad..1ce4f66b1 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -408,39 +408,34 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
vty_out(vty, ", best");
vty_out(vty, "\n");
- if (re->type == ZEBRA_ROUTE_RIP || re->type == ZEBRA_ROUTE_OSPF
- || re->type == ZEBRA_ROUTE_ISIS
- || re->type == ZEBRA_ROUTE_NHRP
- || re->type == ZEBRA_ROUTE_TABLE
- || re->type == ZEBRA_ROUTE_BGP) {
- time_t uptime;
- struct tm *tm;
-
- uptime = time(NULL);
- uptime -= re->uptime;
- tm = gmtime(&uptime);
-
- vty_out(vty, " Last update ");
-
- if (uptime < ONE_DAY_SECOND)
- vty_out(vty, "%02d:%02d:%02d", tm->tm_hour,
- tm->tm_min, tm->tm_sec);
- else if (uptime < ONE_WEEK_SECOND)
- vty_out(vty, "%dd%02dh%02dm", tm->tm_yday,
- tm->tm_hour, tm->tm_min);
- else
- vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7,
- tm->tm_yday - ((tm->tm_yday / 7) * 7),
- tm->tm_hour);
- vty_out(vty, " ago\n");
- }
+ time_t uptime;
+ struct tm *tm;
+
+ uptime = time(NULL);
+ uptime -= re->uptime;
+ tm = gmtime(&uptime);
+
+ vty_out(vty, " Last update ");
+
+ if (uptime < ONE_DAY_SECOND)
+ vty_out(vty, "%02d:%02d:%02d", tm->tm_hour,
+ tm->tm_min, tm->tm_sec);
+ else if (uptime < ONE_WEEK_SECOND)
+ vty_out(vty, "%dd%02dh%02dm", tm->tm_yday,
+ tm->tm_hour, tm->tm_min);
+ else
+ vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7,
+ tm->tm_yday - ((tm->tm_yday / 7) * 7),
+ tm->tm_hour);
+ vty_out(vty, " ago\n");
for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
char addrstr[32];
vty_out(vty, " %c%s",
CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
- ? '*'
+ ? CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)
+ ? ' ' : '*'
: ' ',
nexthop->rparent ? " " : "");
@@ -489,6 +484,9 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
default:
break;
}
+ if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE))
+ vty_out(vty, " (duplicate nexthop removed)");
+
if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
vty_out(vty, " inactive");
@@ -553,6 +551,12 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
json_object *json_nexthop = NULL;
json_object *json_route = NULL;
json_object *json_labels = NULL;
+ time_t uptime;
+ struct tm *tm;
+
+ uptime = time(NULL);
+ uptime -= re->uptime;
+ tm = gmtime(&uptime);
if (json) {
json_route = json_object_new_object();
@@ -579,35 +583,26 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
json_object_int_add(json_route, "metric", re->metric);
}
- if (re->type == ZEBRA_ROUTE_RIP || re->type == ZEBRA_ROUTE_OSPF
- || re->type == ZEBRA_ROUTE_ISIS
- || re->type == ZEBRA_ROUTE_NHRP
- || re->type == ZEBRA_ROUTE_TABLE
- || re->type == ZEBRA_ROUTE_BGP) {
- time_t uptime;
- struct tm *tm;
-
- uptime = time(NULL);
- uptime -= re->uptime;
- tm = gmtime(&uptime);
-
- if (uptime < ONE_DAY_SECOND)
- sprintf(buf, "%02d:%02d:%02d", tm->tm_hour,
- tm->tm_min, tm->tm_sec);
- else if (uptime < ONE_WEEK_SECOND)
- sprintf(buf, "%dd%02dh%02dm", tm->tm_yday,
- tm->tm_hour, tm->tm_min);
- else
- sprintf(buf, "%02dw%dd%02dh", tm->tm_yday / 7,
- tm->tm_yday - ((tm->tm_yday / 7) * 7),
- tm->tm_hour);
+ if (uptime < ONE_DAY_SECOND)
+ sprintf(buf, "%02d:%02d:%02d", tm->tm_hour,
+ tm->tm_min, tm->tm_sec);
+ else if (uptime < ONE_WEEK_SECOND)
+ sprintf(buf, "%dd%02dh%02dm", tm->tm_yday,
+ tm->tm_hour, tm->tm_min);
+ else
+ sprintf(buf, "%02dw%dd%02dh", tm->tm_yday / 7,
+ tm->tm_yday - ((tm->tm_yday / 7) * 7),
+ tm->tm_hour);
- json_object_string_add(json_route, "uptime", buf);
- }
+ json_object_string_add(json_route, "uptime", buf);
for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
json_nexthop = json_object_new_object();
+ if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE))
+ json_object_boolean_true_add(json_nexthop,
+ "duplicate");
+
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB))
json_object_boolean_true_add(json_nexthop,
"fib");
@@ -687,6 +682,10 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
break;
}
+ if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE))
+ json_object_boolean_true_add(json_nexthop,
+ "duplicate");
+
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
json_object_boolean_true_add(json_nexthop,
"active");
@@ -774,12 +773,14 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
if (re->type != ZEBRA_ROUTE_CONNECT)
len += vty_out(vty, " [%d/%d]", re->distance,
re->metric);
- } else
+ } else {
vty_out(vty, " %c%*c",
CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
- ? '*'
+ ? CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)
+ ? ' ' : '*'
: ' ',
len - 3 + (2 * nexthop_level(nexthop)), ' ');
+ }
switch (nexthop->type) {
case NEXTHOP_TYPE_IPV4:
@@ -862,29 +863,16 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
sizeof buf, 1));
}
- if (re->type == ZEBRA_ROUTE_RIP || re->type == ZEBRA_ROUTE_OSPF
- || re->type == ZEBRA_ROUTE_ISIS
- || re->type == ZEBRA_ROUTE_NHRP
- || re->type == ZEBRA_ROUTE_TABLE
- || re->type == ZEBRA_ROUTE_BGP) {
- time_t uptime;
- struct tm *tm;
-
- uptime = time(NULL);
- uptime -= re->uptime;
- tm = gmtime(&uptime);
-
- if (uptime < ONE_DAY_SECOND)
- vty_out(vty, ", %02d:%02d:%02d", tm->tm_hour,
- tm->tm_min, tm->tm_sec);
- else if (uptime < ONE_WEEK_SECOND)
- vty_out(vty, ", %dd%02dh%02dm", tm->tm_yday,
- tm->tm_hour, tm->tm_min);
- else
- vty_out(vty, ", %02dw%dd%02dh", tm->tm_yday / 7,
- tm->tm_yday - ((tm->tm_yday / 7) * 7),
- tm->tm_hour);
- }
+ if (uptime < ONE_DAY_SECOND)
+ vty_out(vty, ", %02d:%02d:%02d", tm->tm_hour,
+ tm->tm_min, tm->tm_sec);
+ else if (uptime < ONE_WEEK_SECOND)
+ vty_out(vty, ", %dd%02dh%02dm", tm->tm_yday,
+ tm->tm_hour, tm->tm_min);
+ else
+ vty_out(vty, ", %02dw%dd%02dh", tm->tm_yday / 7,
+ tm->tm_yday - ((tm->tm_yday / 7) * 7),
+ tm->tm_hour);
vty_out(vty, "\n");
}
}