MINOR: mux-quic: implement debug string for logs
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 31 Jul 2024 15:28:24 +0000 (17:28 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 9 Jan 2025 09:28:04 +0000 (10:28 +0100)
Implement MUX_SCTL_DBG_STR for QUIC MUX. This returns info for the
current QCS and QCC instances, reusing qmux_dump_qc{c,s}_info functions
already used for traces, and the connection flags.

This stream operation is useful for debug string sample support.

(cherry picked from commit 630fa53c51ddfd3dbdf5e9d2495ca3fb45ff050e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/mux_quic.c

index 565b144..3dd7c50 100644 (file)
@@ -3,6 +3,7 @@
 #include <import/eb64tree.h>
 
 #include <haproxy/api.h>
+#include <haproxy/buf.h>
 #include <haproxy/chunk.h>
 #include <haproxy/connection.h>
 #include <haproxy/dynbuf.h>
@@ -3291,7 +3292,10 @@ static int qmux_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *ou
 static int qmux_sctl(struct stconn *sc, enum mux_sctl_type mux_sctl, void *output)
 {
        int ret = 0;
-       struct qcs *qcs = __sc_mux_strm(sc);
+       const struct qcs *qcs = __sc_mux_strm(sc);
+       const struct qcc *qcc = qcs->qcc;
+       union mux_sctl_dbg_str_ctx *dbg_ctx;
+       struct buffer *buf;
 
        switch (mux_sctl) {
        case MUX_SCTL_SID:
@@ -3299,6 +3303,22 @@ static int qmux_sctl(struct stconn *sc, enum mux_sctl_type mux_sctl, void *outpu
                        *((int64_t *)output) = qcs->id;
                return ret;
 
+       case MUX_SCTL_DBG_STR:
+               dbg_ctx = output;
+               buf = get_trash_chunk();
+
+               if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_MUXS)
+                       qmux_dump_qcs_info(buf, qcs);
+
+               if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_MUXC)
+                       qmux_dump_qcc_info(buf, qcc);
+
+               if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_CONN)
+                       chunk_appendf(buf, " conn.flg=%#08x", qcc->conn->flags);
+
+               dbg_ctx->ret.buf = *buf;
+               return ret;
+
        default:
                return -1;
        }