]> git.proxmox.com Git - mirror_frr.git/blobdiff - bfdd/bfd.c
Merge pull request #12397 from opensourcerouting/vscode-intro
[mirror_frr.git] / bfdd / bfd.c
index a161926358887de07924d9b2d8ef3a27f5574552..4367f253e11955f4e8a418c6681b12c2a278941a 100644 (file)
@@ -348,7 +348,7 @@ int bfd_session_enable(struct bfd_session *bs)
        /* Sanity check: don't leak open sockets. */
        if (bs->sock != -1) {
                if (bglobal.debug_peer_event)
-                       zlog_debug("session-enable: previous socket open");
+                       zlog_debug("%s: previous socket open", __func__);
 
                close(bs->sock);
                bs->sock = -1;
@@ -381,6 +381,9 @@ int bfd_session_enable(struct bfd_session *bs)
                ptm_bfd_start_xmt_timer(bs, false);
        }
 
+       /* initialize RTT */
+       bfd_rtt_init(bs);
+
        return 0;
 }
 
@@ -574,6 +577,9 @@ void ptm_bfd_sess_dn(struct bfd_session *bfd, uint8_t diag)
        memset(bfd->peer_hw_addr, 0, sizeof(bfd->peer_hw_addr));
        /* reset local address ,it might has been be changed after bfd is up*/
        memset(&bfd->local_address, 0, sizeof(bfd->local_address));
+
+       /* reset RTT */
+       bfd_rtt_init(bfd);
 }
 
 static struct bfd_session *bfd_find_disc(struct sockaddr_any *sa,
@@ -946,7 +952,7 @@ int ptm_bfd_sess_del(struct bfd_peer_cfg *bpc)
        }
 
        if (bglobal.debug_peer_event)
-               zlog_debug("session-delete: %s", bs_to_string(bs));
+               zlog_debug("%s: %s", __func__, bs_to_string(bs));
 
        control_notify_config(BCM_NOTIFY_CONFIG_DELETE, bs);
 
@@ -2063,3 +2069,14 @@ unsigned long bfd_get_session_count(void)
 {
        return bfd_key_hash->count;
 }
+
+void bfd_rtt_init(struct bfd_session *bfd)
+{
+       uint8_t i;
+
+       /* initialize RTT */
+       bfd->rtt_valid = 0;
+       bfd->rtt_index = 0;
+       for (i = 0; i < BFD_RTT_SAMPLE; i++)
+               bfd->rtt[i] = 0;
+}