diff options
author | Florin Coras <fcoras@cisco.com> | 2021-11-25 11:37:33 -0800 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2021-11-26 21:48:20 +0000 |
commit | c6eb7da390fbfaf5bd93ec22a9d2e60e0448d71c (patch) | |
tree | 07e097c9bd285ecca87b9b993d01a97ea0141cd9 /src/vnet/session/session_node.c | |
parent | 9439a3629754ba5a2722f41d1f49e59da59a8167 (diff) |
session: accept reply improvements
- Always check session ownership
- Improve test for main thread rpc
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I5fa60f7f5de199af0966987f9ce9a4cc8180cf98
Diffstat (limited to 'src/vnet/session/session_node.c')
-rw-r--r-- | src/vnet/session/session_node.c | 51 |
1 files 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; } } |