From: Willy Tarreau Date: Tue, 6 May 2025 08:54:48 +0000 (+0200) Subject: MINOR: stick-tables: add "ipv4" as an alias for the "ip" type X-Git-Tag: v3.2-dev15~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46b5dcad9957982583d25342ed7ad8c8b30d8b71;p=thirdparty%2Fhaproxy.git MINOR: stick-tables: add "ipv4" as an alias for the "ip" type 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. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 58d7b7bf6..90156a5ec 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -13558,7 +13558,7 @@ stick store-request [table ] [{if | unless} ] See also : "stick-table", "stick on", about ACLs and sample fetching. -stick-table type {ip | integer | string [len ] | binary [len ]} +stick-table type {ip|ipv4|ipv6|integer|string [len ]|binary [len ]} size [expire ] [nopurge] [peers ] [srvkey ] [write-to ] [store ]* [brates-factor ] [recv-only] @@ -13570,7 +13570,14 @@ stick-table type {ip | integer | string [len ] | binary [len ]} 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. diff --git a/src/stick_table.c b/src/stick_table.c index 31692082f..bf6ae3989 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -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;