From a468fd7e586e93989355648778edb912ef258f23 Mon Sep 17 00:00:00 2001 From: Steven Luong Date: Wed, 8 Mar 2023 16:28:27 -0800 Subject: [PATCH] session: Use session->thread_index to correctly retrieve the session For non-connected udp, when retrieving the subscriber session to send the notification, it uses the current worker thread index whereas the subscriber session is actually on the main thread. Using the worker thread may cause a crash since the corresponding session may not be valid in the worker thread context and even if it is valid, it is the wrong session. This scenario is seen when the application forks and adds subscribers to the worker thread session. Type: fix Signed-off-by: Steven Luong Change-Id: I236ee9d9ff9f3b2f7f9f8e782d70d1080aa1b627 --- src/vnet/session/session.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index b0dbb9ddfe8..3747c8719ed 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -728,8 +728,10 @@ session_enqueue_notify_inline (session_t * s) app_worker_t *app_wrk; u32 session_index; u8 n_subscribers; + u32 thread_index; session_index = s->session_index; + thread_index = s->thread_index; n_subscribers = svm_fifo_n_subscribers (s->rx_fifo); app_wrk = app_worker_get_if_valid (s->app_wrk_index); @@ -753,7 +755,7 @@ session_enqueue_notify_inline (session_t * s) if (PREDICT_FALSE (n_subscribers)) { - s = session_get (session_index, vlib_get_thread_index ()); + s = session_get (session_index, thread_index); return session_notify_subscribers (app_wrk->app_index, s, s->rx_fifo, SESSION_IO_EVT_RX); } -- 2.16.6