]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: checks: Parse custom action rules in tcp-checks
authorGaetan Rivet <grive@u256.net>
Fri, 21 Feb 2020 17:14:59 +0000 (18:14 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 27 Apr 2020 07:39:37 +0000 (09:39 +0200)
Register the custom action rules "set-var" and "unset-var", that will
call the parse_store() command upon parsing.

These rules are thus built and integrated to the tcp-check ruleset, but
have no further effect for the moment.

include/proto/checks.h
include/types/action.h
include/types/checks.h
include/types/sample.h
src/checks.c
src/sample.c
src/vars.c

index d9491753dee105f7832bb3cec194dd652ceb053b..a0a8329b1283440f0d0d26a0e97619c5c5178874 100644 (file)
@@ -56,6 +56,12 @@ int init_email_alert(struct mailers *mailers, struct proxy *p, char **err);
 void send_email_alert(struct server *s, int priority, const char *format, ...)
        __attribute__ ((format(printf, 3, 4)));
 
+extern struct action_kw_list tcp_check_keywords;
+static inline void tcp_check_keywords_register(struct action_kw_list *kw_list)
+{
+       LIST_ADDQ(&tcp_check_keywords.list, &kw_list->list);
+}
+
 /* Declared here, but the definitions are in flt_spoe.c */
 int spoe_prepare_healthcheck_request(char **req, int *len);
 int spoe_handle_healthcheck_response(char *frame, size_t size, char *err, int errlen);
index 329877015583e953bb9eb9d9c0a3f0f5de3be503..1a5a59405d2555d0f865e46f111e64284e7ea812 100644 (file)
@@ -34,6 +34,7 @@ enum act_from {
        ACT_F_TCP_RES_CNT, /* tcp-response content */
        ACT_F_HTTP_REQ,    /* http-request */
        ACT_F_HTTP_RES,    /* http-response */
+       ACT_F_TCP_CHK,     /* tcp-check. */
 };
 
 enum act_return {
index b980faae05e2ab20c5d8fe0a16bd650f12e18dcf..d848e6c9992447ebc586013226bf89cfcdd8c21b 100644 (file)
@@ -256,12 +256,17 @@ struct tcpcheck_expect {
        int min_recv;                   /* Minimum amount of data before an expect can be applied. (default: -1, ignored) */
 };
 
+struct tcpcheck_action_kw {
+       struct act_rule *rule;
+};
+
 /* possible actions for tcpcheck_rule->action */
 enum tcpcheck_rule_type {
        TCPCHK_ACT_SEND = 0, /* send action, regular string format */
        TCPCHK_ACT_EXPECT, /* expect action, either regular or binary string */
        TCPCHK_ACT_CONNECT, /* connect action, to probe a new port */
        TCPCHK_ACT_COMMENT, /* no action, simply a comment used for logs */
+       TCPCHK_ACT_ACTION_KW, /* custom registered action_kw rule. */
 };
 
 struct tcpcheck_rule {
@@ -273,6 +278,7 @@ struct tcpcheck_rule {
                struct tcpcheck_connect connect; /* Connect rule. */
                struct tcpcheck_send send;      /* Send rule. */
                struct tcpcheck_expect expect;  /* Expected pattern. */
+               struct tcpcheck_action_kw action_kw;  /* Custom action. */
        };
 };
 
index e5c2c29f530baf49a0c0b7d9eba54a5f8224419e..2292b3694c40d5954e0e656f8b8f351185c3ae2c 100644 (file)
@@ -99,6 +99,7 @@ enum {
        SMP_CKP_FE_HRS_HDR,  /* FE HTTP response headers (rules, headers) */
        SMP_CKP_FE_HRS_BDY,  /* FE HTTP response body */
        SMP_CKP_FE_LOG_END,  /* FE log at the end of the txn/stream */
+       SMP_CKP_BE_CHK_RUL,  /* BE tcp-check rules */
        SMP_CKP_ENTRIES /* nothing after this */
 };
 
@@ -164,16 +165,18 @@ enum {
        SMP_VAL_FE_HRS_HDR = 1 << SMP_CKP_FE_HRS_HDR,  /* FE HTTP response headers (rules, headers) */
        SMP_VAL_FE_HRS_BDY = 1 << SMP_CKP_FE_HRS_BDY,  /* FE HTTP response body */
        SMP_VAL_FE_LOG_END = 1 << SMP_CKP_FE_LOG_END,  /* FE log at the end of the txn/stream */
+       SMP_VAL_BE_CHK_RUL = 1 << SMP_CKP_BE_CHK_RUL,  /* BE tcp-check rule */
 
        /* a few combinations to decide what direction to try to fetch (useful for logs) */
        SMP_VAL_REQUEST    = SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT |
                             SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK |
                             SMP_VAL_BE_REQ_CNT | SMP_VAL_BE_HRQ_HDR | SMP_VAL_BE_HRQ_BDY |
-                            SMP_VAL_BE_SET_SRV,
+                            SMP_VAL_BE_SET_SRV | SMP_VAL_BE_CHK_RUL,
 
        SMP_VAL_RESPONSE   = SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR |
                             SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT |
-                            SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | SMP_VAL_FE_LOG_END,
+                            SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | SMP_VAL_FE_LOG_END |
+                            SMP_VAL_BE_CHK_RUL,
 };
 
 extern const unsigned int fetch_cap[SMP_SRC_ENTRIES];
index 9423e2d7dc1c0b7c4810c082788c413bde3aa34c..5e147b81f47596f98d6b63dd2993627aa191abe8 100644 (file)
@@ -43,6 +43,7 @@
 #include <types/dns.h>
 #include <types/stats.h>
 
+#include <proto/action.h>
 #include <proto/backend.h>
 #include <proto/checks.h>
 #include <proto/stats.h>
@@ -1559,7 +1560,7 @@ static struct tcpcheck_rule *get_first_tcpcheck_rule(struct list *list)
        struct tcpcheck_rule *r;
 
        list_for_each_entry(r, list, list) {
-               if (r->action != TCPCHK_ACT_COMMENT)
+               if (r->action != TCPCHK_ACT_COMMENT && r->action != TCPCHK_ACT_ACTION_KW)
                        return r;
        }
        return NULL;
@@ -1578,7 +1579,7 @@ static struct tcpcheck_rule *get_next_tcpcheck_rule(struct list *list, struct tc
 
        r = LIST_NEXT(&start->list, typeof(r), list);
        list_for_each_entry_from(r, list, list) {
-               if (r->action != TCPCHK_ACT_COMMENT)
+               if (r->action != TCPCHK_ACT_COMMENT && r->action != TCPCHK_ACT_ACTION_KW)
                        return r;
        }
        return NULL;
@@ -3421,6 +3422,9 @@ static void free_tcpcheck(struct tcpcheck_rule *rule, int in_pool)
        case TCPCHK_ACT_CONNECT:
        case TCPCHK_ACT_COMMENT:
                break;
+       case TCPCHK_ACT_ACTION_KW:
+               free(rule->action_kw.rule);
+               break;
        }
 
        if (in_pool)
@@ -3983,6 +3987,56 @@ REGISTER_PROXY_DEINIT(deinit_proxy_tcpcheck);
 REGISTER_SERVER_DEINIT(deinit_srv_check);
 REGISTER_SERVER_DEINIT(deinit_srv_agent_check);
 
+struct action_kw_list tcp_check_keywords = {
+       .list = LIST_HEAD_INIT(tcp_check_keywords.list),
+};
+
+/* Return the struct action_kw associated to a keyword */
+static struct action_kw *action_kw_tcp_check_lookup(const char *kw)
+{
+       return action_lookup(&tcp_check_keywords.list, kw);
+}
+
+static void action_kw_tcp_check_build_list(struct buffer *chk)
+{
+       action_build_list(&tcp_check_keywords.list, chk);
+}
+
+/* Create a tcp-check rule resulting from parsing a custom keyword. */
+static struct tcpcheck_rule *parse_tcpcheck_action(char **args, int cur_arg, struct proxy *px,
+                                                  struct list *rules, struct action_kw *kw, char **errmsg)
+{
+       struct tcpcheck_rule *chk = NULL;
+       struct act_rule *actrule = NULL;
+
+       actrule = calloc(1, sizeof(*actrule));
+       if (!actrule) {
+               memprintf(errmsg, "out of memory");
+               goto error;
+       }
+       actrule->kw = kw;
+       actrule->from = ACT_F_TCP_CHK;
+
+       cur_arg++;
+       if (kw->parse((const char **)args, &cur_arg, px, actrule, errmsg) == ACT_RET_PRS_ERR) {
+               memprintf(errmsg, "'%s' : %s", kw->kw, *errmsg);
+               goto error;
+       }
+
+       chk = calloc(1, sizeof(*chk));
+       if (!chk) {
+               memprintf(errmsg, "out of memory");
+               goto error;
+       }
+       chk->action = TCPCHK_ACT_ACTION_KW;
+       chk->action_kw.rule = actrule;
+       return chk;
+
+  error:
+       free(actrule);
+       return NULL;
+}
+
 static struct tcpcheck_rule *parse_tcpcheck_connect(char **args, int cur_arg, struct proxy *px, struct list *rules,
                                                    char **errmsg)
 {
@@ -3992,11 +4046,13 @@ static struct tcpcheck_rule *parse_tcpcheck_connect(char **args, int cur_arg, st
        long port = 0;
 
        list_for_each_entry(chk, rules, list) {
-               if (chk->action != TCPCHK_ACT_COMMENT)
+               if (chk->action != TCPCHK_ACT_COMMENT && chk->action != TCPCHK_ACT_ACTION_KW)
                        break;
        }
        if (&chk->list != rules && chk->action != TCPCHK_ACT_CONNECT) {
-               memprintf(errmsg, "first step MUST also be a 'connect' when there is a 'connect' step in the tcp-check ruleset");
+               memprintf(errmsg, "first step MUST also be a 'connect', "
+                         "optionnaly preceded by a 'set-var', an 'unset-var' or a 'comment', "
+                         "when there is a 'connect' step in the tcp-check ruleset");
                goto error;
        }
 
@@ -4367,9 +4423,16 @@ static int proxy_parse_tcpcheck(char **args, int section, struct proxy *curpx,
        else if (strcmp(args[cur_arg], "comment") == 0)
                chk = parse_tcpcheck_comment(args, cur_arg, rules, errmsg);
        else {
-               memprintf(errmsg, "'%s %s' only supports 'comment', 'connect', 'send', 'send-binary' or 'expect'.",
-                         args[0], args[1]);
-               goto error;
+               struct action_kw *kw = action_kw_tcp_check_lookup(args[cur_arg]);
+
+               if (!kw) {
+                       action_kw_tcp_check_build_list(&trash);
+                       memprintf(errmsg, "'%s' only supports 'comment', 'connect', 'send', 'send-binary', 'expect'"
+                                 "%s%s. but got '%s'",
+                                 args[0], (*trash.area ? ", " : ""), trash.area, args[1]);
+                       goto error;
+               }
+               chk = parse_tcpcheck_action(args, cur_arg, curpx, rules, kw, errmsg);
        }
 
        if (!chk) {
index d602887b8fc370740c6acc07e38af9fba61f5034..6cf805aed9adb99bf5e27ee866d1fe2ac870e267 100644 (file)
@@ -73,7 +73,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL),
 
        [SMP_SRC_LISTN] = (SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT |
                           SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK |
@@ -81,7 +81,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL___________),
 
        [SMP_SRC_FTEND] = (SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT |
                           SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK |
@@ -89,7 +89,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL___________),
 
        [SMP_SRC_L4CLI] = (SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT |
                           SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK |
@@ -97,7 +97,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL),
 
        [SMP_SRC_L5CLI] = (SMP_VAL___________ | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT |
                           SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK |
@@ -105,7 +105,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL___________),
 
        [SMP_SRC_TRACK] = (SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT |
                           SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK |
@@ -113,7 +113,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL___________),
 
        [SMP_SRC_L6REQ] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_FE_REQ_CNT |
                           SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK |
@@ -121,7 +121,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
-                          SMP_VAL___________),
+                          SMP_VAL___________ | SMP_VAL___________),
 
        [SMP_SRC_HRQHV] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_FE_REQ_CNT |
                           SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK |
@@ -129,7 +129,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
-                          SMP_VAL___________),
+                          SMP_VAL___________ | SMP_VAL___________),
 
        [SMP_SRC_HRQHP] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_FE_REQ_CNT |
                           SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK |
@@ -137,7 +137,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL___________),
 
        [SMP_SRC_HRQBO] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK |
