From e46090f4244ae94edc15a769b4ba0fb23d7b7418 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 4 May 2026 07:52:41 +0200 Subject: [PATCH] BUG/MINOR: tcpcheck: Properly report error for http health-checks When an error is reported on an expect rule for tcp and http health-checks, a dedicated message is reported with details about the wrong match. However, this was never performed for HTTP health-check because of the wrong test on the check type. In addition, when an error was reported on an "expect hdr" rule, a break statement was missing. So the error message could be truncated (but never emitted because of the issue above). This patch should be backported to all stable versions. --- src/tcpcheck.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tcpcheck.c b/src/tcpcheck.c index 15ce41f32..a500dbadf 100644 --- a/src/tcpcheck.c +++ b/src/tcpcheck.c @@ -415,7 +415,7 @@ static void tcpcheck_expect_onerror_message(struct buffer *msg, struct check *ch int match, struct ist info) { struct sample *smp; - int is_empty; + int is_empty, check_type; /* Follows these step to produce the info message: * 1. if info field is already provided, copy it @@ -433,6 +433,7 @@ static void tcpcheck_expect_onerror_message(struct buffer *msg, struct check *ch goto comment; } + check_type = (check->tcpcheck->rs->flags & TCPCHK_RULES_PROTO_CHK); is_empty = (IS_HTX_SC(check->sc) ? htx_is_empty(htxbuf(&check->bi)) : !b_data(&check->bi)); if (is_empty) { TRACE_ERROR("empty response", CHK_EV_RX_DATA|CHK_EV_RX_ERR, check); @@ -442,7 +443,7 @@ static void tcpcheck_expect_onerror_message(struct buffer *msg, struct check *ch } if (check->type == PR_O2_TCPCHK_CHK && - (check->tcpcheck->rs->flags & TCPCHK_RULES_PROTO_CHK) != TCPCHK_RULES_TCP_CHK) { + check_type != TCPCHK_RULES_TCP_CHK && check_type !=TCPCHK_RULES_HTTP_CHK) { goto comment; } @@ -479,6 +480,7 @@ static void tcpcheck_expect_onerror_message(struct buffer *msg, struct check *ch break; case TCPCHK_EXPECT_HTTP_HEADER: chunk_appendf(msg, " (header pattern) at step %d", tcpcheck_get_step_id(check, rule)); + break; case TCPCHK_EXPECT_UNDEF: /* Should never happen. */ return;