From: Christopher Faulet Date: Tue, 22 Oct 2024 16:21:28 +0000 (+0200) Subject: MINOR: mux-h1: Add support of the debug string for logs X-Git-Tag: v3.1-dev11~79 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ce314cfb395a407484e1b37d76e8af8007c1ff4c;p=thirdparty%2Fhaproxy.git MINOR: mux-h1: Add support of the debug string for logs Now it is possible to have info about front and back H1 multiplexer. For instance: <134>Oct 22 18:10:46 haproxy[3841864]: 127.0.0.1:44280 [22/Oct/2024:18:10:43.265] front-http back-http/www 0/0/-1/-1/3082 503 217 - - SC-- 1/1/0/0/3 0/0 "GET / HTTP/1.1" fs=< h1s=0x13b6f10 h1s.flg=0x14010 .sd.flg=0x50404601 .req.state=MSG_DONE .res.state=MSG_DONE .meth=GET status=503 .sd.flg=0x50404601 .sc.flg=0x00034482 .sc.app=0x11e4c30 .subs=(nil) h1c.flg=0x0 .sub=0 .ibuf =0@(nil)+0/0 .obuf=0@(nil)+0/0 .task=0x1337d10 .exp= conn.flg=0x80000300> bs=< h1s=0x13bb400 h1s.flg=0x100010 .sd.flg=0x10400001 .req.state=MSG_RQBEFORE .res.state=MSG_RPBEFORE .meth=UNKNOWN status=0 .sd.flg=0x10400001 .sc.flg=0x0003c007 .sc.app=0x11e4c30 .subs=(nil) h1c.flg=0x80000000 .sub=0 .ibuf=0@(nil)+0/0 .obuf=0@(nil)+0/0 .task=0x12ba610 .exp= conn.flg=0x5c0300> The have this log message, the log-format must be set to: log-format "$HAPROXY_HTTP_LOG_FMT fs=<%[fs.debug_str]> bs=<%[bs.debug_str]>" --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 54acad8e2c..794740a793 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -346,6 +346,8 @@ static void h1_shutw_conn(struct connection *conn); static void h1_wake_stream_for_recv(struct h1s *h1s); static void h1_wake_stream_for_send(struct h1s *h1s); static void h1s_destroy(struct h1s *h1s); +static int h1_dump_h1c_info(struct buffer *msg, struct h1c *h1c, const char *pfx); +static int h1_dump_h1s_info(struct buffer *msg, const struct h1s *h1s, const char *pfx); /* returns the stconn associated to the H1 stream */ static forceinline struct stconn *h1s_sc(const struct h1s *h1s) @@ -5198,13 +5200,30 @@ static int h1_sctl(struct stconn *sc, enum mux_sctl_type mux_sctl, void *output) { int ret = 0; struct h1s *h1s = __sc_mux_strm(sc); + union mux_sctl_dbg_str_ctx *dbg_ctx; + struct buffer *buf; switch (mux_sctl) { case MUX_SCTL_SID: if (output) *((int64_t *)output) = h1s->h1c->req_count; 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) + h1_dump_h1s_info(buf, h1s, NULL); + + if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_MUXC) + h1_dump_h1c_info(buf, h1s->h1c, NULL); + if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_CONN) + chunk_appendf(buf, " conn.flg=%#08x", h1s->h1c->conn->flags); + + /* other layers not implemented */ + dbg_ctx->ret.buf = *buf; + return ret; default: return -1; }