Skip to content

Commit

Permalink
ospfd:reset wait timer when reading ip ospf dead-interval
Browse files Browse the repository at this point in the history
Signed-off-by: Shbinging <[email protected]>
  • Loading branch information
Shbinging committed Oct 9, 2024
1 parent 8b1b531 commit 3a0a803
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ospfd/ospf_ism.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions ospfd/ospf_ism.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
26 changes: 26 additions & 0 deletions ospfd/ospf_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -8050,6 +8050,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;
uint32_t reset_wait_time;

params = IF_DEF_PARAMS(ifp);

Expand Down Expand Up @@ -8083,6 +8084,7 @@ static int ospf_vty_dead_interval_set(struct vty *vty, const char *interval_str,
return CMD_WARNING_CONFIG_FAILED;
}

reset_wait_time = seconds >= params->v_wait ? seconds - params->v_wait : seconds;
SET_IF_PARAM(params, v_wait);
params->v_wait = seconds;
params->is_v_wait_set = true;
Expand All @@ -8103,6 +8105,30 @@ static int ospf_vty_dead_interval_set(struct vty *vty, const char *interval_str,
ospf_nbr_timer_update(oi);
}

/*Update wait timer.*/
if (reset_wait_time) {
if (nbr_str) {
struct ospf *ospf = NULL;
ospf = ifp->vrf->info;
if (ospf) {
oi = ospf_if_lookup_by_local_addr(ospf, ifp, addr);
//Wait timer is currently running
if (oi && oi->state == ISM_Waiting) {
EVENT_OFF(oi->t_wait);
OSPF_ISM_TIMER_ON(oi->t_wait, ospf_wait_timer,
reset_wait_time);
}
}
} else {
for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn))
if ((oi = rn->info) && oi->state == ISM_Waiting) {
EVENT_OFF(oi->t_wait);
OSPF_ISM_TIMER_ON(oi->t_wait, ospf_wait_timer,
reset_wait_time);
}
}
}

if (params->fast_hello != OSPF_FAST_HELLO_DEFAULT)
ospf_reset_hello_timer(ifp, addr, false);
return CMD_SUCCESS;
Expand Down

0 comments on commit 3a0a803

Please sign in to comment.