From d1c7e565858bd491b8a42c1e432923c0536dbe2a Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 24 Mar 2026 18:21:13 +0100 Subject: [PATCH] BUG/MINOR: config: Properly test warnif_misplaced_* return values warnif_misplaced_* functions return 1 when a warning is reported and 0 otherwise. So the caller must properly handle the return value. When parsing a proxy, ERR_WARN code must be added to the error code instead of the return value. When a warning was reported, ERR_RETRYABLE (1) was added instead of ERR_WARN. And when tcp rules were parsed, warnings were ignored. Message were emitted but the return values were ignored. This patch should be backported to all stable versions. --- src/cfgparse-listen.c | 9 ++++++--- src/tcp_rules.c | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index eac047051..f63a0853d 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -1358,7 +1358,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) goto out; } - err_code |= warnif_misplaced_http_req(curproxy, file, linenum, args[0], NULL); + if (warnif_misplaced_http_req(curproxy, file, linenum, args[0], NULL)) + err_code |= ERR_WARN; if (curproxy->cap & PR_CAP_FE) where |= SMP_VAL_FE_HRQ_HDR; @@ -1491,7 +1492,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) } LIST_APPEND(&curproxy->redirect_rules, &rule->list); - err_code |= warnif_misplaced_redirect(curproxy, file, linenum, args[0], NULL); + if (warnif_misplaced_redirect(curproxy, file, linenum, args[0], NULL)) + err_code |= ERR_WARN; if (curproxy->cap & PR_CAP_FE) where |= SMP_VAL_FE_HRQ_HDR; @@ -2593,7 +2595,8 @@ stats_error_parsing: goto out; } - err_code |= warnif_misplaced_monitor(curproxy, file, linenum, args[0], args[1]); + if (warnif_misplaced_monitor(curproxy, file, linenum, args[0], args[1])) + err_code |= ERR_WARN; if ((cond = build_acl_cond(file, linenum, &curproxy->acl, curproxy, (const char **)args + 2, &errmsg)) == NULL) { ha_alert("parsing [%s:%d] : error detected while parsing a '%s %s' condition : %s.\n", file, linenum, args[0], args[1], errmsg); diff --git a/src/tcp_rules.c b/src/tcp_rules.c index 63ccc9610..8b0d92df6 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -1257,7 +1257,8 @@ static int tcp_parse_tcp_rep(char **args, int section_type, struct proxy *curpx, } /* the following function directly emits the warning */ - warnif_misplaced_tcp_res_cont(curpx, file, line, args[0], args[1]); + if (warnif_misplaced_tcp_res_cont(curpx, file, line, args[0], args[1])) + warn++; LIST_APPEND(&curpx->tcp_rep.inspect_rules, &rule->list); } else { @@ -1377,7 +1378,8 @@ static int tcp_parse_tcp_req(char **args, int section_type, struct proxy *curpx, } /* the following function directly emits the warning */ - warnif_misplaced_tcp_req_cont(curpx, file, line, args[0], args[1]); + if (warnif_misplaced_tcp_req_cont(curpx, file, line, args[0], args[1])) + warn++; LIST_APPEND(&curpx->tcp_req.inspect_rules, &rule->list); } else if (strcmp(args[1], "connection") == 0) { @@ -1422,7 +1424,8 @@ static int tcp_parse_tcp_req(char **args, int section_type, struct proxy *curpx, } /* the following function directly emits the warning */ - warnif_misplaced_tcp_req_conn(curpx, file, line, args[0], args[1]); + if (warnif_misplaced_tcp_req_conn(curpx, file, line, args[0], args[1])) + warn++; LIST_APPEND(&curpx->tcp_req.l4_rules, &rule->list); } else if (strcmp(args[1], "session") == 0) { @@ -1466,7 +1469,8 @@ static int tcp_parse_tcp_req(char **args, int section_type, struct proxy *curpx, } /* the following function directly emits the warning */ - warnif_misplaced_tcp_req_sess(curpx, file, line, args[0], args[1]); + if (warnif_misplaced_tcp_req_sess(curpx, file, line, args[0], args[1])) + warn++; LIST_APPEND(&curpx->tcp_req.l5_rules, &rule->list); } else {