]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: declare the qmux trace module
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 24 Mar 2022 15:09:16 +0000 (16:09 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 25 Mar 2022 13:51:10 +0000 (14:51 +0100)
Declare a new trace module for mux-quic named qmux. It will be used to
convert all printf to regular traces. The handler qmux_trace can uses a
connection and a qcs instance as extra arguments.

src/mux_quic.c

index a7b3128066ac690dec5b3d91ee043f5f2bc35789..ce11772af884893b92ce7e468dcd834193311017 100644 (file)
@@ -9,11 +9,51 @@
 #include <haproxy/htx.h>
 #include <haproxy/pool.h>
 #include <haproxy/ssl_sock-t.h>
+#include <haproxy/trace.h>
 #include <haproxy/xprt_quic.h>
 
 DECLARE_POOL(pool_head_qcc, "qcc", sizeof(struct qcc));
 DECLARE_POOL(pool_head_qcs, "qcs", sizeof(struct qcs));
 
+/* trace source and events */
+static void qmux_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 qmux_trace_events[] = {
+       { }
+};
+
+static const struct name_desc qmux_trace_lockon_args[4] = {
+       /* arg1 */ { /* already used by the connection */ },
+       /* arg2 */ { .name="qcs", .desc="QUIC stream" },
+       /* arg3 */ { },
+       /* arg4 */ { }
+};
+
+static const struct name_desc qmux_trace_decoding[] = {
+#define QMUX_VERB_CLEAN    1
+       { .name="clean",    .desc="only user-friendly stuff, generally suitable for level \"user\"" },
+#define QMUX_VERB_MINIMAL  2
+       { .name="minimal",  .desc="report only qcc/qcs state and flags, no real decoding" },
+       { /* end */ }
+};
+
+struct trace_source trace_qmux = {
+       .name = IST("qmux"),
+       .desc = "QUIC multiplexer",
+       .arg_def = TRC_ARG1_CONN,  /* TRACE()'s first argument is always a connection */
+       .default_cb = qmux_trace,
+       .known_events = qmux_trace_events,
+       .lockon_args = qmux_trace_lockon_args,
+       .decoding = qmux_trace_decoding,
+       .report_events = ~0,  /* report everything by default */
+};
+
+#define TRACE_SOURCE    &trace_qmux
+INITCALL1(STG_REGISTER, trace_register_source, TRACE_SOURCE);
+
 /* Allocate a new QUIC streams with id <id> and type <type>. */
 struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type)
 {
@@ -1028,6 +1068,29 @@ static int qc_wake(struct connection *conn)
        return 1;
 }
 
+
+/* quic-mux trace handler */
+static void qmux_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 (!qcc)
+               return;
+
+       if (src->verbosity > QMUX_VERB_CLEAN) {
+               chunk_appendf(&trace_buf, " : qcc=%p(F)", qcc);
+
+               if (qcs)
+                       chunk_appendf(&trace_buf, " qcs=%p(%llu)", qcs, qcs->by_id.key);
+       }
+}
+
+
 static const struct mux_ops qc_ops = {
        .init = qc_init,
        .detach = qc_detach,