@@ -145,7 +145,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
-                          SMP_VAL___________),
+                          SMP_VAL___________ | SMP_VAL___________),
 
        [SMP_SRC_BKEND] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -153,7 +153,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL),
 
        [SMP_SRC_SERVR] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -161,7 +161,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL),
 
        [SMP_SRC_L4SRV] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -169,7 +169,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL),
 
        [SMP_SRC_L5SRV] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -177,7 +177,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL),
 
        [SMP_SRC_L6RES] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -185,7 +185,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL___________),
+                          SMP_VAL___________ | SMP_VAL___________),
 
        [SMP_SRC_HRSHV] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -193,7 +193,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL___________),
+                          SMP_VAL___________ | SMP_VAL___________),
 
        [SMP_SRC_HRSHP] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -201,7 +201,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_RES_CNT |
                           SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL___________),
 
        [SMP_SRC_HRSBO] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -209,7 +209,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL |
                           SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY |
-                          SMP_VAL___________),
+                          SMP_VAL___________ | SMP_VAL___________),
 
        [SMP_SRC_RQFIN] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -217,7 +217,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL___________),
 
        [SMP_SRC_RSFIN] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -225,7 +225,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL___________),
 
        [SMP_SRC_TXFIN] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -233,7 +233,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL___________),
 
        [SMP_SRC_SSFIN] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
