]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2/trace: emit a trace of the received RST_STREAM type
authorWilly Tarreau <w@1wt.eu>
Wed, 10 Dec 2025 14:56:34 +0000 (15:56 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 10 Dec 2025 14:58:56 +0000 (15:58 +0100)
Right now we don't get any state trace when receiving an RST_STREAM, and
this is not convenient because RST_STREAM(0) is not visible at all, except
in developer level because the function is entered and left.

Let's extract the RST code first and always log it using TRACE_PRINTF()
(along with h2c/h2s) so that it's possible to detect certain codes being
used.

src/mux_h2.c

index 39119ce4f30a8d708fbb01bdbb806f30164f90f2..61ee418487136eead95f42e02e25798c41ed8c6a 100644 (file)
@@ -3356,6 +3356,8 @@ static int h2c_handle_priority(struct h2c *h2c)
  */
 static int h2c_handle_rst_stream(struct h2c *h2c, struct h2s *h2s)
 {
+       int rst_code;
+
        TRACE_ENTER(H2_EV_RX_FRAME|H2_EV_RX_RST|H2_EV_RX_EOI, h2c->conn, h2s);
 
        /* process full frame only */
@@ -3365,13 +3367,20 @@ static int h2c_handle_rst_stream(struct h2c *h2c, struct h2s *h2s)
                return 0;
        }
 
+       rst_code = h2_get_n32(&h2c->dbuf, 0);
+       TRACE_PRINTF(TRACE_LEVEL_STATE, ~0U/*H2_EV_RX_FRAME|H2_EV_RX_RST|H2_EV_RX_EOI*/, h2c->conn, h2s, 0, 0,
+                    "received RST_STREAM(%d) : h2c=%p(%c=%s,%s,%#x) h2s=%p(%d)",
+                    rst_code, h2c, conn_is_back(h2c->conn) ? 'B' : 'F',
+                    h2c->proxy->id, h2c_st_to_str(h2c->st0), h2c->flags,
+                    h2s, h2s->id);
+
        /* late RST, already handled */
        if (h2s->st == H2_SS_CLOSED) {
                TRACE_DEVEL("leaving on stream closed", H2_EV_RX_FRAME|H2_EV_RX_RST|H2_EV_RX_EOI, h2c->conn, h2s);
                return 1;
        }
 
-       h2s->errcode = h2_get_n32(&h2c->dbuf, 0);
+       h2s->errcode = rst_code;
        h2s_close(h2s);
 
        if (h2s_sc(h2s)) {