]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3: define h3 trace module
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 May 2022 13:49:36 +0000 (15:49 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 May 2022 15:34:51 +0000 (17:34 +0200)
A new 'h3' trace module is introduced. It will be used to centralize
events related to HTTP/3 status.

src/h3.c

index 3ff45ffe1c382b90c95a190a8a9a072edb85a8cf..9627e0ba4a3104b700868709e05f65c6c90d108b 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
 #include <haproxy/quic_enc.h>
 #include <haproxy/stconn.h>
 #include <haproxy/tools.h>
+#include <haproxy/trace.h>
 #include <haproxy/xprt_quic.h>
 
+/* trace source and events */
+static void h3_trace(enum trace_level level, uint64_t mask,
+                     const struct trace_source *src,
+                     const struct ist where, const struct ist func,
+                     const void *a1, const void *a2, const void *a3, const void *a4);
+
+static const struct trace_event h3_trace_events[] = {
+       { }
+};
+
+static const struct name_desc h3_trace_lockon_args[4] = {
+       /* arg1 */ { /* already used by the connection */ },
+       /* arg2 */ { .name="qcs", .desc="QUIC stream" },
+       /* arg3 */ { },
+       /* arg4 */ { }
+};
+
+static const struct name_desc h3_trace_decoding[] = {
+#define H3_VERB_CLEAN    1
+       { .name="clean",    .desc="only user-friendly stuff, generally suitable for level \"user\"" },
+#define H3_VERB_MINIMAL  2
+       { .name="minimal",  .desc="report only qcc/qcs state and flags, no real decoding" },
+       { /* end */ }
+};
+
+struct trace_source trace_h3 = {
+       .name = IST("h3"),
+       .desc = "HTTP/3 transcoder",
+       .arg_def = TRC_ARG1_CONN,  /* TRACE()'s first argument is always a connection */
+       .default_cb = h3_trace,
+       .known_events = h3_trace_events,
+       .lockon_args = h3_trace_lockon_args,
+       .decoding = h3_trace_decoding,
+       .report_events = ~0,  /* report everything by default */
+};
+
+#define TRACE_SOURCE    &trace_h3
+INITCALL1(STG_REGISTER, trace_register_source, TRACE_SOURCE);
+
 #if defined(DEBUG_H3)
 #define h3_debug_printf fprintf
 #define h3_debug_hexdump debug_hexdump
@@ -1033,6 +1073,24 @@ static void h3_stats_inc_err_cnt(void *ctx, int err_code)
        h3_inc_err_cnt(h3c->prx_counters, err_code);
 }
 
+/* h3 trace handler */
+static void h3_trace(enum trace_level level, uint64_t mask,
+                     const struct trace_source *src,
+                     const struct ist where, const struct ist func,
+                     const void *a1, const void *a2, const void *a3, const void *a4)
+{
+       const struct connection *conn = a1;
+       const struct qcc *qcc   = conn ? conn->ctx : NULL;
+       const struct qcs *qcs   = a2;
+
+       if (src->verbosity > H3_VERB_CLEAN) {
+               chunk_appendf(&trace_buf, " : qcc=%p(F)", qcc);
+
+               if (qcs)
+                       chunk_appendf(&trace_buf, " qcs=%p(%lu)", qcs, qcs->id);
+       }
+}
+
 /* HTTP/3 application layer operations */
 const struct qcc_app_ops h3_ops = {
        .init        = h3_init,