From dd4fbfb5b407e445e215e2aa910c2cf492317c3d Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Thu, 24 Mar 2022 16:09:16 +0100 Subject: [PATCH] MINOR: mux-quic: declare the qmux trace module 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 | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/mux_quic.c b/src/mux_quic.c index a7b312806..ce11772af 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -9,11 +9,51 @@ #include #include #include +#include #include 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 and 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,