fix show session verbose crash with quic transport 65/19765/2
authorDave Wallace <dwallacelf@gmail.com>
Wed, 22 May 2019 23:12:09 +0000 (19:12 -0400)
committerFlorin Coras <florin.coras@gmail.com>
Thu, 23 May 2019 04:17:40 +0000 (04:17 +0000)
Type: fix

Change-Id: I8199c233f6968ac147fb1867a4f10ef04d67642f
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
src/plugins/quic/quic.c

index dbbc8c4..ca48a90 100644 (file)
@@ -1373,10 +1373,49 @@ quic_listener_get (u32 listener_index)
   return &ctx->connection;
 }
 
+static u8 *
+format_quic_ctx (u8 * s, va_list * args)
+{
+  quic_ctx_t *ctx = va_arg (*args, quic_ctx_t *);
+  u32 verbose = va_arg (*args, u32);
+
+  if (!ctx)
+    return s;
+  s = format (s, "[#%d][%s] ", ctx->c_thread_index, "Q");
+
+  if (ctx->is_listener)
+    {
+      s = format (s, "%s Listener: ", ctx->c_quic_ctx_id.is_stream ?
+                 "Stream" : "QSession");
+      if (verbose)
+       s = format (s, "app %d wrk %d", ctx->c_quic_ctx_id.parent_app_id,
+                   ctx->c_quic_ctx_id.parent_app_wrk_id);
+    }
+  else
+    {
+      if (ctx->c_is_ip4)
+       s = format (s, "%U:%d->%U:%d", format_ip4_address, &ctx->c_lcl_ip4,
+                   clib_net_to_host_u16 (ctx->c_lcl_port),
+                   format_ip4_address, &ctx->c_rmt_ip4,
+                   clib_net_to_host_u16 (ctx->c_rmt_port));
+      else
+       s = format (s, "%U:%d->%U:%d", format_ip6_address, &ctx->c_lcl_ip6,
+                   clib_net_to_host_u16 (ctx->c_lcl_port),
+                   format_ip6_address, &ctx->c_rmt_ip6,
+                   clib_net_to_host_u16 (ctx->c_rmt_port));
+    }
+  return s;
+}
+
 static u8 *
 format_quic_connection (u8 * s, va_list * args)
 {
-  s = format (s, "[QUIC] connection"); /* TODO */
+  u32 qc_index = va_arg (*args, u32);
+  u32 thread_index = va_arg (*args, u32);
+  u32 verbose = va_arg (*args, u32);
+  quic_ctx_t *ctx = quic_ctx_get (qc_index, thread_index);
+  if (ctx)
+    s = format (s, "%-50U", format_quic_ctx, ctx, verbose);
   return s;
 }
 
@@ -1393,7 +1432,14 @@ format_quic_half_open (u8 * s, va_list * args)
 static u8 *
 format_quic_listener (u8 * s, va_list * args)
 {
-  s = format (s, "[QUIC] listener");   /*  TODO */
+  u32 tci = va_arg (*args, u32);
+  u32 verbose = va_arg (*args, u32);
+  quic_ctx_t *ctx = quic_ctx_get (tci, vlib_get_thread_index ());
+  if (ctx)
+    {
+      ASSERT (ctx->is_listener);
+      s = format (s, "%-50U", format_quic_ctx, ctx, verbose);
+    }
   return s;
 }