MINOR: tcpcheck: Support 2-steps args resolution in defaults sections

With the commit eaba25dd9 ("BUG/MINOR: tcpcheck: Don't use arg list for
default proxies during parsing"), we restricted the use of sample fetch in
tcpcheck rules defined in a defaults section to those depending on explicit
arguments only. This means a tcpcheck rules defined in a defaults section
cannot rely on argument unresolved during the configuration parsing.

Thanks to recent changes, it is now possible again.

This patch is mandatory to support TCP/HTTP rules in defaults sections.
This commit is contained in:
Christopher Faulet 2021-10-13 15:18:36 +02:00
parent 52b8a43d4e
commit 6ff7de5d64
4 changed files with 13 additions and 4 deletions

View File

@ -333,6 +333,15 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
goto out;
}
if (curr_defproxy && (curr_defproxy->tcpcheck_rules.flags & TCPCHK_RULES_PROTO_CHK) &&
(curproxy->cap & PR_CAP_LISTEN) == PR_CAP_BE) {
/* If the current default proxy defines tcpcheck rules, the
* current proxy will keep a reference on it. but only if the
* current proxy has the backend capability.
*/
proxy_ref_defaults(curproxy, curr_defproxy);
}
if (rc & PR_CAP_DEF) {
/* last and current proxies must be updated to this one */
curr_defproxy = last_defproxy = curproxy;

View File

@ -418,7 +418,7 @@ int add_sample_to_logformat_list(char *text, char *arg, int arg_len, struct prox
cmd_arg = 0;
expr = sample_parse_expr(cmd, &cmd_arg, curpx->conf.args.file, curpx->conf.args.line, err,
(curpx->cap & PR_CAP_DEF) ? NULL: &curpx->conf.args, endptr);
&curpx->conf.args, endptr);
if (!expr) {
memprintf(err, "failed to parse sample expression <%s> : %s", text, *err);
goto error_free;

View File

@ -2431,7 +2431,7 @@ struct tcpcheck_rule *parse_tcpcheck_connect(char **args, int cur_arg, struct pr
px->conf.args.ctx = ARGC_SRV;
port_expr = sample_parse_expr((char *[]){args[cur_arg], NULL}, &idx,
file, line, errmsg, (px->cap & PR_CAP_DEF) ? NULL: &px->conf.args, NULL);
file, line, errmsg, &px->conf.args, NULL);
if (!port_expr) {
memprintf(errmsg, "error detected while parsing port expression : %s", *errmsg);
@ -3233,7 +3233,7 @@ struct tcpcheck_rule *parse_tcpcheck_expect(char **args, int cur_arg, struct pro
release_sample_expr(status_expr);
px->conf.args.ctx = ARGC_SRV;
status_expr = sample_parse_expr((char *[]){args[cur_arg], NULL}, &idx,
file, line, errmsg, (px->cap & PR_CAP_DEF) ? NULL: &px->conf.args, NULL);
file, line, errmsg, &px->conf.args, NULL);
if (!status_expr) {
memprintf(errmsg, "error detected while parsing status-code expression : %s", *errmsg);
goto error;

View File

@ -879,7 +879,7 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy
} else {
/* set-var */
rule->arg.vars.expr = sample_parse_expr((char **)args, arg, px->conf.args.file,
px->conf.args.line, err, (px->cap & PR_CAP_DEF) ? NULL: &px->conf.args, NULL);
px->conf.args.line, err, &px->conf.args, NULL);
if (!rule->arg.vars.expr)
return ACT_RET_PRS_ERR;