mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-26 15:33:00 +00:00
BUG/MINOR: vars: improve accuracy of the rules used to check expression validity
The set-var() expression naturally checks whether expressions are valid in the context of the rule, but it fails to differentiate frontends from backends. As such for tcp-content and http-request rules, it will only accept frontend-compatible sample-fetches, excluding those declared with SMP_UES_BKEND (a few such as be_id, be_name). For the response it accepts the backend-compatible expressions only, though it seems that there are no sample-fetch function that are valid only in the frontend's content, so that should not cause any problem. Note that while allowing valid configs to be used, the fix might also uncover some incorrect configurations where some expressions currently return nothing (e.g. something depending on frontend declared in a backend), and which could be rejected, but there does not seem to be any such keyword. Thus while it should be backported, better not backport it too far (2.4 and possibly 2.3 only).
This commit is contained in:
parent
2819210a83
commit
843096d72a
32
src/vars.c
32
src/vars.c
@ -780,14 +780,30 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy
|
||||
return ACT_RET_PRS_ERR;
|
||||
|
||||
switch (rule->from) {
|
||||
case ACT_F_TCP_REQ_SES: flags = SMP_VAL_FE_SES_ACC; break;
|
||||
case ACT_F_TCP_REQ_CNT: flags = SMP_VAL_FE_REQ_CNT; break;
|
||||
case ACT_F_TCP_RES_CNT: flags = SMP_VAL_BE_RES_CNT; break;
|
||||
case ACT_F_HTTP_REQ: flags = SMP_VAL_FE_HRQ_HDR; break;
|
||||
case ACT_F_HTTP_RES: flags = SMP_VAL_BE_HRS_HDR; break;
|
||||
case ACT_F_TCP_CHK: flags = SMP_VAL_BE_CHK_RUL; break;
|
||||
case ACT_F_CFG_PARSER: flags = SMP_VAL_CFG_PARSER; break;
|
||||
case ACT_F_CLI_PARSER: flags = SMP_VAL_CLI_PARSER; break;
|
||||
case ACT_F_TCP_REQ_SES:
|
||||
flags = SMP_VAL_FE_SES_ACC;
|
||||
break;
|
||||
case ACT_F_TCP_REQ_CNT:
|
||||
flags = (px->cap & PR_CAP_FE) ? SMP_VAL_FE_REQ_CNT : SMP_VAL_BE_REQ_CNT;
|
||||
break;
|
||||
case ACT_F_TCP_RES_CNT:
|
||||
flags = (px->cap & PR_CAP_FE) ? SMP_VAL_FE_RES_CNT : SMP_VAL_BE_RES_CNT;
|
||||
break;
|
||||
case ACT_F_HTTP_REQ:
|
||||
flags = (px->cap & PR_CAP_FE) ? SMP_VAL_FE_HRQ_HDR : SMP_VAL_BE_HRQ_HDR;
|
||||
break;
|
||||
case ACT_F_HTTP_RES:
|
||||
flags = (px->cap & PR_CAP_BE) ? SMP_VAL_BE_HRS_HDR : SMP_VAL_FE_HRS_HDR;
|
||||
break;
|
||||
case ACT_F_TCP_CHK:
|
||||
flags = SMP_VAL_BE_CHK_RUL;
|
||||
break;
|
||||
case ACT_F_CFG_PARSER:
|
||||
flags = SMP_VAL_CFG_PARSER;
|
||||
break;
|
||||
case ACT_F_CLI_PARSER:
|
||||
flags = SMP_VAL_CLI_PARSER;
|
||||
break;
|
||||
default:
|
||||
memprintf(err,
|
||||
"internal error, unexpected rule->from=%d, please report this bug!",
|
||||
|
Loading…
Reference in New Issue
Block a user