From 8d42c75d6c88be62ac7eed03f10305bba3423f7c Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Mon, 29 Nov 2021 23:26:19 -0800 Subject: [PATCH] vcl: improve handling of failed connects Type: improvement Signed-off-by: Florin Coras Change-Id: If6235888cb0870ec3e1279ab1856a00715bd6c68 --- src/vcl/vppcom.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index d23b0656b29..ce4513c8014 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -389,8 +389,8 @@ vcl_session_connected_handler (vcl_worker_t * wrk, session = vcl_session_get (wrk, session_index); if (PREDICT_FALSE (!session)) { - VDBG (0, "ERROR: vpp handle 0x%llx has no session index (%u)!", - mp->handle, session_index); + VERR ("vpp handle 0x%llx has no session index (%u)!", mp->handle, + session_index); /* Should not happen but if it does, force vpp session cleanup */ vcl_session_t tmp_session = { .vpp_handle = mp->handle, @@ -403,23 +403,29 @@ vcl_session_connected_handler (vcl_worker_t * wrk, vcl_send_session_disconnect (wrk, &tmp_session); return VCL_INVALID_SESSION_INDEX; } + if (mp->retval) { - VDBG (0, "ERROR: session index %u: connect failed! %U", - session_index, format_session_error, mp->retval); + VDBG (0, "session index %u: connect failed! %U", session_index, + format_session_error, mp->retval); session->session_state = VCL_STATE_DETACHED; - session->vpp_handle = mp->handle; + session->vpp_handle = VCL_INVALID_SESSION_HANDLE; return session_index; } session->vpp_handle = mp->handle; + /* Add to lookup table. Even if something fails, session cannot be + * cleaned up prior to notifying vpp and going through the cleanup + * "procedure" see @ref vcl_session_cleanup_handler */ + vcl_session_table_add_vpp_handle (wrk, mp->handle, session_index); + if (vcl_segment_attach_session ( mp->segment_handle, mp->server_rx_fifo, mp->server_tx_fifo, mp->vpp_event_queue_address, mp->mq_index, 0, session)) { VDBG (0, "failed to attach fifos for %u", session->session_index); - session->session_state = VCL_STATE_DETACHED; + session->session_state = VCL_STATE_UPDATED; vcl_send_session_disconnect (wrk, session); return session_index; } @@ -431,7 +437,7 @@ vcl_session_connected_handler (vcl_worker_t * wrk, session)) { VDBG (0, "failed to attach ct fifos for %u", session->session_index); - session->session_state = VCL_STATE_DETACHED; + session->session_state = VCL_STATE_UPDATED; vcl_send_session_disconnect (wrk, session); return session_index; } @@ -449,9 +455,6 @@ vcl_session_connected_handler (vcl_worker_t * wrk, else session->session_state = VCL_STATE_READY; - /* Add it to lookup table */ - vcl_session_table_add_vpp_handle (wrk, mp->handle, session_index); - VDBG (1, "session %u [0x%llx] connected! rx_fifo %p, refcnt %d, tx_fifo %p," " refcnt %d", session_index, mp->handle, session->rx_fifo, session->rx_fifo->refcnt, session->tx_fifo, session->tx_fifo->refcnt); -- 2.16.6