diff options
Diffstat (limited to 'ospfd/ospf_vty.c')
| -rw-r--r-- | ospfd/ospf_vty.c | 127 |
1 files changed, 76 insertions, 51 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 54ce248d89..4c248c0df3 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -286,7 +286,7 @@ DEFPY (ospf_router_id, for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) if (area->full_nbrs) { vty_out(vty, - "For this router-id change to take effect, use “clear ip ospf process” command\n"); + "For this router-id change to take effect, use \"clear ip ospf process\" command\n"); return CMD_SUCCESS; } @@ -319,7 +319,7 @@ DEFUN_HIDDEN (ospf_router_id_old, for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) if (area->full_nbrs) { vty_out(vty, - "For this router-id change to take effect, use “clear ip ospf process” command\n"); + "For this router-id change to take effect, use \"clear ip ospf process\" command\n"); return CMD_SUCCESS; } @@ -352,7 +352,7 @@ DEFPY (no_ospf_router_id, for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) if (area->full_nbrs) { vty_out(vty, - "For this router-id change to take effect, use “clear ip ospf process” command\n"); + "For this router-id change to take effect, use \"clear ip ospf process\" command\n"); return CMD_SUCCESS; } @@ -375,10 +375,27 @@ static void ospf_passive_interface_default_update(struct ospf *ospf, ospf_if_set_multicast(oi); } -static void ospf_passive_interface_update(struct interface *ifp) +static void ospf_passive_interface_update(struct interface *ifp, + struct ospf_if_params *params, + struct in_addr addr, uint8_t newval) { struct route_node *rn; + if (OSPF_IF_PARAM_CONFIGURED(params, passive_interface)) { + if (params->passive_interface == newval) + return; + + params->passive_interface = newval; + UNSET_IF_PARAM(params, passive_interface); + if (params != IF_DEF_PARAMS(ifp)) { + ospf_free_if_params(ifp, addr); + ospf_if_update_params(ifp, addr); + } + } else { + params->passive_interface = newval; + SET_IF_PARAM(params, passive_interface); + } + /* * XXX We should call ospf_if_set_multicast on exactly those * interfaces for which the passive property changed. It is too much @@ -457,10 +474,7 @@ DEFUN_HIDDEN (ospf_passive_interface_addr, params = IF_DEF_PARAMS(ifp); } - params->passive_interface = OSPF_IF_PASSIVE; - SET_IF_PARAM(params, passive_interface); - - ospf_passive_interface_update(ifp); + ospf_passive_interface_update(ifp, params, addr, OSPF_IF_PASSIVE); return CMD_SUCCESS; } @@ -521,14 +535,7 @@ DEFUN_HIDDEN (no_ospf_passive_interface, params = IF_DEF_PARAMS(ifp); } - params->passive_interface = OSPF_IF_ACTIVE; - UNSET_IF_PARAM(params, passive_interface); - if (params != IF_DEF_PARAMS(ifp)) { - ospf_free_if_params(ifp, addr); - ospf_if_update_params(ifp, addr); - } - - ospf_passive_interface_update(ifp); + ospf_passive_interface_update(ifp, params, addr, OSPF_IF_ACTIVE); return CMD_SUCCESS; } @@ -6616,7 +6623,7 @@ static void show_lsa_prefix_set(struct vty *vty, struct prefix_ls *lp, if (id == NULL) lp->prefixlen = 0; else if (adv_router == NULL) { - lp->prefixlen = 32; + lp->prefixlen = IPV4_MAX_BITLEN; lp->id = *id; } else { lp->prefixlen = 64; @@ -8305,10 +8312,12 @@ DEFUN (ip_ospf_hello_interval, { VTY_DECLVAR_CONTEXT(interface, ifp); int idx = 0; - struct in_addr addr; + struct in_addr addr = {.s_addr = 0L}; struct ospf_if_params *params; params = IF_DEF_PARAMS(ifp); uint32_t seconds = 0; + bool is_addr = false; + uint32_t old_interval = 0; argv_find(argv, argc, "(1-65535)", &idx); seconds = strtol(argv[idx]->arg, NULL, 10); @@ -8322,8 +8331,15 @@ DEFUN (ip_ospf_hello_interval, params = ospf_get_if_params(ifp, addr); ospf_if_update_params(ifp, addr); + is_addr = true; } + old_interval = params->v_hello; + + /* Return, if same interval is configured. */ + if (old_interval == seconds) + return CMD_SUCCESS; + SET_IF_PARAM(params, v_hello); params->v_hello = seconds; @@ -8338,6 +8354,8 @@ DEFUN (ip_ospf_hello_interval, params->v_wait = 4 * seconds; } + ospf_reset_hello_timer(ifp, addr, is_addr); + return CMD_SUCCESS; } @@ -8364,7 +8382,7 @@ DEFUN (no_ip_ospf_hello_interval, { VTY_DECLVAR_CONTEXT(interface, ifp); int idx = 0; - struct in_addr addr; + struct in_addr addr = {.s_addr = 0L}; struct ospf_if_params *params; struct route_node *rn; @@ -9082,7 +9100,7 @@ DEFUN (ip_ospf_passive, { VTY_DECLVAR_CONTEXT(interface, ifp); int idx_ipv4 = 3; - struct in_addr addr; + struct in_addr addr = {.s_addr = INADDR_ANY}; struct ospf_if_params *params; int ret; @@ -9099,10 +9117,7 @@ DEFUN (ip_ospf_passive, params = IF_DEF_PARAMS(ifp); } - params->passive_interface = OSPF_IF_PASSIVE; - SET_IF_PARAM(params, passive_interface); - - ospf_passive_interface_update(ifp); + ospf_passive_interface_update(ifp, params, addr, OSPF_IF_PASSIVE); return CMD_SUCCESS; } @@ -9118,7 +9133,7 @@ DEFUN (no_ip_ospf_passive, { VTY_DECLVAR_CONTEXT(interface, ifp); int idx_ipv4 = 4; - struct in_addr addr; + struct in_addr addr = {.s_addr = INADDR_ANY}; struct ospf_if_params *params; int ret; @@ -9136,14 +9151,7 @@ DEFUN (no_ip_ospf_passive, params = IF_DEF_PARAMS(ifp); } - params->passive_interface = OSPF_IF_ACTIVE; - UNSET_IF_PARAM(params, passive_interface); - if (params != IF_DEF_PARAMS(ifp)) { - ospf_free_if_params(ifp, addr); - ospf_if_update_params(ifp, addr); - } - - ospf_passive_interface_update(ifp); + ospf_passive_interface_update(ifp, params, addr, OSPF_IF_ACTIVE); return CMD_SUCCESS; } @@ -10027,7 +10035,7 @@ DEFUN (ospf_external_route_aggregation, str2prefix_ipv4(argv[idx]->arg, &p); - if (is_prefix_default(&p)) { + if (is_default_prefix4(&p)) { vty_out(vty, "Default address shouldn't be configured as summary address.\n"); return CMD_SUCCESS; @@ -10068,7 +10076,7 @@ DEFUN (no_ospf_external_route_aggregation, str2prefix_ipv4(argv[idx]->arg, &p); - if (is_prefix_default(&p)) { + if (is_default_prefix4(&p)) { vty_out(vty, "Default address shouldn't be configured as summary address.\n"); return CMD_SUCCESS; @@ -10361,7 +10369,7 @@ DEFUN (ospf_external_route_aggregation_no_adrvertise, str2prefix_ipv4(argv[idx]->arg, &p); - if (is_prefix_default(&p)) { + if (is_default_prefix4(&p)) { vty_out(vty, "Default address shouldn't be configured as summary address.\n"); return CMD_SUCCESS; @@ -10397,7 +10405,7 @@ DEFUN (no_ospf_external_route_aggregation_no_adrvertise, str2prefix_ipv4(argv[idx]->arg, &p); - if (is_prefix_default(&p)) { + if (is_default_prefix4(&p)) { vty_out(vty, "Default address shouldn't be configured as summary address.\n"); return CMD_SUCCESS; @@ -10913,6 +10921,8 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, "N E1"); json_object_int_add(json_route, "cost", er->cost); + json_object_int_add(json_route, "tag", + er->u.ext.tag); } else { vty_out(vty, "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI @@ -10926,6 +10936,10 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, "N E2"); json_object_int_add(json_route, "cost", er->cost); + json_object_int_add(json_route, "type2cost", + er->u.ext.type2_cost); + json_object_int_add(json_route, "tag", + er->u.ext.tag); } else { vty_out(vty, "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI @@ -11383,6 +11397,11 @@ DEFPY (clear_ip_ospf_neighbor, if (!ospf->oi_running) continue; + if (nbr_id_str && IPV4_ADDR_SAME(&ospf->router_id, &nbr_id)) { + vty_out(vty, "Self router-id is not allowed.\r\n "); + return CMD_SUCCESS; + } + ospf_neighbor_reset(ospf, nbr_id, nbr_id_str); } @@ -11921,7 +11940,11 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) if (OSPF_IF_PARAM_CONFIGURED(params, passive_interface)) { - vty_out(vty, " ip ospf passive"); + vty_out(vty, " %sip ospf passive", + params->passive_interface + == OSPF_IF_ACTIVE + ? "no " + : ""); if (params != IF_DEF_PARAMS(ifp) && rn) vty_out(vty, " %pI4", &rn->p.u.prefix4); vty_out(vty, "\n"); @@ -12244,6 +12267,18 @@ static int ospf_cfg_write_helper_dis_rtr_walkcb(struct hash_bucket *bucket, return HASHWALK_CONTINUE; } +static void config_write_ospf_gr(struct vty *vty, struct ospf *ospf) +{ + if (!ospf->gr_info.restart_support) + return; + + if (ospf->gr_info.grace_period == OSPF_DFLT_GRACE_INTERVAL) + vty_out(vty, " graceful-restart\n"); + else + vty_out(vty, " graceful-restart grace-period %u\n", + ospf->gr_info.grace_period); +} + static int config_write_ospf_gr_helper(struct vty *vty, struct ospf *ospf) { if (ospf->is_helper_supported) @@ -12458,7 +12493,8 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf) /* Redistribute information print. */ config_write_ospf_redistribute(vty, ospf); - /* Print gr helper configs */ + /* Graceful Restart print */ + config_write_ospf_gr(vty, ospf); config_write_ospf_gr_helper(vty, ospf); /* Print external route aggregation. */ @@ -12598,22 +12634,11 @@ void ospf_vty_show_init(void) install_element(VIEW_NODE, &show_ip_ospf_external_aggregator_cmd); } -static int config_write_interface(struct vty *vty); -/* ospfd's interface node. */ -static struct cmd_node interface_node = { - .name = "interface", - .node = INTERFACE_NODE, - .parent_node = CONFIG_NODE, - .prompt = "%s(config-if)# ", - .config_write = config_write_interface, -}; - /* Initialization of OSPF interface. */ static void ospf_vty_if_init(void) { /* Install interface node. */ - install_node(&interface_node); - if_cmd_init(); + if_cmd_init(config_write_interface); /* "ip ospf authentication" commands. */ install_element(INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
