forked from Mirror/frr
lib: small BFD session notifier improvement
Cache current monotime to avoid unnecessary calls. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
parent
a099abe55b
commit
3e6376b813
|
@ -1079,6 +1079,7 @@ static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS)
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
int remote_cbit = false;
|
int remote_cbit = false;
|
||||||
int state = BFD_STATUS_UNKNOWN;
|
int state = BFD_STATUS_UNKNOWN;
|
||||||
|
time_t now;
|
||||||
size_t addrlen;
|
size_t addrlen;
|
||||||
struct prefix dp;
|
struct prefix dp;
|
||||||
struct prefix sp;
|
struct prefix sp;
|
||||||
|
@ -1119,6 +1120,9 @@ static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Cache current time to avoid multiple monotime clock calls. */
|
||||||
|
now = monotime(NULL);
|
||||||
|
|
||||||
/* Notify all matching sessions about update. */
|
/* Notify all matching sessions about update. */
|
||||||
TAILQ_FOREACH (bsp, &bsglobal.bsplist, entry) {
|
TAILQ_FOREACH (bsp, &bsglobal.bsplist, entry) {
|
||||||
/* Skip disabled or not installed entries. */
|
/* 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)
|
if ((int)bsp->bss.state == state)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bsp->bss.last_event = monotime(NULL);
|
bsp->bss.last_event = now;
|
||||||
bsp->bss.previous_state = bsp->bss.state;
|
bsp->bss.previous_state = bsp->bss.state;
|
||||||
bsp->bss.state = state;
|
bsp->bss.state = state;
|
||||||
bsp->bss.remote_cbit = remote_cbit;
|
bsp->bss.remote_cbit = remote_cbit;
|
||||||
|
|
Loading…
Reference in a new issue