http tls: fix half-open formatting 19/43919/3
authorFlorin Coras <[email protected]>
Wed, 22 Oct 2025 04:32:34 +0000 (00:32 -0400)
committerDave Barach <[email protected]>
Wed, 22 Oct 2025 19:13:58 +0000 (19:13 +0000)
Type: fix

Change-Id: I362a7070a6f5a89358bf01d6e9ab05df18c9ec6e
Signed-off-by: Florin Coras <[email protected]>
src/plugins/http/http.c
src/vnet/session/session_types.h
src/vnet/tls/tls.c

index 0ef19a5..5e6672c 100644 (file)
@@ -219,6 +219,7 @@ http_ho_conn_alloc (void)
   pool_get_aligned_safe (hm->ho_conn_pool, hc, CLIB_CACHE_LINE_BYTES);
   clib_memset (hc, 0, sizeof (*hc));
   hc->hc_hc_index = hc - hm->ho_conn_pool;
+  hc->c_thread_index = transport_cl_thread ();
   hc->hc_pa_session_handle = SESSION_INVALID_HANDLE;
   hc->hc_tc_session_handle = SESSION_INVALID_HANDLE;
   hc->timeout = HTTP_CONN_TIMEOUT;
@@ -1376,6 +1377,19 @@ format_http_transport_listener (u8 *s, va_list *args)
   return s;
 }
 
+static u8 *
+format_http_ho_conn_id (u8 *s, va_list *args)
+{
+  http_conn_t *ho_hc = va_arg (*args, http_conn_t *);
+
+  s = format (s, "[%d:%d][H] half-open app_wrk %u ts %d:%d",
+             ho_hc->c_thread_index, ho_hc->c_s_index, ho_hc->hc_pa_wrk_index,
+             session_thread_from_handle (ho_hc->hc_tc_session_handle),
+             session_index_from_handle (ho_hc->hc_tc_session_handle));
+
+  return s;
+}
+
 static u8 *
 format_http_transport_half_open (u8 *s, va_list *args)
 {
@@ -1383,20 +1397,17 @@ format_http_transport_half_open (u8 *s, va_list *args)
   u32 __clib_unused thread_index = va_arg (*args, u32);
   u32 __clib_unused verbose = va_arg (*args, u32);
   http_conn_t *ho_hc;
-  session_t *tcp_ho;
 
   ho_hc = http_ho_conn_get (ho_index);
-  tcp_ho = session_get_from_handle_if_valid (ho_hc->hc_tc_session_handle);
 
-  if (tcp_ho)
-    s =
-      format (s, "[%d:%d][H] half-open app_wrk %u ts %d:%d",
-             ho_hc->c_thread_index, ho_hc->c_s_index, ho_hc->hc_pa_wrk_index,
-             tcp_ho->thread_index, tcp_ho->session_index);
-  else
-    s =
-      format (s, "[%d:%d][H] half-open app_wrk %u (postponed cleanup)",
-             ho_hc->c_thread_index, ho_hc->c_s_index, ho_hc->hc_pa_wrk_index);
+  s = format (s, "%-" SESSION_CLI_ID_LEN "U", format_http_ho_conn_id, ho_hc);
+
+  if (verbose)
+    s = format (s, "%-" SESSION_CLI_STATE_LEN "s",
+               (ho_hc->hc_tc_session_handle == SESSION_INVALID_HANDLE) ?
+                 (ho_hc->flags & HTTP_CONN_F_HO_DONE) ? "CLOSED" :
+                                                        "CLOSED-PNDG" :
+                 "CONNECTING");
 
   return s;
 }
index a75e21c..147c00a 100644 (file)
@@ -34,7 +34,7 @@ typedef union session_handle_tu_
   struct
   {
     u32 session_index;
-    clib_thread_index_t thread_index;
+    u32 thread_index;
   };
 } __attribute__ ((__transparent_union__)) session_handle_tu_t;
 
index 745c96c..8c5d817 100644 (file)
@@ -1049,16 +1049,21 @@ format_tls_half_open (u8 * s, va_list * args)
   u32 ho_index = va_arg (*args, u32);
   u32 __clib_unused thread_index = va_arg (*args, u32);
   u32 __clib_unused verbose = va_arg (*args, u32);
-  session_t *tcp_ho;
   tls_ctx_t *ho_ctx;
 
   ho_ctx = tls_ctx_half_open_get (ho_index);
 
-  tcp_ho = session_get_from_handle (ho_ctx->tls_session_handle);
   s = format (s, "[%d:%d][%s] half-open app_wrk %u engine %u ts %d:%d",
              ho_ctx->c_thread_index, ho_ctx->c_s_index, "TLS",
              ho_ctx->parent_app_wrk_index, ho_ctx->tls_ctx_engine,
-             tcp_ho->thread_index, tcp_ho->session_index);
+             session_thread_from_handle (ho_ctx->tls_session_handle),
+             session_index_from_handle (ho_ctx->tls_session_handle));
+  if (verbose)
+    s = format (
+      s, "%-" SESSION_CLI_STATE_LEN "s",
+      (ho_ctx->tls_session_handle == SESSION_INVALID_HANDLE) ?
+       ((ho_ctx->flags & TLS_CONN_F_HO_DONE) ? "CLOSED" : "CLOSED-PNDG") :
+       "CONNECTING");
 
   return s;
 }