From c6eb7da390fbfaf5bd93ec22a9d2e60e0448d71c Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Thu, 25 Nov 2021 11:37:33 -0800 Subject: session: accept reply improvements - Always check session ownership - Improve test for main thread rpc Type: improvement Signed-off-by: Florin Coras Change-Id: I5fa60f7f5de199af0966987f9ce9a4cc8180cf98 --- src/vnet/session/session_node.c | 51 ++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index 7565b43b29b..1d7ebf9f11a 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -454,19 +454,10 @@ session_mq_accepted_reply_handler (void *data) app_worker_t *app_wrk; session_t *s; - /* Server isn't interested, kill the session */ - if (mp->retval) - { - a->app_index = mp->context; - a->handle = mp->handle; - vnet_disconnect_session (a); - return; - } - /* Mail this back from the main thread. We're not polling in main * thread so we're using other workers for notifications. */ - if (vlib_num_workers () && vlib_get_thread_index () != 0 - && session_thread_from_handle (mp->handle) == 0) + if (session_thread_from_handle (mp->handle) == 0 && vlib_num_workers () && + vlib_get_thread_index () != 0) { vlib_rpc_call_main_thread (session_mq_accepted_reply_handler, (u8 *) mp, sizeof (*mp)); @@ -484,27 +475,35 @@ session_mq_accepted_reply_handler (void *data) return; } - if (!session_has_transport (s)) + /* Server isn't interested, disconnect the session */ + if (mp->retval) { - s->session_state = SESSION_STATE_READY; - if (ct_session_connect_notify (s, SESSION_E_NONE)) - return; + a->app_index = mp->context; + a->handle = mp->handle; + vnet_disconnect_session (a); + return; } - else + + /* Special handling for cut-through sessions */ + if (!session_has_transport (s)) { - old_state = s->session_state; s->session_state = SESSION_STATE_READY; + ct_session_connect_notify (s, SESSION_E_NONE); + return; + } - if (!svm_fifo_is_empty_prod (s->rx_fifo)) - app_worker_lock_and_send_event (app_wrk, s, SESSION_IO_EVT_RX); + old_state = s->session_state; + s->session_state = SESSION_STATE_READY; - /* Closed while waiting for app to reply. Resend disconnect */ - if (old_state >= SESSION_STATE_TRANSPORT_CLOSING) - { - app_worker_close_notify (app_wrk, s); - s->session_state = old_state; - return; - } + if (!svm_fifo_is_empty_prod (s->rx_fifo)) + app_worker_lock_and_send_event (app_wrk, s, SESSION_IO_EVT_RX); + + /* Closed while waiting for app to reply. Resend disconnect */ + if (old_state >= SESSION_STATE_TRANSPORT_CLOSING) + { + app_worker_close_notify (app_wrk, s); + s->session_state = old_state; + return; } } -- cgit 1.2.3-korg