MEDIUM: mux-h2: update session trackers with number of glitches

We now update the session's tracked counters with the observed glitches.
In order to avoid incurring a high cost, e.g. if many small frames contain
issues, we batch the updates around h2_process_demux() by directly passing
the difference. Indeed, for now all functions that increment glitches are
called from h2_process_demux(). If that were to change, we'd just need to
keep the value of the last synced counter in the h2c struct instead of the
stack.

The regtest was updated to verify that the 3rd client that does not cause
issue still sees the counter resulting from client 2's mistakes. The rate
is also verified, considering it shouldn't fail since the period is very
long (1m).
This commit is contained in:
Willy Tarreau 2024-01-19 17:33:27 +01:00
parent 8581d62daf
commit 870e2d3f1f
2 changed files with 12 additions and 1 deletions

View File

@ -11,7 +11,9 @@ haproxy hap -conf {
listen fe1
bind "fd@${fe1}" proto h2
http-request return status 200 hdr x-glitches %[fc_glitches]
tcp-request session track-sc0 src
http-request return status 200 hdr x-glitches %[fc_glitches] hdr x-glitch-cnt %[sc0_glitch_cnt] hdr x-glitch-rate %[sc0_glitch_rate]
stick-table type ip size 10 store glitch_cnt,glitch_rate(1m)
} -start
# valid request: no glitch
@ -73,6 +75,8 @@ client c2-path -connect ${hap_fe1_sock} {
rxresp
expect resp.status == 200
expect resp.http.x-glitches == 1
expect resp.http.x-glitch-cnt == 1
expect resp.http.x-glitch-rate == 1
} -run
} -run
@ -104,5 +108,7 @@ client c3-scheme -connect ${hap_fe1_sock} {
rxresp
expect resp.status == 200
expect resp.http.x-glitches == 0
expect resp.http.x-glitch-cnt == 1
expect resp.http.x-glitch-rate == 1
} -run
} -run

View File

@ -4364,8 +4364,13 @@ static int h2_process(struct h2c *h2c)
if (!(h2c->flags & H2_CF_DEM_BLOCK_ANY) &&
(b_data(&h2c->dbuf) || (h2c->flags & H2_CF_RCVD_SHUT))) {
int prev_glitches = h2c->glitches;
h2_process_demux(h2c);
if (h2c->glitches != prev_glitches && !(h2c->flags & H2_CF_IS_BACK))
session_add_glitch_ctr(h2c->conn->owner, h2c->glitches - prev_glitches);
if (h2c->st0 >= H2_CS_ERROR || (h2c->flags & H2_CF_ERROR))
b_reset(&h2c->dbuf);