diff options
author | Florin Coras <fcoras@cisco.com> | 2023-10-06 16:45:04 -0700 |
---|---|---|
committer | Florin Coras <fcoras@cisco.com> | 2023-10-07 10:03:56 -0700 |
commit | 9ffec14a2202e1268c4a2f189c39a90986090a25 (patch) | |
tree | 2b0849d65bcb6254a8648356fa4591308cbe705b | |
parent | 589fe7ca61111d742ed2e6249728eb54423bab16 (diff) |
session: handle accept and connect errors
If builtin apps refuse connections, they should be cleaned up.
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I95ef22902ac3fe873e15e250aa5f03031c2dc0c4
-rw-r--r-- | src/vnet/session/session_input.c | 34 | ||||
-rw-r--r-- | src/vnet/session/session_node.c | 1 |
2 files changed, 29 insertions, 6 deletions
diff --git a/src/vnet/session/session_input.c b/src/vnet/session/session_input.c index 2c89c31a827..cdd6a884949 100644 --- a/src/vnet/session/session_input.c +++ b/src/vnet/session/session_input.c @@ -77,10 +77,11 @@ app_worker_flush_events_inline (app_worker_t *app_wrk, u32 thread_index, { application_t *app = application_get (app_wrk->app_index); svm_msg_q_t *mq = app_wrk->event_queue; + u8 ring_index, mq_is_cong, was_closed; session_event_t *evt; u32 n_evts = 128, i; - u8 ring_index, mq_is_cong; session_t *s; + int rv; n_evts = clib_min (n_evts, clib_fifo_elts (app_wrk->wrk_evts[thread_index])); @@ -145,16 +146,37 @@ app_worker_flush_events_inline (app_worker_t *app_wrk, u32 thread_index, break; case SESSION_CTRL_EVT_ACCEPTED: s = session_get (evt->session_index, thread_index); - app->cb_fns.session_accept_callback (s); + was_closed = s->session_state >= SESSION_STATE_TRANSPORT_CLOSING; + if (app->cb_fns.session_accept_callback (s)) + { + session_close (s); + s->app_wrk_index = SESSION_INVALID_INDEX; + break; + } + if (is_builtin && was_closed) + app_worker_close_notify (app_wrk, s); break; case SESSION_CTRL_EVT_CONNECTED: if (!(evt->as_u64[1] & 0xffffffff)) - s = session_get (evt->session_index, thread_index); + { + s = session_get (evt->session_index, thread_index); + was_closed = s->session_state >= SESSION_STATE_TRANSPORT_CLOSING; + } else s = 0; - app->cb_fns.session_connected_callback (app_wrk->wrk_index, - evt->as_u64[1] >> 32, s, - evt->as_u64[1] & 0xffffffff); + rv = app->cb_fns.session_connected_callback ( + app_wrk->wrk_index, evt->as_u64[1] >> 32, s, + evt->as_u64[1] & 0xffffffff); + if (!s) + break; + if (rv) + { + session_close (s); + s->app_wrk_index = SESSION_INVALID_INDEX; + break; + } + if (was_closed) + app_worker_close_notify (app_wrk, s); break; case SESSION_CTRL_EVT_DISCONNECTED: s = session_get (evt->session_index, thread_index); diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index 4f2cae4d196..d27b804550a 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -456,6 +456,7 @@ session_mq_accepted_reply_handler (session_worker_t *wrk, a->app_index = mp->context; a->handle = mp->handle; vnet_disconnect_session (a); + s->app_wrk_index = SESSION_INVALID_INDEX; return; } |