From 07bdcc83b332740abcdfa1439cd785319727d6ef Mon Sep 17 00:00:00 2001 From: Shbinging Date: Wed, 9 Oct 2024 07:19:31 +0000 Subject: [PATCH] ospfd:reset wait timer when reading ip ospf dead-interval Signed-off-by: Shbinging --- ospfd/ospf_ism.c | 2 +- ospfd/ospf_ism.h | 1 + ospfd/ospf_vty.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c index 377e7a6bcc20..20bf9085944a 100644 --- a/ospfd/ospf_ism.c +++ b/ospfd/ospf_ism.c @@ -258,7 +258,7 @@ void ospf_hello_timer(struct event *thread) OSPF_HELLO_TIMER_ON(oi); } -static void ospf_wait_timer(struct event *thread) +void ospf_wait_timer(struct event *thread) { struct ospf_interface *oi; diff --git a/ospfd/ospf_ism.h b/ospfd/ospf_ism.h index bbb059c78909..b57bb0009d7b 100644 --- a/ospfd/ospf_ism.h +++ b/ospfd/ospf_ism.h @@ -76,6 +76,7 @@ extern void ospf_ism_event(struct event *thread); extern void ism_change_status(struct ospf_interface *, int); extern void ospf_hello_timer(struct event *thread); extern int ospf_dr_election(struct ospf_interface *oi); +extern void ospf_wait_timer(struct event *thread); DECLARE_HOOK(ospf_ism_change, (struct ospf_interface * oi, int state, int oldstate), diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 27528f659432..2d07dd53fd49 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -8038,6 +8038,7 @@ static int ospf_vty_dead_interval_set(struct vty *vty, const char *interval_str, struct ospf_if_params *params; struct ospf_interface *oi; struct route_node *rn; + int time_remaining; params = IF_DEF_PARAMS(ifp); @@ -8091,6 +8092,38 @@ static int ospf_vty_dead_interval_set(struct vty *vty, const char *interval_str, ospf_nbr_timer_update(oi); } + /*Update wait timer.*/ + if (nbr_str) { + struct ospf *ospf = NULL; + ospf = ifp->vrf->info; + if (ospf) { + oi = ospf_if_lookup_by_local_addr(ospf, ifp, addr); + if (oi) { + time_remaining = seconds - event_timer_remain_second(oi->t_wait); + EVENT_OFF(oi->t_wait); + if (time_remaining > 0) + OSPF_ISM_TIMER_ON(oi->t_wait, ospf_wait_timer, + time_remaining); + else + ospf_wait_timer(oi->t_wait); + } + } + } else { + for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { + oi = rn->info; + if (oi) { + time_remaining = seconds - event_timer_remain_second(oi->t_wait); + EVENT_OFF(oi->t_wait); + if (time_remaining > 0) + OSPF_ISM_TIMER_ON(oi->t_wait, ospf_wait_timer, + time_remaining); + else + ospf_wait_timer(oi->t_wait); + } + } + } + + if (params->fast_hello != OSPF_FAST_HELLO_DEFAULT) ospf_reset_hello_timer(ifp, addr, false); return CMD_SUCCESS; @@ -8139,6 +8172,7 @@ DEFUN (ip_ospf_dead_interval_minimal, { int idx_number = 5; int idx_ipv4 = 6; + if (argc == 7) return ospf_vty_dead_interval_set( vty, NULL, argv[idx_ipv4]->arg, argv[idx_number]->arg);