Skip to content

Commit cf61539

Browse files
committed
vrrp: Ensure VRRPv3 advert interval strictly <= 40.95 seconds
If an advert interval of 40.958 seconds was configured, it was being round up to 40.96 after the check that the advert interval was less than 40.96. The consequence of this was that adverts were being sent at 40.96 second intervals, but worse, the advert interval in the VRRP packet was set to 0. This commit now ensures that after the rounding the advert interval is <= 40.95 seconds. Signed-off-by: Quentin Armitage <[email protected]>
1 parent 027234e commit cf61539

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

keepalived/vrrp/vrrp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,10 +1852,8 @@ vrrp_state_leave_fault(vrrp_t * vrrp)
18521852
vrrp->state = vrrp->wantstate;
18531853
send_instance_notifies(vrrp);
18541854

1855-
if (vrrp->state == VRRP_STATE_BACK) {
1855+
if (vrrp->state == VRRP_STATE_BACK)
18561856
vrrp->preempt_time.tv_sec = 0;
1857-
vrrp->master_adver_int = vrrp->adver_int;
1858-
}
18591857
}
18601858

18611859
/* Set the down timer */
@@ -3346,8 +3344,11 @@ vrrp_complete_instance(vrrp_t * vrrp)
33463344
vrrp->adver_int = vrrp->adver_int + (TIMER_CENTI_HZ / 2);
33473345
vrrp->adver_int -= vrrp->adver_int % TIMER_CENTI_HZ;
33483346

3347+
/* Ensure don't round outside [0.01,40.95] */
33493348
if (vrrp->adver_int == 0)
33503349
vrrp->adver_int = TIMER_CENTI_HZ;
3350+
else if (vrrp->adver_int == (1<<12) * TIMER_CENTI_HZ)
3351+
vrrp->adver_int = ((1<<12) - 1) * TIMER_CENTI_HZ;
33513352
}
33523353
}
33533354
vrrp->master_adver_int = vrrp->adver_int;

0 commit comments

Comments
 (0)