diff options
Diffstat (limited to 'ospfd/ospf_vty.c')
| -rw-r--r-- | ospfd/ospf_vty.c | 167 |
1 files changed, 31 insertions, 136 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 828a5cb1ee..0b0b9d81ee 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -55,7 +55,6 @@ #include "ospfd/ospf_dump.h" #include "ospfd/ospf_bfd.h" #include "ospfd/ospf_ldp_sync.h" -#include "ospfd/ospf_orr.h" FRR_CFG_DEFAULT_BOOL(OSPF_LOG_ADJACENCY_CHANGES, @@ -7315,16 +7314,26 @@ static int show_ip_ospf_database_type_adv_router_common(struct vty *vty, type = OSPF_OPAQUE_AREA_LSA; else if (strncmp(argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) type = OSPF_OPAQUE_AS_LSA; - else + else { + if (uj) { + if (use_vrf) + json_object_free(json_vrf); + } return CMD_WARNING; + } /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ if (strncmp(argv[arg_base + 5]->text, "s", 1) == 0) adv_router = ospf->router_id; else { ret = inet_aton(argv[arg_base + 6]->arg, &adv_router); - if (!ret) + if (!ret) { + if (uj) { + if (use_vrf) + json_object_free(json_vrf); + } return CMD_WARNING; + } } show_lsa_detail_adv_router(vty, ospf, type, &adv_router, json_vrf); @@ -7388,9 +7397,12 @@ DEFUN (show_ip_ospf_database_type_adv_router, } else { ospf = ospf_lookup_by_inst_name(inst, vrf_name); if ((ospf == NULL) || !ospf->oi_running) { - vty_out(vty, - "%% OSPF is not enabled in vrf %s\n", - vrf_name); + if (uj) + vty_json(vty, json); + else + vty_out(vty, + "%% OSPF is not enabled in vrf %s\n", + vrf_name); return CMD_SUCCESS; } @@ -7401,7 +7413,11 @@ DEFUN (show_ip_ospf_database_type_adv_router, /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); if (ospf == NULL || !ospf->oi_running) { - vty_out(vty, "%% OSPF is not enabled on vrf default\n"); + if (uj) + vty_json(vty, json); + else + vty_out(vty, + "%% OSPF is not enabled on vrf default\n"); return CMD_SUCCESS; } @@ -10979,131 +10995,6 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, vty_out(vty, "\n"); } -static void show_ip_ospf_route_orr_root(struct vty *vty, struct ospf *ospf, - struct orr_root *root, bool use_vrf) -{ - if (ospf->instance) - vty_out(vty, "\nOSPF Instance: %d\n", ospf->instance); - - ospf_show_vrf_name(ospf, vty, NULL, use_vrf); - - vty_out(vty, "ORR Group: %s\n", root->group_name); - vty_out(vty, "Active Root: %pI4\n\n", &root->router_id); - vty_out(vty, "SPF calculated from %pI4\n\n", &root->router_id); - - if (root->new_table) - show_ip_ospf_route_network(vty, ospf, root->new_table, NULL); - - if (root->new_rtrs) - show_ip_ospf_route_router(vty, ospf, root->new_rtrs, NULL); - - vty_out(vty, "\n"); -} - -static void show_ip_ospf_route_orr_common(struct vty *vty, struct ospf *ospf, - const char *orr_group, bool use_vrf) -{ - afi_t afi; - safi_t safi; - struct orr_root *root = NULL; - struct listnode *node = NULL; - struct list *orr_root_list = NULL; - - if (!ospf->orr_spf_request) - return; - - FOREACH_AFI_SAFI (afi, safi) { - orr_root_list = ospf->orr_root[afi][safi]; - if (!orr_root_list) - continue; - for (ALL_LIST_ELEMENTS_RO(orr_root_list, node, root)) { - if (orr_group) { - if (!strmatch(root->group_name, orr_group)) - continue; - show_ip_ospf_route_orr_root(vty, ospf, root, - use_vrf); - } else - show_ip_ospf_route_orr_root(vty, ospf, root, - use_vrf); - } - } -} - -DEFPY (show_ip_ospf_instance_route_orr, - show_ip_ospf_instance_route_orr_cmd, - "show ip ospf (1-65535)$instance route orr [WORD$orr_group]", - SHOW_STR - IP_STR - OSPF_STR - "Instance ID\n" - "OSPF routing table\n" - "Optimal Route Reflection\n" - "ORR Group name\n") -{ - struct ospf *ospf; - - if (instance != ospf_instance) - return CMD_NOT_MY_INSTANCE; - - ospf = ospf_lookup_instance(instance); - if (!ospf || !ospf->oi_running) - return CMD_SUCCESS; - - show_ip_ospf_route_orr_common(vty, ospf, orr_group, false); - - return CMD_SUCCESS; -} - -DEFPY (show_ip_ospf_route_orr, - show_ip_ospf_route_orr_cmd, - "show ip ospf [vrf <NAME$vrf_name|all$all_vrf>] route orr [WORD$orr_group]", - SHOW_STR - IP_STR - OSPF_STR - VRF_CMD_HELP_STR - "All VRFs\n" - "OSPF routing table\n" - "Optimal Route Reflection\n" - "ORR Group name\n") -{ - struct ospf *ospf = NULL; - struct listnode *node = NULL; - int ret = CMD_SUCCESS; - int inst = 0; - bool use_vrf = vrf_name || all_vrf; - - if (all_vrf) { - bool ospf_output = false; - - for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { - if (!ospf->oi_running) - continue; - ospf_output = true; - - show_ip_ospf_route_orr_common(vty, ospf, orr_group, - use_vrf); - } - if (!ospf_output) - vty_out(vty, "%% OSPF is not enabled\n"); - return ret; - } - - if (vrf_name) - ospf = ospf_lookup_by_inst_name(inst, vrf_name); - else - ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); - - if (!ospf || !ospf->oi_running) { - vty_out(vty, "%% OSPF is not enabled in vrf %s\n", - vrf_name ? vrf_name : "default"); - return CMD_SUCCESS; - } - - show_ip_ospf_route_orr_common(vty, ospf, orr_group, use_vrf); - - return ret; -} - static int show_ip_ospf_reachable_routers_common(struct vty *vty, struct ospf *ospf, uint8_t use_vrf) @@ -11243,7 +11134,8 @@ static int show_ip_ospf_border_routers_common(struct vty *vty, vty_out(vty, "No OSPF routing information exist\n"); else { json_object_free(json_router); - json_object_free(json_vrf); + if (use_vrf) + json_object_free(json_vrf); } return CMD_SUCCESS; } @@ -11399,7 +11291,12 @@ static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf, ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); if (ospf->new_table == NULL) { - vty_out(vty, "No OSPF routing information exist\n"); + if (json) { + if (use_vrf) + json_object_free(json_vrf); + } else { + vty_out(vty, "No OSPF routing information exist\n"); + } return CMD_SUCCESS; } @@ -12871,13 +12768,11 @@ void ospf_vty_show_init(void) install_element(VIEW_NODE, &show_ip_ospf_route_cmd); install_element(VIEW_NODE, &show_ip_ospf_border_routers_cmd); install_element(VIEW_NODE, &show_ip_ospf_reachable_routers_cmd); - install_element(VIEW_NODE, &show_ip_ospf_route_orr_cmd); install_element(VIEW_NODE, &show_ip_ospf_instance_route_cmd); install_element(VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd); install_element(VIEW_NODE, &show_ip_ospf_instance_reachable_routers_cmd); - install_element(VIEW_NODE, &show_ip_ospf_instance_route_orr_cmd); /* "show ip ospf vrfs" commands. */ install_element(VIEW_NODE, &show_ip_ospf_vrfs_cmd); |
