lib: fix possible crash on BFD notification

Allow sessions to remove themselves from the notifications without
risking crashes.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
Rafael Zalamena 2021-04-12 17:59:52 -03:00
parent b38f1fd03d
commit 464e6541b1

View File

@ -1080,7 +1080,7 @@ static int zclient_bfd_session_reply(ZAPI_CALLBACK_ARGS)
static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS)
{
struct bfd_session_params *bsp;
struct bfd_session_params *bsp, *bspn;
size_t sessions_updated = 0;
struct interface *ifp;
int remote_cbit = false;
@ -1137,7 +1137,7 @@ static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS)
now = monotime(NULL);
/* Notify all matching sessions about update. */
TAILQ_FOREACH (bsp, &bsglobal.bsplist, entry) {
TAILQ_FOREACH_SAFE (bsp, &bsglobal.bsplist, entry, bspn) {
/* Skip not installed entries. */
if (!bsp->installed)
continue;