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.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 20c0f74..09e27b0 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -11982,10 +11982,13 @@
- set-src <expr>
- set-src-port <expr>
- set-tos <tos>
+ - set-var(<var-name>) <expr>
+ - set-var-fmt(<var-name>) <fmt>
- silent-drop
- track-sc0 <key> [table <table>]
- track-sc1 <key> [table <table>]
- track-sc2 <key> [table <table>]
+ - unset-var(<var-name>)
The supported actions are described below.
@@ -12110,6 +12113,14 @@
to the value passed in <tos> on platforms which support this. Please refer to
"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> ]
This stops the evaluation of the rules and makes the client-facing connection
@@ -12125,6 +12136,11 @@
refer to "http-request track-sc0", "http-request track-sc1" and "http-request
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>]
Perform an action on a new session depending on a layer 4-7 condition
diff --git a/src/vars.c b/src/vars.c
index 0de90d8..a61fb12 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -659,6 +659,7 @@
int dir;
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_CNT: dir = SMP_OPT_DIR_REQ; break;
case ACT_F_TCP_RES_CNT: dir = SMP_OPT_DIR_RES; break;
@@ -827,6 +828,10 @@
kw_name = args[*arg-1];
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:
flags = SMP_VAL_FE_SES_ACC;
px->conf.args.ctx = ARGC_TSE;
@@ -1213,6 +1218,15 @@
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 = { { }, {
{ "set-var-fmt", parse_store, KWF_MATCH_PREFIX },
{ "set-var", parse_store, KWF_MATCH_PREFIX },