]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stktable: allow sc-set-gpt(0) from tcp-request connection
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 9 Aug 2023 15:23:32 +0000 (17:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Aug 2023 07:03:44 +0000 (09:03 +0200)
Both the documentation and original developer intents seem to suggest
that sc-set-gpt/sc-set-gpt0 actions should be available from
tcp-request connection.

Yet because it was probably forgotten when expr support was added to
sc-set-gpt0 in 0d7712dff0 ("MINOR: stick-table: allow sc-set-gpt0 to
set value from an expression") it doesn't work and will report this
kind of errors:
 "internal error, unexpected rule->from=0, please report this bug!"

Fixing the code to comply with the documentation and the expected
behavior.

This must be backported to every stable versions.

[for < 2.5, as only sc-set-gpt0 existed back then, the patch must be
manually applied to skip irrelevant parts]

src/stick_table.c

index 4ca83a37719bfb226fbe85a4b71eacb4b13d1b6e..48fdaa4396452e58b97a730ff0b652a3cd7bdb99 100644 (file)
@@ -2709,6 +2709,7 @@ static enum act_return action_set_gpt(struct act_rule *rule, struct proxy *px,
                        value = (unsigned int)(rule->arg.gpt.value);
                else {
                        switch (rule->from) {
+                       case ACT_F_TCP_REQ_CON: smp_opt_dir = SMP_OPT_DIR_REQ; break;
                        case ACT_F_TCP_REQ_SES: smp_opt_dir = SMP_OPT_DIR_REQ; break;
                        case ACT_F_TCP_REQ_CNT: smp_opt_dir = SMP_OPT_DIR_REQ; break;
                        case ACT_F_TCP_RES_CNT: smp_opt_dir = SMP_OPT_DIR_RES; break;
@@ -2777,6 +2778,7 @@ static enum act_return action_set_gpt0(struct act_rule *rule, struct proxy *px,
                        value = (unsigned int)(rule->arg.gpt.value);
                else {
                        switch (rule->from) {
+                       case ACT_F_TCP_REQ_CON: smp_opt_dir = SMP_OPT_DIR_REQ; break;
                        case ACT_F_TCP_REQ_SES: smp_opt_dir = SMP_OPT_DIR_REQ; break;
                        case ACT_F_TCP_REQ_CNT: smp_opt_dir = SMP_OPT_DIR_REQ; break;
                        case ACT_F_TCP_RES_CNT: smp_opt_dir = SMP_OPT_DIR_RES; break;
@@ -2904,6 +2906,7 @@ static enum act_parse_ret parse_set_gpt(const char **args, int *arg, struct prox
                        return ACT_RET_PRS_ERR;
 
                switch (rule->from) {
+               case ACT_F_TCP_REQ_CON: smp_val = SMP_VAL_FE_CON_ACC; break;
                case ACT_F_TCP_REQ_SES: smp_val = SMP_VAL_FE_SES_ACC; break;
                case ACT_F_TCP_REQ_CNT: smp_val = SMP_VAL_FE_REQ_CNT; break;
                case ACT_F_TCP_RES_CNT: smp_val = SMP_VAL_BE_RES_CNT; break;