]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: proxy: only use proxy_inc_fe_cum_sess_ver_ctr() with frontends
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 2 May 2025 17:06:44 +0000 (19:06 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 6 May 2025 09:01:39 +0000 (11:01 +0200)
proxy_inc_fe_cum_sess_ver_ctr() was implemented in 9969adbc
("MINOR: stats: add by HTTP version cumulated number of sessions and
requests")

As its name suggests, it is meant to be called for frontends, not backends

Also, in 9969adbc, when used under h1_init(), a precaution is taken to
ensure that the function is only called with frontends.

However, this precaution was not applied in h2_init() and qc_init().

Due to this, it remains possible to have proxy_inc_fe_cum_sess_ver_ctr()
being called with a backend proxy as parameter. While it did not cause
known issues so far, it is not expected and could result in bugs in the
future. Better fix this by ensuring the function is only called with
frontends.

It may be backported up to 2.8

src/mux_h2.c
src/mux_quic.c

index 9bec150302a87582aaf3824b052daed14de8c972..dba0505529f0d469692a52c60cb13c7a56c73ce7 100644 (file)
@@ -1423,7 +1423,7 @@ static int h2_init(struct connection *conn, struct proxy *prx, struct session *s
                        goto fail_stream;
        }
 
-       if (sess)
+       if (sess && !conn_is_back(conn))
                proxy_inc_fe_cum_sess_ver_ctr(sess->listener, prx, 2);
 
        /* Rhttp connections are only accounted after reverse completion. */
index 0bc882e9c21028a600e1ce82140adc3d000972ff..68b913970b40154169a76659e75a0a9509c2a7fe 100644 (file)
@@ -3515,7 +3515,7 @@ static int qmux_init(struct connection *conn, struct proxy *prx,
                goto err;
        }
 
-       if (qcc->app_ops == &h3_ops)
+       if (qcc->app_ops == &h3_ops && !conn_is_back(conn))
                proxy_inc_fe_cum_sess_ver_ctr(sess->listener, prx, 3);
 
        /* Register conn for idle front closing. This is done once everything is allocated. */