summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@opensourcerouting.org>2019-10-11 13:12:26 -0300
committerRafael Zalamena <rzalamena@opensourcerouting.org>2019-10-11 16:12:49 -0300
commit8ee0862e80da186dcae93311c22e17783cdd723c (patch)
tree8f230b628eda0c19871cd3cf7f5d92afa27ecf5e
parent507d75d4532c9ed3be5b4f232ae1a0f434f97d83 (diff)
bfdd: set session down after disabling it
If a session is no longer able to send/receive packets, it is very likely it will be down in a few milliseconds so lets speed up the process and correctly mark it as down. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
-rw-r--r--bfdd/bfd.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/bfdd/bfd.c b/bfdd/bfd.c
index c15391c654..072f44dc3b 100644
--- a/bfdd/bfd.c
+++ b/bfdd/bfd.c
@@ -213,10 +213,13 @@ void bfd_session_disable(struct bfd_session *bs)
/* Disable all timers. */
bfd_recvtimer_delete(bs);
- bfd_echo_recvtimer_delete(bs);
bfd_xmttimer_delete(bs);
- bfd_echo_xmttimer_delete(bs);
+ ptm_bfd_echo_stop(bs);
bs->vrf = NULL;
+ bs->ifp = NULL;
+
+ /* Set session down so it doesn't report UP and disabled. */
+ ptm_bfd_sess_dn(bs, BD_PATH_DOWN);
}
static uint32_t ptm_bfd_gen_ID(void)
@@ -329,7 +332,14 @@ void ptm_bfd_sess_dn(struct bfd_session *bfd, uint8_t diag)
bfd->demand_mode = 0;
monotime(&bfd->downtime);
- ptm_bfd_snd(bfd, 0);
+ /*
+ * Only attempt to send if we have a valid socket:
+ * this function might be called by session disablers and in
+ * this case we won't have a valid socket (i.e. interface was
+ * removed or VRF doesn't exist anymore).
+ */
+ if (bfd->sock != -1)
+ ptm_bfd_snd(bfd, 0);
/* Slow down the control packets, the connection is down. */
bs_set_slow_timers(bfd);