summaryrefslogtreecommitdiff
path: root/ospfd/ospf_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_vty.c')
-rw-r--r--ospfd/ospf_vty.c106
1 files changed, 56 insertions, 50 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 2cb3ec0894..515ec28b1b 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;
}
@@ -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;
}
@@ -11389,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);
}
@@ -11832,9 +11845,7 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
/* Router Dead Interval print. */
if (OSPF_IF_PARAM_CONFIGURED(params, v_wait)
- && params->is_v_wait_set
- && params->v_wait
- != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) {
+ && params->is_v_wait_set) {
vty_out(vty, " ip ospf dead-interval ");
/* fast hello ? */
@@ -11927,7 +11938,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");
@@ -11953,7 +11968,7 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
ospf_opaque_config_write_if(vty, ifp);
- vty_endframe(vty, NULL);
+ vty_endframe(vty, "exit\n!\n");
}
return write;
@@ -12529,6 +12544,8 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
/* LDP-Sync print */
ospf_ldp_sync_write_config(vty, ospf);
+ vty_out(vty, "exit\n");
+
write++;
return write;
}
@@ -12617,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);
@@ -12978,7 +12984,7 @@ void ospf_vty_init(void)
install_element(OSPF_NODE, &ospf_max_multipath_cmd);
install_element(OSPF_NODE, &no_ospf_max_multipath_cmd);
- vrf_cmd_init(NULL, &ospfd_privs);
+ vrf_cmd_init(NULL);
/* Init interface related vty commands. */
ospf_vty_if_init();