From 3e8b8aa6aa809fee72dab14df7a838078b8c0b08 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 26 Mar 2026 22:57:58 +0100 Subject: [PATCH] BUG/MINOR: tcpcheck: Use tcpcheck context for expressions parsing When log-format stirngs were parsed in context of a tcpcheck, ARGC_SRV context was used instead of ARGC_TCK. This context is used to report accurrate errors. This patch could be backported to all stable versions. --- src/tcpcheck.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tcpcheck.c b/src/tcpcheck.c index e476cbd88..3a217e396 100644 --- a/src/tcpcheck.c +++ b/src/tcpcheck.c @@ -2774,7 +2774,7 @@ struct tcpcheck_rule *parse_tcpcheck_connect(char **args, int cur_arg, struct pr if (p != end) { int idx = 0; - px->conf.args.ctx = ARGC_SRV; + px->conf.args.ctx = ARGC_TCK; port_expr = sample_parse_expr((char *[]){args[cur_arg], NULL}, &idx, file, line, errmsg, &px->conf.args, NULL); @@ -2985,7 +2985,7 @@ struct tcpcheck_rule *parse_tcpcheck_send(char **args, int cur_arg, struct proxy case TCPCHK_SEND_STRING_LF: case TCPCHK_SEND_BINARY_LF: lf_expr_init(&chk->send.fmt); - px->conf.args.ctx = ARGC_SRV; + px->conf.args.ctx = ARGC_TCK; if (!parse_logformat_string(data, px, &chk->send.fmt, 0, SMP_VAL_BE_CHK_RUL, errmsg)) { memprintf(errmsg, "'%s' invalid log-format string (%s).\n", data, *errmsg); goto error; @@ -3126,7 +3126,7 @@ struct tcpcheck_rule *parse_tcpcheck_send_http(char **args, int cur_arg, struct if (uri) { if (chk->send.http.flags & TCPCHK_SND_HTTP_FL_URI_FMT) { lf_expr_init(&chk->send.http.uri_fmt); - px->conf.args.ctx = ARGC_SRV; + px->conf.args.ctx = ARGC_TCK; if (!parse_logformat_string(uri, px, &chk->send.http.uri_fmt, 0, SMP_VAL_BE_CHK_RUL, errmsg)) { memprintf(errmsg, "'%s' invalid log-format string (%s).\n", uri, *errmsg); goto error; @@ -3170,7 +3170,7 @@ struct tcpcheck_rule *parse_tcpcheck_send_http(char **args, int cur_arg, struct if (body) { if (chk->send.http.flags & TCPCHK_SND_HTTP_FL_BODY_FMT) { lf_expr_init(&chk->send.http.body_fmt); - px->conf.args.ctx = ARGC_SRV; + px->conf.args.ctx = ARGC_TCK; if (!parse_logformat_string(body, px, &chk->send.http.body_fmt, 0, SMP_VAL_BE_CHK_RUL, errmsg)) { memprintf(errmsg, "'%s' invalid log-format string (%s).\n", body, *errmsg); goto error; @@ -3575,7 +3575,7 @@ struct tcpcheck_rule *parse_tcpcheck_expect(char **args, int cur_arg, struct pro cur_arg++; release_sample_expr(status_expr); - px->conf.args.ctx = ARGC_SRV; + px->conf.args.ctx = ARGC_TCK; status_expr = sample_parse_expr((char *[]){args[cur_arg], NULL}, &idx, file, line, errmsg, &px->conf.args, NULL); if (!status_expr) { @@ -3647,14 +3647,14 @@ struct tcpcheck_rule *parse_tcpcheck_expect(char **args, int cur_arg, struct pro chk->expect.status_expr = status_expr; status_expr = NULL; if (on_success_msg) { - px->conf.args.ctx = ARGC_SRV; + px->conf.args.ctx = ARGC_TCK; if (!parse_logformat_string(on_success_msg, px, &chk->expect.onsuccess_fmt, 0, SMP_VAL_BE_CHK_RUL, errmsg)) { memprintf(errmsg, "'%s' invalid log-format string (%s).\n", on_success_msg, *errmsg); goto error; } } if (on_error_msg) { - px->conf.args.ctx = ARGC_SRV; + px->conf.args.ctx = ARGC_TCK; if (!parse_logformat_string(on_error_msg, px, &chk->expect.onerror_fmt, 0, SMP_VAL_BE_CHK_RUL, errmsg)) { memprintf(errmsg, "'%s' invalid log-format string (%s).\n", on_error_msg, *errmsg); goto error; @@ -3730,7 +3730,7 @@ struct tcpcheck_rule *parse_tcpcheck_expect(char **args, int cur_arg, struct pro case TCPCHK_EXPECT_BINARY_LF: case TCPCHK_EXPECT_HTTP_BODY_LF: lf_expr_init(&chk->expect.fmt); - px->conf.args.ctx = ARGC_SRV; + px->conf.args.ctx = ARGC_TCK; if (!parse_logformat_string(pattern, px, &chk->expect.fmt, 0, SMP_VAL_BE_CHK_RUL, errmsg)) { memprintf(errmsg, "'%s' invalid log-format string (%s).\n", pattern, *errmsg); goto error; @@ -3748,7 +3748,7 @@ struct tcpcheck_rule *parse_tcpcheck_expect(char **args, int cur_arg, struct pro goto error; } else if (chk->expect.flags & TCPCHK_EXPT_FL_HTTP_HNAME_FMT) { - px->conf.args.ctx = ARGC_SRV; + px->conf.args.ctx = ARGC_TCK; lf_expr_init(&chk->expect.hdr.name_fmt); if (!parse_logformat_string(npat, px, &chk->expect.hdr.name_fmt, 0, SMP_VAL_BE_CHK_RUL, errmsg)) { memprintf(errmsg, "'%s' invalid log-format string (%s).\n", npat, *errmsg); @@ -3778,7 +3778,7 @@ struct tcpcheck_rule *parse_tcpcheck_expect(char **args, int cur_arg, struct pro goto error; } else if (chk->expect.flags & TCPCHK_EXPT_FL_HTTP_HVAL_FMT) { - px->conf.args.ctx = ARGC_SRV; + px->conf.args.ctx = ARGC_TCK; lf_expr_init(&chk->expect.hdr.value_fmt); if (!parse_logformat_string(vpat, px, &chk->expect.hdr.value_fmt, 0, SMP_VAL_BE_CHK_RUL, errmsg)) { memprintf(errmsg, "'%s' invalid log-format string (%s).\n", vpat, *errmsg);