@@ -241,7 +241,7 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = {
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
                           SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ |
-                          SMP_VAL_FE_LOG_END),
+                          SMP_VAL_FE_LOG_END | SMP_VAL___________),
 };
 
 static const char *fetch_src_names[SMP_SRC_ENTRIES] = {
@@ -289,6 +289,7 @@ static const char *fetch_ckp_names[SMP_CKP_ENTRIES] = {
        [SMP_CKP_FE_HRS_HDR] = "frontend http-response header rule",
        [SMP_CKP_FE_HRS_BDY] = "frontend http-response body rule",
        [SMP_CKP_FE_LOG_END] = "logs",
+       [SMP_CKP_BE_CHK_RUL] = "backend tcp-check rule",
 };
 
 /* This function returns the type of the data returned by the sample_expr.
index 0b7b990019745ef93e51c0c97f2843e68477c215..7f3d2d0cf3f172d66659afda3aa3e901b218fd7a 100644 (file)
@@ -788,6 +788,7 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy
        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;
        default:
                memprintf(err,
                          "internal error, unexpected rule->from=%d, please report this bug!",
@@ -903,6 +904,14 @@ static struct action_kw_list tcp_res_kws = { { }, {
 
 INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_kws);
 
+static struct action_kw_list tcp_check_kws = {ILH, {
+       { "set-var",   parse_store, 1 },
+       { "unset-var", parse_store, 1 },
+       { /* END */ }
+}};
+
+INITCALL1(STG_REGISTER, tcp_check_keywords_register, &tcp_check_kws);
+
 static struct action_kw_list http_req_kws = { { }, {
        { "set-var",   parse_store, 1 },
        { "unset-var", parse_store, 1 },