mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MINOR: vars: add "set-var" for "tcp-request connection" rules.
Session struct is already allocated when "tcp-request connection" rules are evaluated so session-scoped variables turned out easy to support. This resolves github issue #1408.
This commit is contained in:
parent
44c5ff69ac
commit
c8637032a7
@ -11982,10 +11982,13 @@ tcp-request connection <action> <options...> [ { if | unless } <condition> ]
|
|||||||
- set-src <expr>
|
- set-src <expr>
|
||||||
- set-src-port <expr>
|
- set-src-port <expr>
|
||||||
- set-tos <tos>
|
- set-tos <tos>
|
||||||
|
- set-var(<var-name>) <expr>
|
||||||
|
- set-var-fmt(<var-name>) <fmt>
|
||||||
- silent-drop
|
- silent-drop
|
||||||
- track-sc0 <key> [table <table>]
|
- track-sc0 <key> [table <table>]
|
||||||
- track-sc1 <key> [table <table>]
|
- track-sc1 <key> [table <table>]
|
||||||
- track-sc2 <key> [table <table>]
|
- track-sc2 <key> [table <table>]
|
||||||
|
- unset-var(<var-name>)
|
||||||
|
|
||||||
The supported actions are described below.
|
The supported actions are described below.
|
||||||
|
|
||||||
@ -12110,6 +12113,14 @@ tcp-request connection set-tos <tos> [ { if | unless } <condition> ]
|
|||||||
to the value passed in <tos> on platforms which support this. Please refer to
|
to the value passed in <tos> on platforms which support this. Please refer to
|
||||||
"http-request set-tos" for a complete description.
|
"http-request set-tos" for a complete description.
|
||||||
|
|
||||||
|
tcp-request connection set-var(<var-name>) <expr> [ { if | unless } <condition> ]
|
||||||
|
tcp-request connection set-var-fmt(<var-name>) <fmt> [ { if | unless } <condition> ]
|
||||||
|
|
||||||
|
This is used to set the contents of a variable. The variable is declared
|
||||||
|
inline. "tcp-request connection" can set variables in the "proc" and "sess"
|
||||||
|
scopes. Please refer to "http-request set-var" and "http-request set-var-fmt"
|
||||||
|
for a complete description.
|
||||||
|
|
||||||
tcp-request connection silent-drop [ { if | unless } <condition> ]
|
tcp-request connection silent-drop [ { if | unless } <condition> ]
|
||||||
|
|
||||||
This stops the evaluation of the rules and makes the client-facing connection
|
This stops the evaluation of the rules and makes the client-facing connection
|
||||||
@ -12125,6 +12136,11 @@ tcp-request connection track-sc2 <key> [table <table>] [ { if | unless } <condi
|
|||||||
refer to "http-request track-sc0", "http-request track-sc1" and "http-request
|
refer to "http-request track-sc0", "http-request track-sc1" and "http-request
|
||||||
track-sc2" for a complete description.
|
track-sc2" for a complete description.
|
||||||
|
|
||||||
|
tcp-request connection unset-var(<var-name>) [ { if | unless } <condition> ]
|
||||||
|
|
||||||
|
This is used to unset a variable. Please refer to "http-request set-var" for
|
||||||
|
details about variables.
|
||||||
|
|
||||||
|
|
||||||
tcp-request content <action> [{if | unless} <condition>]
|
tcp-request content <action> [{if | unless} <condition>]
|
||||||
Perform an action on a new session depending on a layer 4-7 condition
|
Perform an action on a new session depending on a layer 4-7 condition
|
||||||
|
14
src/vars.c
14
src/vars.c
@ -659,6 +659,7 @@ static enum act_return action_store(struct act_rule *rule, struct proxy *px,
|
|||||||
int dir;
|
int dir;
|
||||||
|
|
||||||
switch (rule->from) {
|
switch (rule->from) {
|
||||||
|
case ACT_F_TCP_REQ_CON: dir = SMP_OPT_DIR_REQ; break;
|
||||||
case ACT_F_TCP_REQ_SES: dir = SMP_OPT_DIR_REQ; break;
|
case ACT_F_TCP_REQ_SES: dir = SMP_OPT_DIR_REQ; break;
|
||||||
case ACT_F_TCP_REQ_CNT: dir = SMP_OPT_DIR_REQ; break;
|
case ACT_F_TCP_REQ_CNT: dir = SMP_OPT_DIR_REQ; break;
|
||||||
case ACT_F_TCP_RES_CNT: dir = SMP_OPT_DIR_RES; break;
|
case ACT_F_TCP_RES_CNT: dir = SMP_OPT_DIR_RES; break;
|
||||||
@ -827,6 +828,10 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy
|
|||||||
kw_name = args[*arg-1];
|
kw_name = args[*arg-1];
|
||||||
|
|
||||||
switch (rule->from) {
|
switch (rule->from) {
|
||||||
|
case ACT_F_TCP_REQ_CON:
|
||||||
|
flags = SMP_VAL_FE_CON_ACC;
|
||||||
|
px->conf.args.ctx = ARGC_TCO;
|
||||||
|
break;
|
||||||
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;
|
px->conf.args.ctx = ARGC_TSE;
|
||||||
@ -1213,6 +1218,15 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, {
|
|||||||
|
|
||||||
INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws);
|
INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws);
|
||||||
|
|
||||||
|
static struct action_kw_list tcp_req_conn_kws = { { }, {
|
||||||
|
{ "set-var-fmt", parse_store, KWF_MATCH_PREFIX },
|
||||||
|
{ "set-var", parse_store, KWF_MATCH_PREFIX },
|
||||||
|
{ "unset-var", parse_store, KWF_MATCH_PREFIX },
|
||||||
|
{ /* END */ }
|
||||||
|
}};
|
||||||
|
|
||||||
|
INITCALL1(STG_REGISTER, tcp_req_conn_keywords_register, &tcp_req_conn_kws);
|
||||||
|
|
||||||
static struct action_kw_list tcp_req_sess_kws = { { }, {
|
static struct action_kw_list tcp_req_sess_kws = { { }, {
|
||||||
{ "set-var-fmt", parse_store, KWF_MATCH_PREFIX },
|
{ "set-var-fmt", parse_store, KWF_MATCH_PREFIX },
|
||||||
{ "set-var", parse_store, KWF_MATCH_PREFIX },
|
{ "set-var", parse_store, KWF_MATCH_PREFIX },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user