mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
BUG/MINOR: vars: properly set the argument parsing context in the expression
When the expression called in "set-var" uses argments that require late resolution, the context must be set. At the moment, any unknown argument is misleadingly reported as "ACL": frontend f bind :8080 mode http http-request set-var(proc.a) be_conn(foo) parsing [b1.cfg:4]: unable to find backend 'foo' referenced in arg 1 \ of ACL keyword 'be_conn' in proxy 'f'. Once the context is properly set, it now says the truth: parsing [b1.cfg:8]: unable to find backend 'foo' referenced in arg 1 \ of sample fetch keyword 'be_conn' in http-request expression in proxy 'f'. This may be backported but is not really important. If so, the preceeding patches "BUG/MINOR: vars: improve accuracy of the rules used to check expression validity" and "MINOR: sample: add missing ARGC_ entries" must be backported as well.
This commit is contained in:
parent
57467b8356
commit
54b96d9955
19
src/vars.c
19
src/vars.c
@ -774,35 +774,38 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy
|
|||||||
|
|
||||||
kw_name = args[*arg-1];
|
kw_name = args[*arg-1];
|
||||||
|
|
||||||
rule->arg.vars.expr = sample_parse_expr((char **)args, arg, px->conf.args.file,
|
|
||||||
px->conf.args.line, err, &px->conf.args, NULL);
|
|
||||||
if (!rule->arg.vars.expr)
|
|
||||||
return ACT_RET_PRS_ERR;
|
|
||||||
|
|
||||||
switch (rule->from) {
|
switch (rule->from) {
|
||||||
case ACT_F_TCP_REQ_SES:
|
case ACT_F_TCP_REQ_SES:
|
||||||
flags = SMP_VAL_FE_SES_ACC;
|
flags = SMP_VAL_FE_SES_ACC;
|
||||||
|
px->conf.args.ctx = ARGC_TSE;
|
||||||
break;
|
break;
|
||||||
case ACT_F_TCP_REQ_CNT:
|
case ACT_F_TCP_REQ_CNT:
|
||||||
flags = (px->cap & PR_CAP_FE) ? SMP_VAL_FE_REQ_CNT : SMP_VAL_BE_REQ_CNT;
|
flags = (px->cap & PR_CAP_FE) ? SMP_VAL_FE_REQ_CNT : SMP_VAL_BE_REQ_CNT;
|
||||||
|
px->conf.args.ctx = ARGC_TRQ;
|
||||||
break;
|
break;
|
||||||
case ACT_F_TCP_RES_CNT:
|
case ACT_F_TCP_RES_CNT:
|
||||||
flags = (px->cap & PR_CAP_FE) ? SMP_VAL_FE_RES_CNT : SMP_VAL_BE_RES_CNT;
|
flags = (px->cap & PR_CAP_FE) ? SMP_VAL_FE_RES_CNT : SMP_VAL_BE_RES_CNT;
|
||||||
|
px->conf.args.ctx = ARGC_TRS;
|
||||||
break;
|
break;
|
||||||
case ACT_F_HTTP_REQ:
|
case ACT_F_HTTP_REQ:
|
||||||
flags = (px->cap & PR_CAP_FE) ? SMP_VAL_FE_HRQ_HDR : SMP_VAL_BE_HRQ_HDR;
|
flags = (px->cap & PR_CAP_FE) ? SMP_VAL_FE_HRQ_HDR : SMP_VAL_BE_HRQ_HDR;
|
||||||
|
px->conf.args.ctx = ARGC_HRQ;
|
||||||
break;
|
break;
|
||||||
case ACT_F_HTTP_RES:
|
case ACT_F_HTTP_RES:
|
||||||
flags = (px->cap & PR_CAP_BE) ? SMP_VAL_BE_HRS_HDR : SMP_VAL_FE_HRS_HDR;
|
flags = (px->cap & PR_CAP_BE) ? SMP_VAL_BE_HRS_HDR : SMP_VAL_FE_HRS_HDR;
|
||||||
|
px->conf.args.ctx = ARGC_HRS;
|
||||||
break;
|
break;
|
||||||
case ACT_F_TCP_CHK:
|
case ACT_F_TCP_CHK:
|
||||||
flags = SMP_VAL_BE_CHK_RUL;
|
flags = SMP_VAL_BE_CHK_RUL;
|
||||||
|
px->conf.args.ctx = ARGC_TCK;
|
||||||
break;
|
break;
|
||||||
case ACT_F_CFG_PARSER:
|
case ACT_F_CFG_PARSER:
|
||||||
flags = SMP_VAL_CFG_PARSER;
|
flags = SMP_VAL_CFG_PARSER;
|
||||||
|
px->conf.args.ctx = ARGC_CFG;
|
||||||
break;
|
break;
|
||||||
case ACT_F_CLI_PARSER:
|
case ACT_F_CLI_PARSER:
|
||||||
flags = SMP_VAL_CLI_PARSER;
|
flags = SMP_VAL_CLI_PARSER;
|
||||||
|
px->conf.args.ctx = ARGC_CLI;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
memprintf(err,
|
memprintf(err,
|
||||||
@ -810,6 +813,12 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy
|
|||||||
rule->from);
|
rule->from);
|
||||||
return ACT_RET_PRS_ERR;
|
return ACT_RET_PRS_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rule->arg.vars.expr = sample_parse_expr((char **)args, arg, px->conf.args.file,
|
||||||
|
px->conf.args.line, err, &px->conf.args, NULL);
|
||||||
|
if (!rule->arg.vars.expr)
|
||||||
|
return ACT_RET_PRS_ERR;
|
||||||
|
|
||||||
if (!(rule->arg.vars.expr->fetch->val & flags)) {
|
if (!(rule->arg.vars.expr->fetch->val & flags)) {
|
||||||
memprintf(err,
|
memprintf(err,
|
||||||
"fetch method '%s' extracts information from '%s', none of which is available here",
|
"fetch method '%s' extracts information from '%s', none of which is available here",
|
||||||
|
Loading…
Reference in New Issue
Block a user