]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: mux-h2: count a protocol error when failing to parse a trailer
authorWilly Tarreau <w@1wt.eu>
Wed, 22 Apr 2026 09:58:15 +0000 (11:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 22 Apr 2026 13:57:20 +0000 (15:57 +0200)
Commit aab1a60977 ("BUG/MEDIUM: h2/htx: always fail on too large trailers")
explicitly returned an RST_STREAM on failure to decode some trailers, and
used the code H2_ERR_INTERNAL_ERROR. However there are multiple possible
causes for this failure to happen, and it turns out that it's much more
likely to be related to a protocol error than a decompression error. So
let's change this to PROTOCOL_ERROR, and count a protocol error on the
proxy and in the session.

This can be backported to all stable versions (with adjustments related
to these versions, maybe focusing on 3.2 max is reasonable).

src/mux_h2.c

index e8aeaca468729130e21ea7b72d986d5da00d88e7..99a6be282d6e41f7aaee9a98784e9a976fd4fbab 100644 (file)
@@ -3561,8 +3561,10 @@ static struct h2s *h2c_frt_handle_headers(struct h2c *h2c, struct h2s *h2s)
                                /* Failed to decode this frame (e.g. too large request)
                                 * but the HPACK decompressor is still synchronized.
                                 */
+                               session_inc_http_err_ctr(h2c->conn->owner);
+                               HA_ATOMIC_INC(&h2c->px_counters->strm_proto_err);
                                h2_sess_log_strm(h2c->conn->owner);
-                               h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
+                               h2s_error(h2s, H2_ERR_PROTOCOL_ERROR);
                                TRACE_USER("Stream error decoding H2 trailers", H2_EV_RX_FRAME|H2_EV_RX_HDR|H2_EV_STRM_NEW|H2_EV_STRM_END, h2c->conn, 0, h2s_rxbuf_tail(h2s));
                                h2c->st0 = H2_CS_FRAME_E;
                                goto out;