From: Florin Coras Date: Thu, 23 Oct 2025 05:11:54 +0000 (-0400) Subject: http: h2 handle connect init errors X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F27%2F43927%2F5;p=vpp.git http: h2 handle connect init errors Type: fix Change-Id: Ia8a27b3066de9fc49bcb5c0ae6c18845ce2eea70 Signed-off-by: Florin Coras Signed-off-by: Matus Fabian --- diff --git a/src/plugins/http/http2/http2.c b/src/plugins/http/http2/http2.c index 286c1fc9a55..ed65ca1a241 100644 --- a/src/plugins/http/http2/http2.c +++ b/src/plugins/http/http2/http2.c @@ -469,11 +469,16 @@ http2_connection_error (http_conn_t *hc, http2_error_t error, app_worker_connect_notify (app_wrk, 0, SESSION_E_UNKNOWN, hc->hc_pa_app_api_ctx); } - else + else if (!(hc->flags & HTTP_CONN_F_NO_APP_SESSION)) { req = http2_req_get (h2c->parent_req_index, hc->c_thread_index); session_transport_reset_notify (&req->base.connection); } + else + { + http_disconnect_transport (hc); + return; + } } if (clib_llist_elt_is_linked (h2c, sched_list)) clib_llist_remove (wrk->conn_pool, sched_list, h2c); diff --git a/src/plugins/http/http_private.h b/src/plugins/http/http_private.h index 14b24b17b91..7a823d2aa1e 100644 --- a/src/plugins/http/http_private.h +++ b/src/plugins/http/http_private.h @@ -903,6 +903,14 @@ http_conn_established (http_conn_t *hc, http_req_t *req, /* in chain with TLS there is race on half-open cleanup */ __atomic_fetch_or (&ho_hc->flags, HTTP_CONN_F_HO_DONE, __ATOMIC_RELEASE); + app_wrk = app_worker_get_if_valid (hc->hc_pa_wrk_index); + if (!app_wrk) + { + HTTP_DBG (1, "no app worker"); + req->c_s_index = SESSION_INVALID_INDEX; + return -1; + } + /* allocate app session and initialize */ as = session_alloc (hc->c_thread_index); HTTP_DBG (1, "allocated session 0x%lx", session_handle (as)); @@ -916,19 +924,11 @@ http_conn_established (http_conn_t *hc, http_req_t *req, TRANSPORT_PROTO_HTTP, session_type_is_ip4 (ts->session_type)); /* init session fifos and notify app */ - app_wrk = app_worker_get_if_valid (hc->hc_pa_wrk_index); - if (!app_wrk) - { - HTTP_DBG (1, "no app worker"); - hc->flags |= HTTP_CONN_F_NO_APP_SESSION; - return -1; - } - if ((rv = app_worker_init_connected (app_wrk, as))) { HTTP_DBG (1, "failed to allocate fifos"); session_free (as); - hc->flags |= HTTP_CONN_F_NO_APP_SESSION; + req->c_s_index = SESSION_INVALID_INDEX; app_worker_connect_notify (app_wrk, 0, rv, parent_app_api_ctx); return rv; } @@ -936,6 +936,7 @@ http_conn_established (http_conn_t *hc, http_req_t *req, app_worker_connect_notify (app_wrk, as, 0, parent_app_api_ctx); req->hr_pa_wrk_index = as->app_wrk_index; + hc->flags &= ~HTTP_CONN_F_NO_APP_SESSION; return 0; }