]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: config: Properly test warnif_misplaced_* return values
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 24 Mar 2026 17:21:13 +0000 (18:21 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 27 Mar 2026 06:35:25 +0000 (07:35 +0100)
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
src/tcp_rules.c

index eac047051c3c8f050549badf97226e3dfcdc22e8..f63a0853df9c5d32cd6ede6dc5a7d671a19b3d55 100644 (file)
@@ -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);
index 63ccc9610e69593f9738465913fa4fe04dd64b0c..8b0d92df69e99941f7e9e16329147e3da163de45 100644 (file)
@@ -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 {