MEDIUM: mux-h2: allow to set the glitches threshold to kill a connection
authorWilly Tarreau <w@1wt.eu>
Mon, 11 Mar 2024 06:33:44 +0000 (07:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 11 Mar 2024 07:25:08 +0000 (08:25 +0100)
commit6770259083eeb4b6f8c1dfee6870c3f75b87531e
tree2ebc3be5fb364d7ce0893bcbb7f6f752af3b8000
parente6e7e1587e1d6ddc880b8ccdff09db41588e671e
MEDIUM: mux-h2: allow to set the glitches threshold to kill a connection

Till now it was still needed to write rules to eliminate bad behaving
H2 clients, while most of the time it would be desirable to just be able
to set a threshold on the level of anomalies on a connection.

This is what this patch does. By setting a glitches threshold for frontend
and backend, it allows to automatically turn a connection to the error
state when the threshold is reached so that the connection dies by itself
without having to write possibly complex rules.

One subtlety is that we still have the error state being exclusive to the
parser's state so this requires the h2c_report_glitches() function to return
a status indicating if the threshold was reached or not so that processing
can instantly stop and bypass the state update, otherwise the state could
be turned back to a valid one (e.g. after parsing CONTINUATION); we should
really contemplate the possibility to use H2_CF_ERROR for this. Fortunately
there were very few places where a glitch was reported outside of an error
path so the changes are quite minor.

Now by setting the front value to 1000, a client flooding with short
CONTINUATION frames is instantly stopped.
doc/configuration.txt
src/mux_h2.c