]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: Make bc_http_major compatible with tcp-checks
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 14 Apr 2021 13:46:49 +0000 (15:46 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 19 Apr 2021 06:31:05 +0000 (08:31 +0200)
bc_http_major sample fetch now works when it is called from a
tcp-check. When it happens, the session origin is a check. The backend
connection is retrieved from the conn-stream attached to the check.

If required, this path may easily be backported as far as 2.2.

src/connection.c

index b55890ae2a239cefc6a57b9d646100d32c7d934e..c0ba8155f48dd46f882c4615f618e7c0a28c3961 100644 (file)
@@ -1315,8 +1315,13 @@ static int cfg_parse_pp2_never_send_local(char **args, int section_type, struct
 static int
 smp_fetch_fc_http_major(const struct arg *args, struct sample *smp, const char *kw, void *private)
 {
-       struct connection *conn = (kw[0] != 'b') ? objt_conn(smp->sess->origin) :
-                                                                               smp->strm ? cs_conn(objt_cs(smp->strm->si[1].end)) : NULL;
+       struct connection *conn = NULL;
+
+       if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+                conn = (kw[0] == 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
+        else
+                conn = (kw[0] != 'b') ? objt_conn(smp->sess->origin) :
+                       smp->strm ? cs_conn(objt_cs(smp->strm->si[1].end)) : NULL;
 
        /* No connection or a connection with a RAW muxx */
        if (!conn || (conn->mux && !(conn->mux->flags & MX_FL_HTX)))