Skip to content

Commit

Permalink
ospfd: OSPF hello packets not sent with configured hello timer
Browse files Browse the repository at this point in the history
Description :
	ospf hello timer is not getting refelcted upon
	changing the hello interval.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
  • Loading branch information
rgirada committed Jul 22, 2021
1 parent 1dce93d commit be41816
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
52 changes: 52 additions & 0 deletions ospfd/ospf_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,58 @@ static int ospf_ifp_destroy(struct interface *ifp)
return 0;
}

/* Resetting ospf hello timer */
void ospf_reset_hello_timer(struct interface *ifp, struct in_addr addr,
bool is_addr)
{
struct route_node *rn;

if (is_addr) {
struct prefix p;
struct ospf_interface *oi = NULL;

p.u.prefix4 = addr;
p.family = AF_INET;

oi = ospf_if_table_lookup(ifp, &p);

if (oi) {
/* Send hello before restart the hello timer
* to avoid session flaps in case of bigger
* hello interval configurations.
*/
ospf_hello_send(oi);

/* Restart hello timer for this interface */
OSPF_ISM_TIMER_OFF(oi->t_hello);
OSPF_HELLO_TIMER_ON(oi);
}

return;
}

for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {
struct ospf_interface *oi = rn->info;

if (!oi)
continue;

/* If hello interval configured on this oi, don't restart. */
if (OSPF_IF_PARAM_CONFIGURED(oi->params, v_hello))
continue;

/* Send hello before restart the hello timer
* to avoid session flaps in case of bigger
* hello interval configurations.
*/
ospf_hello_send(oi);

/* Restart the hello timer. */
OSPF_ISM_TIMER_OFF(oi->t_hello);
OSPF_HELLO_TIMER_ON(oi);
}
}

void ospf_if_init(void)
{
if_zapi_callbacks(ospf_ifp_create, ospf_ifp_up,
Expand Down
3 changes: 2 additions & 1 deletion ospfd/ospf_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ extern void ospf_if_set_multicast(struct ospf_interface *);
extern void ospf_if_interface(struct interface *ifp);

extern uint32_t ospf_if_count_area_params(struct interface *ifp);

extern void ospf_reset_hello_timer(struct interface *ifp, struct in_addr addr,
bool is_addr);
DECLARE_HOOK(ospf_vl_add, (struct ospf_vl_data * vd), (vd));
DECLARE_HOOK(ospf_vl_delete, (struct ospf_vl_data * vd), (vd));

Expand Down
15 changes: 13 additions & 2 deletions ospfd/ospf_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -8305,10 +8305,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);
Expand All @@ -8322,8 +8324,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;

Expand All @@ -8338,6 +8347,8 @@ DEFUN (ip_ospf_hello_interval,
params->v_wait = 4 * seconds;
}

ospf_reset_hello_timer(ifp, addr, is_addr);

return CMD_SUCCESS;
}

Expand All @@ -8364,7 +8375,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;

Expand Down

0 comments on commit be41816

Please sign in to comment.