From 0db9b04cf0f9c892a00988e7a61ae703aa83b721 Mon Sep 17 00:00:00 2001 From: Eyal Bari Date: Thu, 11 Oct 2018 14:09:58 +0300 Subject: bfd:fix handling session creation batch when multiple session creating script is ran (via exec) only the first one actually starts Change-Id: I0fc36f65795c8921cf180e0b555c446e5a80be45 Signed-off-by: Eyal Bari --- src/vnet/bfd/bfd_main.c | 61 +++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'src/vnet/bfd') diff --git a/src/vnet/bfd/bfd_main.c b/src/vnet/bfd/bfd_main.c index 55ea23dea41..bd2addf3b0f 100644 --- a/src/vnet/bfd/bfd_main.c +++ b/src/vnet/bfd/bfd_main.c @@ -1165,6 +1165,7 @@ bfd_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) } } now = clib_cpu_time_now (); + uword *session_index; switch (event_type) { case ~0: /* no events => timeout */ @@ -1180,35 +1181,41 @@ bfd_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) * each event or timeout */ break; case BFD_EVENT_NEW_SESSION: - bfd_lock (bm); - if (!pool_is_free_index (bm->sessions, *event_data)) - { - bfd_session_t *bs = - pool_elt_at_index (bm->sessions, *event_data); - bfd_send_periodic (vm, rt, bm, bs, now); - bfd_set_timer (bm, bs, now, 1); - } - else - { - BFD_DBG ("Ignoring event for non-existent session index %u", - (u32) * event_data); - } - bfd_unlock (bm); + vec_foreach (session_index, event_data) + { + bfd_lock (bm); + if (!pool_is_free_index (bm->sessions, *session_index)) + { + bfd_session_t *bs = + pool_elt_at_index (bm->sessions, *session_index); + bfd_send_periodic (vm, rt, bm, bs, now); + bfd_set_timer (bm, bs, now, 1); + } + else + { + BFD_DBG ("Ignoring event for non-existent session index %u", + (u32) * session_index); + } + bfd_unlock (bm); + } break; case BFD_EVENT_CONFIG_CHANGED: - bfd_lock (bm); - if (!pool_is_free_index (bm->sessions, *event_data)) - { - bfd_session_t *bs = - pool_elt_at_index (bm->sessions, *event_data); - bfd_on_config_change (vm, rt, bm, bs, now); - } - else - { - BFD_DBG ("Ignoring event for non-existent session index %u", - (u32) * event_data); - } - bfd_unlock (bm); + vec_foreach (session_index, event_data) + { + bfd_lock (bm); + if (!pool_is_free_index (bm->sessions, *session_index)) + { + bfd_session_t *bs = + pool_elt_at_index (bm->sessions, *session_index); + bfd_on_config_change (vm, rt, bm, bs, now); + } + else + { + BFD_DBG ("Ignoring event for non-existent session index %u", + (u32) * session_index); + } + bfd_unlock (bm); + } break; default: vlib_log_err (bm->log_class, "BUG: event type 0x%wx", event_type); -- cgit 1.2.3-korg