From 26cac364ffbc76c2122bf4541b49aa9b81309c65 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Tue, 10 Jun 2025 04:48:06 -0400 Subject: [PATCH] vcl: fix read on closed sessions with mt apps Apps like iperf can have a thread close a session that another thread selects/epolls. Make sure to return error when that happens. Type: fix Change-Id: I586f8077431a28e7d8d3e4f21e45efcc035698ba Signed-off-by: Florin Coras --- src/vcl/ldp.c | 4 +++- src/vcl/vppcom.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c index b4978bf1a81..7e4cddbb46d 100644 --- a/src/vcl/ldp.c +++ b/src/vcl/ldp.c @@ -661,7 +661,9 @@ ldp_select_init_maps (fd_set * __restrict original, { vlsh_to_session_and_worker_index (vlsh, &session_index, &wrk_index); if (wrk_index != vppcom_worker_index ()) - clib_warning ("migration currently not supported"); + clib_warning ( + "migration for %d vlsh %d from %d to %d not supported", fd, vlsh, + wrk_index, vppcom_worker_index ()); else *vclb = clib_bitmap_set (*vclb, session_index, 1); } diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index 0e52a26dc96..9aff1e6ccd3 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -617,6 +617,7 @@ vcl_session_unlisten_reply_handler (vcl_worker_t * wrk, void *data) if (mp->context != wrk->wrk_index) VDBG (0, "wrong context"); + VDBG (0, "unlisten reply freeing %d[0x%llx]", s->session_index, mp->handle); vcl_session_table_del_vpp_handle (wrk, mp->handle); vcl_session_free (wrk, s); } @@ -2123,7 +2124,9 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n, s->session_index, s->vpp_handle, s->session_state, vcl_session_state_str (s->session_state)); rx_fifo = vcl_session_is_ct (s) ? s->ct_rx_fifo : s->rx_fifo; - if (svm_fifo_is_empty_cons (rx_fifo)) + /* If application closed, e.g., mt app, or no data return error */ + if (s->session_state == VCL_STATE_CLOSED || + svm_fifo_is_empty_cons (rx_fifo)) return vcl_session_closed_error (s); } -- 2.16.6