BUG/MINOR: stick-table: fix the sc-set-gpt* parser when using expressions
authorWilly Tarreau <w@1wt.eu>
Tue, 24 Aug 2021 12:57:28 +0000 (14:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Sep 2021 14:23:40 +0000 (16:23 +0200)
commit01f6b58a67d9c7e81f91eb6437c4699fb10508b0
treec7b519ef2ace121139393c8e851c600330a5d1a3
parenta12d1f149a802a5afd179baa8abd2f507a5b11d1
BUG/MINOR: stick-table: fix the sc-set-gpt* parser when using expressions

The sc-set-gpt0() parser was extended in 2.1 by commit 0d7712dff ("MINOR:
stick-table: allow sc-set-gpt0 to set value from an expression") to support
sample expressions in addition to plain integers. However there is a
subtlety there, which is that while the arg position must be incremented
when parsing an integer, it must not be touched when calling an expression
since the expression parser already does it.

The effect is that rules making use of sc-set-gpt0() followed by an
expression always ignore one word after that expression, and will typically
fail to parse if followed by an "if" as the parser will restart after the
"if". With no condition it's different because an empty condition doesn't
result in trying to parse anything.

This patch moves the increment at the right place and adds a few
explanations for a code part that was far from being obvious.

This should be backported to branches having the commit above (2.1+).

(cherry picked from commit ece4c4a35265cbc28d25826205ee66dbf9ac6f7d)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit f1e1c91953c28f48a5b0bfde8e616b16c33ebb26)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/stick_table.c