BUG/MINOR: mux-h2: count a protocol error when failing to parse a trailer

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).
This commit is contained in:
Willy Tarreau 2026-04-22 11:58:15 +02:00
parent 0bb52f7542
commit c73a81469e

View 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;