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.
This commit is contained in:
Christopher Faulet 2026-03-24 18:21:13 +01:00
parent 4e99cddde4
commit d1c7e56585
2 changed files with 14 additions and 7 deletions

View 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);

View 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 {