From 87bd50e8577b16feefbcea0dc821b8e3e2e250c8 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Sun, 17 Sep 2017 15:44:39 -0700 Subject: [PATCH] ospfd: OSPFv2 VRF, vrf in show command output Add VRF name in both vtysh and json format of show commands. Signed-off-by: Chirag Shah --- ospfd/ospf_lsa.c | 2 +- ospfd/ospf_vty.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 1795225ca7..74d5178f55 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -1702,7 +1702,7 @@ static void ospf_install_flood_nssa(struct ospf *ospf, struct ospf_lsa *lsa, not adversited into OSPF as an internal OSPF route and the type-7 LSA's P-bit is set a forwarding address should be - selected from one of the router's active OSPF inteface + selected from one of the router's active OSPF interface addresses which belong to the NSSA. If no such addresses exist, then diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 3840bc4170..7d6f40bfe7 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2890,6 +2890,13 @@ static int show_ip_ospf_common(struct vty *vty, struct ospf *ospf, } } + if (ospf->name) { + if (use_json) + json_object_string_add(json, "vrfName", ospf->name); + else + vty_out(vty, "OSPF vrfName: %s\n", ospf->name); + } + /* Show Router ID. */ if (use_json) { json_object_string_add(json, "routerId", @@ -3857,6 +3864,13 @@ static int show_ip_ospf_neighbor_common(struct vty *vty, struct ospf *ospf, vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); } + if (ospf->name) { + if (use_json) + json_object_string_add(json, "vrfName", ospf->name); + else + vty_out(vty, "OSPF vrfName: %s\n", ospf->name); + } + for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) show_ip_ospf_neighbor_sub(vty, oi, json, use_json); @@ -4146,6 +4160,13 @@ static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf, vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); } + if (ospf->name) { + if (use_json) + json_object_string_add(json, "vrfName", ospf->name); + else + vty_out(vty, "OSPF vrfName: %s\n", ospf->name); + } + /*ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id);*/ ifp = if_lookup_by_name_all_vrf(argv[arg_base]->arg); if (!ifp) { @@ -4558,6 +4579,13 @@ static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf, vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); } + if (ospf->name) { + if (use_json) + json_object_string_add(json, "vrfName", ospf->name); + else + vty_out(vty, "OSPF vrfName: %s\n", ospf->name); + } + ret = inet_aton(argv[arg_base]->arg, &router_id); if (!ret) { if (!use_json) @@ -4657,6 +4685,13 @@ static int show_ip_ospf_neighbor_detail_common(struct vty *vty, vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); } + if (ospf->name) { + if (use_json) + json_object_string_add(json, "vrfName", ospf->name); + else + vty_out(vty, "OSPF vrfName: %s\n", ospf->name); + } + for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) { struct route_node *rn; struct ospf_neighbor *nbr; @@ -4781,6 +4816,13 @@ static int show_ip_ospf_neighbor_detail_all_common(struct vty *vty, vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); } + if (ospf->name) { + if (use_json) + json_object_string_add(json, "vrfName", ospf->name); + else + vty_out(vty, "OSPF vrfName: %s\n", ospf->name); + } + for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) { struct route_node *rn; struct ospf_neighbor *nbr; @@ -5591,6 +5633,9 @@ static int show_ip_ospf_database_common(struct vty *vty, struct ospf *ospf, if (ospf->instance) vty_out(vty, "\nOSPF Instance: %d\n", ospf->instance); + if (ospf->name) + vty_out(vty, "OSPF vrfName: %s\n", ospf->name); + vty_out(vty, "\n OSPF Router with ID (%s)\n\n", inet_ntoa(ospf->router_id)); @@ -5812,6 +5857,9 @@ static int show_ip_ospf_database_type_adv_router_common(struct vty *vty, if (ospf->instance) vty_out(vty, "\nOSPF Instance: %d\n", ospf->instance); + if (ospf->name) + vty_out(vty, "OSPF vrfName: %s\n", ospf->name); + vty_out(vty, "\n OSPF Router with ID (%s)\n\n", inet_ntoa(ospf->router_id)); @@ -8368,6 +8416,9 @@ static int show_ip_ospf_border_routers_common(struct vty *vty, if (ospf->instance) vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); + if (ospf->name) + vty_out(vty, "OSPF vrfName: %s\n", ospf->name); + if (ospf->new_table == NULL) { vty_out(vty, "No OSPF routing information exist\n"); return CMD_SUCCESS; @@ -8460,6 +8511,9 @@ static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf) if (ospf->instance) vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); + if (ospf->name) + vty_out(vty, "OSPF vrfName: %s\n", ospf->name); + if (ospf->new_table == NULL) { vty_out(vty, "No OSPF routing information exist\n"); return CMD_SUCCESS; -- 2.39.5