]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: implement debug string for logs
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 31 Jul 2024 15:28:24 +0000 (17:28 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 7 Aug 2024 13:40:52 +0000 (15:40 +0200)
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.

src/mux_quic.c

index b703c8bfbc8d02fbff49b00312a3cede0d71544b..4ea46bd15ce3a35928c5f9350dc0ee969c6b47ed 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>
@@ -3201,7 +3202,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:
@@ -3209,6 +3213,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;
        }