]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: h2/rhttp: fix HTTP2 conn counters on reverse
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 16 Dec 2024 10:00:23 +0000 (11:00 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 19 Dec 2024 16:32:01 +0000 (17:32 +0100)
commit8633446337cd322f010ce7b3ca9c257d1ce7848c
tree88820717ebefb24592bb231e6fd38f0351ae708e
parent4490df57a6d6d603077c1ecbb69c67a07bc9e3d6
BUG/MINOR: h2/rhttp: fix HTTP2 conn counters on reverse

Dedicated HTTP/2 stats proxy counters are available for current and
total number of HTTP/2 connection on both frontend and backend sides.
Both counters are simply incremented into h2_init().

This causes issues when using reverse HTTP. First, increment is not
performed on the expected side, as it is triggered before
h2_conn_reverse() which switches a connection from frontend to backend
or vice versa. For example on active revers side, h2_total_connections
is incremented on the backend only even after connection is reversed and
attached to a listener for the remainder of its lifetime.

h2_open_connections suffers from a similar but arguably worst behavior
as it is also decremented. If increment and decrement operations are not
performed on the same proxy side, which happens for every connection
which has been successfully reversed, it causes an invalid counter
value, possibly with an integer overflow.

To fix this, delay increment operations on reverse HTTP from h2_init()
to h2_conn_reverse(). Both counters are updated only after reverse has
completed, thus using the expected frontend or backend side.

To prevent overflow on h2_open_connections, ensure h2_release()
decrement is not performed if a connection is freed before achieving its
reversal, as in this case it would not have been accounted by H2
counters.

This should be backported up to 2.9.

This should fix github issue #2821.
src/mux_h2.c