diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-12-08 01:49:35 +0100 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-05-17 02:27:08 +0200 |
commit | 3e7a4043ff23b77901b5a3ccd980efac577bb59d (patch) | |
tree | da57da82c401fc19442f6a275757003bf9ae7457 /vrrpd/vrrp.c | |
parent | vrrpd: improve logging (diff) | |
download | frr-3e7a4043ff23b77901b5a3ccd980efac577bb59d.tar.xz frr-3e7a4043ff23b77901b5a3ccd980efac577bb59d.zip |
vrrpd: handle rescheduling Adver_Timer, Shutdown
* Reschedule Adver_Timer when necessary
* Handle Shutdown event appropriately for all states
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to '')
-rw-r--r-- | vrrpd/vrrp.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c index 73493fc15..0fd5e2548 100644 --- a/vrrpd/vrrp.c +++ b/vrrpd/vrrp.c @@ -356,14 +356,20 @@ static int vrrp_adver_timer_expire(struct thread *thread) zlog_info(VRRP_LOGPFX VRRP_LOGPFX_VRID "Adver_Timer expired", vr->vrid); - if (vr->fsm.state == VRRP_STATE_BACKUP) { + if (vr->fsm.state == VRRP_STATE_MASTER) { + /* Send an ADVERTISEMENT */ vrrp_send_advertisement(vr); - /* FIXME: vrrp_send_gratuitous_arp(vr); */ - } else if (vr->fsm.state == VRRP_STATE_MASTER) { - } else if (vr->fsm.state == VRRP_STATE_INITIALIZE) { - assert(!"FUCK"); + /* Reset the Adver_Timer to Advertisement_Interval */ + thread_add_timer_msec(master, vrrp_adver_timer_expire, vr, + vr->advertisement_interval * 10, + &vr->t_adver_timer); + } else { + zlog_warn(VRRP_LOGPFX VRRP_LOGPFX_VRID + "Adver_Timer expired in state '%s'; this is a bug", + vr->vrid, vrrp_state_names[vr->fsm.state]); } + return 0; } @@ -443,13 +449,34 @@ static int vrrp_startup(struct vrrp_vrouter *vr) */ static int vrrp_shutdown(struct vrrp_vrouter *vr) { + switch (vr->fsm.state) { + case VRRP_STATE_MASTER: + /* Cancel the Adver_Timer */ + THREAD_OFF(vr->t_adver_timer); + /* Send an ADVERTISEMENT with Priority = 0 */ + uint8_t saved_prio = vr->priority; + vr->priority = 0; + vrrp_send_advertisement(vr); + vr->priority = saved_prio; + break; + case VRRP_STATE_BACKUP: + /* Cancel the Master_Down_Timer */ + THREAD_OFF(vr->t_master_down_timer); + break; + case VRRP_STATE_INITIALIZE: + zlog_info(VRRP_LOGPFX VRRP_LOGPFX_VRID + "Received '%s' event in '%s' state; ignoring", + vr->vrid, + vrrp_event_names[VRRP_EVENT_SHUTDOWN], + vrrp_state_names[VRRP_STATE_INITIALIZE]); + break; + } + /* close socket */ if (vr->sock >= 0) close(vr->sock); - /* cancel all threads */ - /* ... */ - + /* Transition to the Initialize state */ vrrp_change_state(vr, VRRP_STATE_INITIALIZE); return 0; |