From 663416b4ef2fafcffa61c04aa09056853d9674f7 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Thu, 1 Aug 2024 11:35:04 +0200 Subject: [PATCH] MINOR: quic: dump quic_conn debug string for logs Define a new xprt_ops callback named dump_info. This can be used to extend MUX debug string with infos from the lower layer. Implement dump_info for QUIC stack. For now, only minimal info are reported : bytes in flight and size of the sending window. This should allow to detect if the congestion controller is fine. These info are reported via QUIC MUX debug string sample. --- include/haproxy/connection-t.h | 1 + include/haproxy/quic_trace.h | 6 ++++++ src/mux_quic.c | 3 +++ src/quic_trace.c | 8 ++++++++ src/xprt_quic.c | 7 +++++++ 5 files changed, 25 insertions(+) diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index 7119c0c20d..228f2078c4 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -404,6 +404,7 @@ struct xprt_ops { int (*add_xprt)(struct connection *conn, void *xprt_ctx, void *toadd_ctx, const struct xprt_ops *toadd_ops, void **oldxprt_ctx, const struct xprt_ops **oldxprt_ops); /* Add a new XPRT as the new xprt, and return the old one */ struct ssl_sock_ctx *(*get_ssl_sock_ctx)(struct connection *); /* retrieve the ssl_sock_ctx in use, or NULL if none */ int (*show_fd)(struct buffer *, const struct connection *, const void *ctx); /* append some data about xprt for "show fd"; returns non-zero if suspicious */ + void (*dump_info)(struct buffer *, const struct connection *); }; /* mux_ops describes the mux operations, which are to be performed at the diff --git a/include/haproxy/quic_trace.h b/include/haproxy/quic_trace.h index 19fe864307..ddfd3cc958 100644 --- a/include/haproxy/quic_trace.h +++ b/include/haproxy/quic_trace.h @@ -23,6 +23,10 @@ #include +#include + +struct quic_conn; + #define TRACE_SOURCE &trace_quic /* Initializes a enc_debug_info struct (only for debug purpose) */ @@ -37,4 +41,6 @@ static inline void enc_debug_info_init(struct enc_debug_info *edi, edi->pn = pn; } +void quic_dump_qc_info(struct buffer *msg, const struct quic_conn *qc); + #endif /* _HAPROXY_QUIC_TRACE_H */ diff --git a/src/mux_quic.c b/src/mux_quic.c index 4ea46bd15c..ddaea06228 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -3226,6 +3226,9 @@ static int qmux_sctl(struct stconn *sc, enum mux_sctl_type mux_sctl, void *outpu if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_CONN) chunk_appendf(buf, " conn.flg=%#08x", qcc->conn->flags); + if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_XPRT) + qcc->conn->xprt->dump_info(buf, qcc->conn); + dbg_ctx->ret.buf = *buf; return ret; diff --git a/src/quic_trace.c b/src/quic_trace.c index bd7a886107..ce683f6571 100644 --- a/src/quic_trace.c +++ b/src/quic_trace.c @@ -12,6 +12,8 @@ #include +#include +#include #include #include #include @@ -631,3 +633,9 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace } } + +void quic_dump_qc_info(struct buffer *msg, const struct quic_conn *qc) +{ + chunk_appendf(msg, " qc.wnd=%llu/%llu", (ullong)qc->path->in_flight, + (ullong)qc->path->cwnd); +} diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 558d1a5975..d6d1a16708 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -161,6 +162,11 @@ static struct ssl_sock_ctx *qc_get_ssl_sock_ctx(struct connection *conn) return conn->handle.qc->xprt_ctx; } +static void qc_xprt_dump_info(struct buffer *msg, const struct connection *conn) +{ + quic_dump_qc_info(msg, conn->handle.qc); +} + /* transport-layer operations for QUIC connections. */ static struct xprt_ops ssl_quic = { .close = quic_close, @@ -172,6 +178,7 @@ static struct xprt_ops ssl_quic = { .destroy_bind_conf = ssl_sock_destroy_bind_conf, .get_alpn = ssl_sock_get_alpn, .get_ssl_sock_ctx = qc_get_ssl_sock_ctx, + .dump_info = qc_xprt_dump_info, .name = "QUIC", };