]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: add a trace context filling helper
authorWilly Tarreau <w@1wt.eu>
Tue, 6 Aug 2024 17:01:30 +0000 (19:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Aug 2024 14:02:59 +0000 (16:02 +0200)
This helper is able to find a connection, a session, a stream, or a
frontend from its args.

src/qmux_trace.c

index 424c07e577dbb001ae6e179bc6bd61ac00cca1cf..e31ff7dd8d387987896c08dd569086af2e6fefcc 100644 (file)
@@ -13,6 +13,9 @@ static void qmux_trace(enum trace_level level, uint64_t mask,
                        const struct ist where, const struct ist func,
                        const void *a1, const void *a2, const void *a3, const void *a4);
 
+static void qmux_trace_fill_ctx(struct trace_ctx *ctx, const struct trace_source *src,
+                                const void *a1, const void *a2, const void *a3, const void *a4);
+
 static const struct name_desc qmux_trace_lockon_args[4] = {
        /* arg1 */ { /* already used by the connection */ },
        /* arg2 */ { .name="qcs", .desc="QUIC stream" },
@@ -33,6 +36,7 @@ struct trace_source trace_qmux = {
        .desc = "QUIC multiplexer",
        .arg_def = TRC_ARG1_CONN,  /* TRACE()'s first argument is always a connection */
        .default_cb = qmux_trace,
+       .fill_ctx = qmux_trace_fill_ctx,
        .known_events = qmux_trace_events,
        .lockon_args = qmux_trace_lockon_args,
        .decoding = qmux_trace_decoding,
@@ -99,6 +103,28 @@ static void qmux_trace(enum trace_level level, uint64_t mask,
        }
 }
 
+/* This fills the trace_ctx with extra info guessed from the args */
+static void qmux_trace_fill_ctx(struct trace_ctx *ctx, const struct trace_source *src,
+                               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 (!ctx->conn)
+               ctx->conn = conn;
+
+       if (qcc) {
+               if (!ctx->fe)
+                       ctx->fe = qcc->proxy;
+       }
+
+       if (qcs) {
+               if (!ctx->strm && qcs->sd && qcs->sd->sc)
+                       ctx->strm = sc_strm(qcs->sd->sc);
+       }
+}
+
 
 /* register qmux traces */
 INITCALL1(STG_REGISTER, trace_register_source, TRACE_SOURCE);