diff options
author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2021-03-02 12:52:35 +0100 |
---|---|---|
committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2021-03-23 16:40:09 +0100 |
commit | 3e6376b813fc38a7588ce1d0624b9fea4ad2ba9f (patch) | |
tree | b94b99acfaca1f39368187f25384357a0aa1cfa4 /lib/bfd.c | |
parent | lib: new BFD integration API (diff) | |
download | frr-3e6376b813fc38a7588ce1d0624b9fea4ad2ba9f.tar.xz frr-3e6376b813fc38a7588ce1d0624b9fea4ad2ba9f.zip |
lib: small BFD session notifier improvement
Cache current monotime to avoid unnecessary calls.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'lib/bfd.c')
-rw-r--r-- | lib/bfd.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1079,6 +1079,7 @@ static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS) struct interface *ifp; int remote_cbit = false; int state = BFD_STATUS_UNKNOWN; + time_t now; size_t addrlen; struct prefix dp; struct prefix sp; @@ -1119,6 +1120,9 @@ static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS) break; } + /* Cache current time to avoid multiple monotime clock calls. */ + now = monotime(NULL); + /* Notify all matching sessions about update. */ TAILQ_FOREACH (bsp, &bsglobal.bsplist, entry) { /* Skip disabled or not installed entries. */ @@ -1151,7 +1155,7 @@ static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS) if ((int)bsp->bss.state == state) continue; - bsp->bss.last_event = monotime(NULL); + bsp->bss.last_event = now; bsp->bss.previous_state = bsp->bss.state; bsp->bss.state = state; bsp->bss.remote_cbit = remote_cbit; |