mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 21:10:28 +00:00
Merge pull request #13140 from rgwan/master
ospfd: Show advertise router in 'show ip ospf route' command
This commit is contained in:
commit
13d9d082a7
@ -884,10 +884,11 @@ Showing Information
|
|||||||
|
|
||||||
Show detailed information about the OSPF link-state database.
|
Show detailed information about the OSPF link-state database.
|
||||||
|
|
||||||
.. clicmd:: show ip ospf route [json]
|
.. clicmd:: show ip ospf route [detail] [json]
|
||||||
|
|
||||||
Show the OSPF routing table, as determined by the most recent SPF
|
Show the OSPF routing table, as determined by the most recent SPF
|
||||||
calculation.
|
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]
|
.. clicmd:: show ip ospf [vrf <NAME|all>] border-routers [json]
|
||||||
|
|
||||||
@ -898,7 +899,7 @@ Showing Information
|
|||||||
|
|
||||||
.. clicmd:: show ip ospf graceful-restart helper [detail] [json]
|
.. clicmd:: show ip ospf graceful-restart helper [detail] [json]
|
||||||
|
|
||||||
Displays the Grcaeful Restart Helper details including helper
|
Displays the Graceful Restart Helper details including helper
|
||||||
config changes.
|
config changes.
|
||||||
|
|
||||||
.. _opaque-lsa:
|
.. _opaque-lsa:
|
||||||
|
@ -48,6 +48,7 @@ struct ospf_route *ospf_route_new(void)
|
|||||||
|
|
||||||
new->paths = list_new();
|
new->paths = list_new();
|
||||||
new->paths->del = (void (*)(void *))ospf_path_free;
|
new->paths->del = (void (*)(void *))ospf_path_free;
|
||||||
|
new->u.std.transit = false;
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
@ -500,6 +501,7 @@ void ospf_intra_add_transit(struct route_table *rt, struct vertex *v,
|
|||||||
or->cost = v->distance;
|
or->cost = v->distance;
|
||||||
or->type = OSPF_DESTINATION_NETWORK;
|
or->type = OSPF_DESTINATION_NETWORK;
|
||||||
or->u.std.origin = (struct lsa_header *)lsa;
|
or->u.std.origin = (struct lsa_header *)lsa;
|
||||||
|
or->u.std.transit = true;
|
||||||
|
|
||||||
ospf_route_copy_nexthops_from_vertex(area, or, v);
|
ospf_route_copy_nexthops_from_vertex(area, or, v);
|
||||||
|
|
||||||
@ -851,7 +853,7 @@ void ospf_route_copy_nexthops_from_vertex(struct ospf_area *area,
|
|||||||
|| area->spf_dry_run) {
|
|| area->spf_dry_run) {
|
||||||
path = ospf_path_new();
|
path = ospf_path_new();
|
||||||
path->nexthop = nexthop->router;
|
path->nexthop = nexthop->router;
|
||||||
path->adv_router = v->id;
|
path->adv_router = v->lsa->adv_router;
|
||||||
|
|
||||||
if (oi) {
|
if (oi) {
|
||||||
path->ifindex = oi->ifp->ifindex;
|
path->ifindex = oi->ifp->ifindex;
|
||||||
|
@ -69,6 +69,8 @@ struct route_standard {
|
|||||||
|
|
||||||
/* */
|
/* */
|
||||||
uint8_t flags; /* From router-LSA */
|
uint8_t flags; /* From router-LSA */
|
||||||
|
|
||||||
|
bool transit; /* Transit network or not */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct route_external {
|
struct route_external {
|
||||||
|
@ -10732,7 +10732,7 @@ static void config_write_stub_router(struct vty *vty, struct ospf *ospf)
|
|||||||
|
|
||||||
static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
|
static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
|
||||||
struct route_table *rt,
|
struct route_table *rt,
|
||||||
json_object *json)
|
json_object *json, bool detail)
|
||||||
{
|
{
|
||||||
struct route_node *rn;
|
struct route_node *rn;
|
||||||
struct ospf_route * or ;
|
struct ospf_route * or ;
|
||||||
@ -10792,15 +10792,17 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
|
|||||||
if (json) {
|
if (json) {
|
||||||
json_object_string_add(json_route, "routeType",
|
json_object_string_add(json_route, "routeType",
|
||||||
"N");
|
"N");
|
||||||
|
json_object_boolean_add(json_route, "transit",
|
||||||
|
or->u.std.transit);
|
||||||
json_object_int_add(json_route, "cost",
|
json_object_int_add(json_route, "cost",
|
||||||
or->cost);
|
or->cost);
|
||||||
json_object_string_addf(json_route, "area",
|
json_object_string_addf(json_route, "area",
|
||||||
"%pI4",
|
"%pI4",
|
||||||
&or->u.std.area_id);
|
&or->u.std.area_id);
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty, "N %-18s [%d] area: %pI4\n",
|
vty_out(vty, "N %s %-18s [%d] area: %pI4\n",
|
||||||
buf1, or->cost,
|
or->u.std.transit && detail ? "T" : " ",
|
||||||
&or->u.std.area_id);
|
buf1, or->cost, &or->u.std.area_id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -10857,6 +10859,11 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
|
|||||||
ifindex2ifname(
|
ifindex2ifname(
|
||||||
path->ifindex,
|
path->ifindex,
|
||||||
ospf->vrf_id));
|
ospf->vrf_id));
|
||||||
|
json_object_string_addf(
|
||||||
|
json_nexthop,
|
||||||
|
"advertisedRouter",
|
||||||
|
"%pI4",
|
||||||
|
&path->adv_router);
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
"%24s via %pI4, %s\n",
|
"%24s via %pI4, %s\n",
|
||||||
@ -10866,6 +10873,11 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
|
|||||||
path->ifindex,
|
path->ifindex,
|
||||||
ospf->vrf_id));
|
ospf->vrf_id));
|
||||||
}
|
}
|
||||||
|
if (detail && !json)
|
||||||
|
vty_out(vty,
|
||||||
|
"%24s adv %pI4\n",
|
||||||
|
"",
|
||||||
|
&path->adv_router);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11020,7 +11032,7 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,
|
|||||||
|
|
||||||
static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,
|
static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,
|
||||||
struct route_table *rt,
|
struct route_table *rt,
|
||||||
json_object *json)
|
json_object *json, bool detail)
|
||||||
{
|
{
|
||||||
struct route_node *rn;
|
struct route_node *rn;
|
||||||
struct ospf_route *er;
|
struct ospf_route *er;
|
||||||
@ -11124,6 +11136,11 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,
|
|||||||
ifindex2ifname(
|
ifindex2ifname(
|
||||||
path->ifindex,
|
path->ifindex,
|
||||||
ospf->vrf_id));
|
ospf->vrf_id));
|
||||||
|
json_object_string_addf(
|
||||||
|
json_nexthop,
|
||||||
|
"advertisedRouter",
|
||||||
|
"%pI4",
|
||||||
|
&path->adv_router);
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
"%24s via %pI4, %s\n",
|
"%24s via %pI4, %s\n",
|
||||||
@ -11133,6 +11150,10 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,
|
|||||||
path->ifindex,
|
path->ifindex,
|
||||||
ospf->vrf_id));
|
ospf->vrf_id));
|
||||||
}
|
}
|
||||||
|
if (detail && !json)
|
||||||
|
vty_out(vty,
|
||||||
|
"%24s adv %pI4\n", "",
|
||||||
|
&path->adv_router);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11419,7 +11440,8 @@ DEFUN (show_ip_ospf_instance_border_routers,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf,
|
static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf,
|
||||||
json_object *json, uint8_t use_vrf)
|
json_object *json, uint8_t use_vrf,
|
||||||
|
bool detail)
|
||||||
{
|
{
|
||||||
json_object *json_vrf = NULL;
|
json_object *json_vrf = NULL;
|
||||||
|
|
||||||
@ -11446,8 +11468,15 @@ static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf,
|
|||||||
return CMD_SUCCESS;
|
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 Network routes. */
|
||||||
show_ip_ospf_route_network(vty, ospf, ospf->new_table, json_vrf);
|
show_ip_ospf_route_network(vty, ospf, ospf->new_table, json_vrf,
|
||||||
|
detail);
|
||||||
|
|
||||||
/* Show Router routes. */
|
/* Show Router routes. */
|
||||||
show_ip_ospf_route_router(vty, ospf, ospf->new_rtrs, json_vrf);
|
show_ip_ospf_route_router(vty, ospf, ospf->new_rtrs, json_vrf);
|
||||||
@ -11458,7 +11487,7 @@ static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf,
|
|||||||
|
|
||||||
/* Show AS External routes. */
|
/* Show AS External routes. */
|
||||||
show_ip_ospf_route_external(vty, ospf, ospf->old_external_route,
|
show_ip_ospf_route_external(vty, ospf, ospf->old_external_route,
|
||||||
json_vrf);
|
json_vrf, detail);
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
if (use_vrf) {
|
if (use_vrf) {
|
||||||
@ -11476,13 +11505,14 @@ static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf,
|
|||||||
|
|
||||||
DEFUN (show_ip_ospf_route,
|
DEFUN (show_ip_ospf_route,
|
||||||
show_ip_ospf_route_cmd,
|
show_ip_ospf_route_cmd,
|
||||||
"show ip ospf [vrf <NAME|all>] route [json]",
|
"show ip ospf [vrf <NAME|all>] route [detail] [json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
"OSPF information\n"
|
"OSPF information\n"
|
||||||
VRF_CMD_HELP_STR
|
VRF_CMD_HELP_STR
|
||||||
"All VRFs\n"
|
"All VRFs\n"
|
||||||
"OSPF routing table\n"
|
"OSPF routing table\n"
|
||||||
|
"Detailed information\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
struct ospf *ospf = NULL;
|
struct ospf *ospf = NULL;
|
||||||
@ -11491,14 +11521,19 @@ DEFUN (show_ip_ospf_route,
|
|||||||
bool all_vrf = false;
|
bool all_vrf = false;
|
||||||
int ret = CMD_SUCCESS;
|
int ret = CMD_SUCCESS;
|
||||||
int inst = 0;
|
int inst = 0;
|
||||||
|
int idx = 0;
|
||||||
int idx_vrf = 0;
|
int idx_vrf = 0;
|
||||||
uint8_t use_vrf = 0;
|
uint8_t use_vrf = 0;
|
||||||
bool uj = use_json(argc, argv);
|
bool uj = use_json(argc, argv);
|
||||||
|
bool detail = false;
|
||||||
json_object *json = NULL;
|
json_object *json = NULL;
|
||||||
|
|
||||||
if (uj)
|
if (uj)
|
||||||
json = json_object_new_object();
|
json = json_object_new_object();
|
||||||
|
|
||||||
|
if (argv_find(argv, argc, "detail", &idx))
|
||||||
|
detail = true;
|
||||||
|
|
||||||
OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
|
OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
|
||||||
|
|
||||||
/* vrf input is provided could be all or specific vrf*/
|
/* vrf input is provided could be all or specific vrf*/
|
||||||
@ -11512,8 +11547,8 @@ DEFUN (show_ip_ospf_route,
|
|||||||
if (!ospf->oi_running)
|
if (!ospf->oi_running)
|
||||||
continue;
|
continue;
|
||||||
ospf_output = true;
|
ospf_output = true;
|
||||||
ret = show_ip_ospf_route_common(vty, ospf, json,
|
ret = show_ip_ospf_route_common(
|
||||||
use_vrf);
|
vty, ospf, json, use_vrf, detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uj) {
|
if (uj) {
|
||||||
@ -11550,7 +11585,8 @@ DEFUN (show_ip_ospf_route,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ospf) {
|
if (ospf) {
|
||||||
ret = show_ip_ospf_route_common(vty, ospf, json, use_vrf);
|
ret = show_ip_ospf_route_common(vty, ospf, json, use_vrf,
|
||||||
|
detail);
|
||||||
/* Keep Non-pretty format */
|
/* Keep Non-pretty format */
|
||||||
if (uj)
|
if (uj)
|
||||||
vty_out(vty, "%s\n",
|
vty_out(vty, "%s\n",
|
||||||
@ -11566,16 +11602,22 @@ DEFUN (show_ip_ospf_route,
|
|||||||
|
|
||||||
DEFUN (show_ip_ospf_instance_route,
|
DEFUN (show_ip_ospf_instance_route,
|
||||||
show_ip_ospf_instance_route_cmd,
|
show_ip_ospf_instance_route_cmd,
|
||||||
"show ip ospf (1-65535) route",
|
"show ip ospf (1-65535) route [detail]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
"OSPF information\n"
|
"OSPF information\n"
|
||||||
"Instance ID\n"
|
"Instance ID\n"
|
||||||
"OSPF routing table\n")
|
"OSPF routing table\n"
|
||||||
|
"Detailed information\n")
|
||||||
{
|
{
|
||||||
int idx_number = 3;
|
int idx_number = 3;
|
||||||
|
int idx = 0;
|
||||||
struct ospf *ospf;
|
struct ospf *ospf;
|
||||||
unsigned short instance = 0;
|
unsigned short instance = 0;
|
||||||
|
bool detail = false;
|
||||||
|
|
||||||
|
if (argv_find(argv, argc, "detail", &idx))
|
||||||
|
detail = true;
|
||||||
|
|
||||||
instance = strtoul(argv[idx_number]->arg, NULL, 10);
|
instance = strtoul(argv[idx_number]->arg, NULL, 10);
|
||||||
if (instance != ospf_instance)
|
if (instance != ospf_instance)
|
||||||
@ -11585,7 +11627,7 @@ DEFUN (show_ip_ospf_instance_route,
|
|||||||
if (!ospf || !ospf->oi_running)
|
if (!ospf || !ospf->oi_running)
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
return show_ip_ospf_route_common(vty, ospf, NULL, 0);
|
return show_ip_ospf_route_common(vty, ospf, NULL, 0, detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user