diff options
Diffstat (limited to 'ospfd/ospf_vty.c')
| -rw-r--r-- | ospfd/ospf_vty.c | 156 |
1 files changed, 29 insertions, 127 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 828a5cb1ee..8e31dd7329 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -10979,131 +10979,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) @@ -11413,6 +11288,35 @@ static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf, if (ospf->all_rtrs) show_ip_ospf_route_router(vty, ospf, ospf->all_rtrs, json_vrf); + /* Show ORR routes */ + if (ospf->orr_spf_request) { + afi_t afi; + safi_t safi; + struct orr_root *root = NULL; + struct listnode *node = NULL; + struct list *orr_root_list = NULL; + + 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 (!root->new_table) + continue; + if (!json) + vty_out(vty, + "Calculated from location %pI4\n", + &root->router_id); + show_ip_ospf_route_network( + vty, ospf, root->new_table, json_vrf); + if (!root->new_rtrs) + continue; + show_ip_ospf_route_router( + vty, ospf, root->new_rtrs, json_vrf); + } + } + } + /* Show AS External routes. */ show_ip_ospf_route_external(vty, ospf, ospf->old_external_route, json_vrf); @@ -12871,13 +12775,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); |
