From: Willy Tarreau Date: Tue, 6 Aug 2024 17:01:30 +0000 (+0200) Subject: MINOR: mux-quic: add a trace context filling helper X-Git-Tag: v3.1-dev5~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6191de6aa6202f983a721073241b486abcdab869;p=thirdparty%2Fhaproxy.git MINOR: mux-quic: add a trace context filling helper This helper is able to find a connection, a session, a stream, or a frontend from its args. --- diff --git a/src/qmux_trace.c b/src/qmux_trace.c index 424c07e577..e31ff7dd8d 100644 --- a/src/qmux_trace.c +++ b/src/qmux_trace.c @@ -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);