diff options
| author | Russ White <russ@riw.us> | 2022-10-12 09:30:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-12 09:30:36 -0400 |
| commit | 984eb32b588186ac946733c5c3fe8032bae28ebc (patch) | |
| tree | fadbfb00938fbd06eb92909bfe628857b7b3d00f /ospfd/ospf_vty.c | |
| parent | 87d54383c520799a90457e84e2242b6fa2024f73 (diff) | |
| parent | 80f6ea8b99188b9d8e79fe4fc1740cc92375d7bc (diff) | |
Merge pull request #11159 from maduri111/bgpd-orr
bgpd: optimal route reflection
Diffstat (limited to 'ospfd/ospf_vty.c')
| -rw-r--r-- | ospfd/ospf_vty.c | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index c957c8c014..4f0fa6194a 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -55,6 +55,7 @@ #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, @@ -10982,6 +10983,131 @@ 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) @@ -12694,11 +12820,13 @@ 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); |
