]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stick-tables: add "ipv4" as an alias for the "ip" type
authorWilly Tarreau <w@1wt.eu>
Tue, 6 May 2025 08:54:48 +0000 (10:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 May 2025 08:11:55 +0000 (10:11 +0200)
However the doc purposely says the opposite, to encourage migrating away
from "ip". The goal is that in the future we change "ip" to mean "ipv6",
which seems to be what most users naturally expect. But we cannot break
configurations in the LTS version so for now "ipv4" is the alias.

The reason for not changing it in the table is that the type name is
used at a few places (look for "].kw"):
  - dumps
  - promex

We'd rather not change that output for 3.2, but only do it in 3.3.
This way, 3.2 can be made future-proof by using "ipv4" in the config
without any other side effect.

Please see github issue #2962 for updates on this transition.

doc/configuration.txt
src/stick_table.c

index 58d7b7bf698b67d0b24b989d11c2a2a7aa779ee4..90156a5eca1b77414b89b18626764a93f273c4af 100644 (file)
@@ -13558,7 +13558,7 @@ stick store-request <pattern> [table <table>] [{if | unless} <condition>]
   See also : "stick-table", "stick on", about ACLs and sample fetching.
 
 
-stick-table type {ip | integer | string [len <length>] | binary [len <length>]}
+stick-table type {ip|ipv4|ipv6|integer|string [len <length>]|binary [len <length>]}
             size <size> [expire <expire>] [nopurge] [peers <peersect>] [srvkey <srvkey>]
             [write-to <wtable>] [store <data_type>]* [brates-factor <factor>]
             [recv-only]
@@ -13570,7 +13570,14 @@ stick-table type {ip | integer | string [len <length>] | binary [len <length>]}
                                  no    |    yes   |   yes  |   yes
 
   Arguments :
-    ip         a table declared with "type ip" will only store IPv4 addresses.
+    ip         This type should be avoided in favor of a more explicit one such
+               as "ipv4" or "ipv6". Prior to version 3.2 it was the only way to
+               configure IPv4. In 3.2, "ip" is an alias for "ipv4", and "ipv4"
+               is preferred. In a future version, "ip" will instead correspond
+               to "ipv6". It is only meant to ease the transition from pre-3.2
+               to post-3.2.
+
+    ipv4       a table declared with this type will only store IPv4 addresses.
                This form is very compact (about 50 bytes per entry) and allows
                very fast entry lookup and stores with almost no overhead. This
                is mainly used to store client source IP addresses.
index 31692082fd7b00aae4b074e95813eabb5fc670ac..bf6ae39898863d80b83e479b615a404f14ff5366 100644 (file)
@@ -1133,10 +1133,16 @@ struct stktable_type stktable_types[SMP_TYPES] = {
  */
 int stktable_parse_type(char **args, int *myidx, unsigned long *type, size_t *key_size, const char *file, int linenum)
 {
+       const char *kw = args[*myidx];
+
+       /* Planning for future changes, for now "ipv4" is an alias for "ip" */
+       if (strcmp(kw, "ipv4") == 0)
+               kw = "ip";
+
        for (*type = 0; *type < SMP_TYPES; (*type)++) {
                if (!stktable_types[*type].kw)
                        continue;
-               if (strcmp(args[*myidx], stktable_types[*type].kw) != 0)
+               if (strcmp(kw, stktable_types[*type].kw) != 0)
                        continue;
 
                *key_size =  stktable_types[*type].default_size;