diff --git a/doc/user/ospfd.rst b/doc/user/ospfd.rst index 9491c5e42f..4e30ef2aec 100644 --- a/doc/user/ospfd.rst +++ b/doc/user/ospfd.rst @@ -887,8 +887,8 @@ Showing Information .. clicmd:: show ip ospf route [detail] [json] Show the OSPF routing table, as determined by the most recent SPF - calculation. If detail is specified, each routing item's - advertiser will be show up. + calculation. When detail option is used, it shows more information + to the CLI like advertising router ID for each route, etc. .. clicmd:: show ip ospf [vrf ] border-routers [json] diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c index e32e06e7a4..3ffa7c0bb1 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -48,6 +48,7 @@ struct ospf_route *ospf_route_new(void) new->paths = list_new(); new->paths->del = (void (*)(void *))ospf_path_free; + new->u.std.transit = false; return new; } @@ -500,6 +501,7 @@ void ospf_intra_add_transit(struct route_table *rt, struct vertex *v, or->cost = v->distance; or->type = OSPF_DESTINATION_NETWORK; or->u.std.origin = (struct lsa_header *)lsa; + or->u.std.transit = true; ospf_route_copy_nexthops_from_vertex(area, or, v); diff --git a/ospfd/ospf_route.h b/ospfd/ospf_route.h index 7639a0049e..44e80216d7 100644 --- a/ospfd/ospf_route.h +++ b/ospfd/ospf_route.h @@ -69,6 +69,8 @@ struct route_standard { /* */ uint8_t flags; /* From router-LSA */ + + bool transit; /* Transit network or not */ }; struct route_external { diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 0438bbcdf8..a23802719b 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -10792,15 +10792,17 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, if (json) { json_object_string_add(json_route, "routeType", "N"); + json_object_boolean_add(json_route, "transit", + or->u.std.transit); json_object_int_add(json_route, "cost", or->cost); json_object_string_addf(json_route, "area", "%pI4", &or->u.std.area_id); } else { - vty_out(vty, "N %-18s [%d] area: %pI4\n", - buf1, or->cost, - &or->u.std.area_id); + vty_out(vty, "N %s %-18s [%d] area: %pI4\n", + or->u.std.transit && detail ? "T" : " ", + buf1, or->cost, &or->u.std.area_id); } break; default: @@ -10859,7 +10861,8 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, ospf->vrf_id)); json_object_string_addf( json_nexthop, - "adv", "%pI4", + "advertisedRouter", + "%pI4", &path->adv_router); } else { vty_out(vty, @@ -11134,7 +11137,8 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, path->ifindex, ospf->vrf_id)); json_object_string_addf( - json_nexthop, "adv", + json_nexthop, + "advertisedRouter", "%pI4", &path->adv_router); } else { @@ -11464,6 +11468,12 @@ static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf, return CMD_SUCCESS; } + if (detail && json == NULL) { + vty_out(vty, "Codes: N - network T - transitive\n"); + vty_out(vty, " IA - inter-area E - external route\n"); + vty_out(vty, " D - destination R - router\n\n"); + } + /* Show Network routes. */ show_ip_ospf_route_network(vty, ospf, ospf->new_table, json_vrf, detail);