]> git.proxmox.com Git - mirror_frr.git/commitdiff
bfdd: slow down on peer connection loss
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Thu, 31 Jan 2019 20:36:44 +0000 (18:36 -0200)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Thu, 14 Feb 2019 16:17:29 +0000 (14:17 -0200)
Lets be more RFC 5880 compliant and slow down control packets on
connection loss.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
bfdd/bfd.c
bfdd/bfd.h

index 53d8601e9ce6c8a0994eff4a929a6575c1e9ad2c..ea3a586f95b08afde19d6dfe273cd9aebca1804e 100644 (file)
@@ -191,6 +191,9 @@ void ptm_bfd_ses_dn(struct bfd_session *bfd, uint8_t diag)
 
        ptm_bfd_snd(bfd, 0);
 
+       /* Slow down the control packets, the connection is down. */
+       bs_set_slow_timers(bfd);
+
        /* only signal clients when going from up->down state */
        if (old_state == PTM_BFD_UP)
                control_notify(bfd);
@@ -369,18 +372,8 @@ static struct bfd_session *bfd_session_new(int sd)
        bs->detect_mult = BFD_DEFDETECTMULT;
        bs->mh_ttl = BFD_DEF_MHOP_TTL;
 
-       /*
-        * BFD connection startup must use slow timer.
-        *
-        * RFC 5880, Section 6.8.3.
-        */
-       bs->cur_timers.desired_min_tx = BFD_DEF_SLOWTX;
-       bs->cur_timers.required_min_rx = BFD_DEF_SLOWTX;
-       bs->cur_timers.required_min_echo = 0;
-
-       /* Set the appropriated timeouts for slow connection. */
-       bs->detect_TO = (BFD_DEFDETECTMULT * BFD_DEF_SLOWTX);
-       bs->xmt_TO = BFD_DEF_SLOWTX;
+       /* Initiate connection with slow timers. */
+       bs_set_slow_timers(bs);
 
        /* Initiate remote settings as well. */
        bs->remote_timers = bs->cur_timers;
@@ -923,6 +916,22 @@ void bs_final_handler(struct bfd_session *bs)
        control_notify_config(BCM_NOTIFY_CONFIG_UPDATE, bs);
 }
 
+void bs_set_slow_timers(struct bfd_session *bs)
+{
+       /*
+        * BFD connection must use slow timers before going up or after
+        * losing connectivity to avoid wasting bandwidth.
+        *
+        * RFC 5880, Section 6.8.3.
+        */
+       bs->cur_timers.desired_min_tx = BFD_DEF_SLOWTX;
+       bs->cur_timers.required_min_rx = BFD_DEF_SLOWTX;
+       bs->cur_timers.required_min_echo = 0;
+
+       /* Set the appropriated timeouts for slow connection. */
+       bs->detect_TO = (BFD_DEFDETECTMULT * BFD_DEF_SLOWTX);
+       bs->xmt_TO = BFD_DEF_SLOWTX;
+}
 
 /*
  * Helper functions.
index e6fb25da0d366e85b0433e508c769d7a570c0188..2cd2b87a1f85645784e6584a13c84b5e3827aeab 100644 (file)
@@ -527,6 +527,7 @@ void bfd_set_polling(struct bfd_session *bs);
 void bs_state_handler(struct bfd_session *, int);
 void bs_echo_timer_handler(struct bfd_session *);
 void bs_final_handler(struct bfd_session *);
+void bs_set_slow_timers(struct bfd_session *bs);
 const char *satostr(struct sockaddr_any *sa);
 const char *diag2str(uint8_t diag);
 int strtosa(const char *addr, struct sockaddr_any *sa);