]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: Support show intra-area network type in 'show ip ospf route' command
authorZhiyuan Wan <h@iloli.bid>
Mon, 3 Apr 2023 08:21:15 +0000 (16:21 +0800)
committerZhiyuan Wan <h@iloli.bid>
Tue, 18 Jul 2023 06:20:05 +0000 (14:20 +0800)
User can now use 'show ip ospf route detail' command to distinguish
intra-area stub network and transit network.
Transit network will be displayed as 'N T prefix ...'.

NOTICE: Json output format has been changed, intra-area transit networks
will have a new attribute 'transit' and value is 'true'.
And 'adv' (means advertise router) change to 'advertisedRouter'.

Example output:

bsp-debianrt-exp1# show ip ospf route detail
Codes: N  - network     T - transitive
       IA - inter-area  E - external route
       D  - destination R - router

============ OSPF network routing table ============
N T  10.0.0.0/24           [32] area: 0.0.0.0
                           via 192.168.124.67, ens192
                           adv 10.0.0.5
N    10.0.30.0/24          [33] area: 0.0.0.0
                           via 192.168.124.67, ens192
                           adv 10.0.0.5
...

Signed-off-by: Zhiyuan Wan <h@iloli.bid>
doc/user/ospfd.rst
ospfd/ospf_route.c
ospfd/ospf_route.h
ospfd/ospf_vty.c

index 9491c5e42f400e2257aef052f24ce2a47f1e8b19..4e30ef2aec2d86ae0923c70ca8006549b77faa70 100644 (file)
@@ -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 <NAME|all>] border-routers [json]
 
index e32e06e7a4a1386dc9645aa6d6d4e208b02b2497..3ffa7c0bb11eeb803e09ea7ac7a6b4bc98ffdf03 100644 (file)
@@ -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);
 
index 7639a0049e1263eed1c454d23f4fc9e88a423977..44e80216d711d404fef743737e779c51e5045a53 100644 (file)
@@ -69,6 +69,8 @@ struct route_standard {
 
        /*  */
        uint8_t flags; /* From router-LSA */
+
+       bool transit; /* Transit network or not */
 };
 
 struct route_external {
index 0438bbcdf80f7a8d96b5800603cecf43b0b36665..a23802719b5ecb371454f0ae343d07eab099bfee 100644 (file)
@@ -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);