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.
This commit is contained in:
Willy Tarreau 2025-05-06 10:54:48 +02:00
parent 697a531516
commit 46b5dcad99
2 changed files with 16 additions and 3 deletions

View 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.

View 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;