BUG/MINOR: server: accept server IDs above 2^31 and clarify error message

Due to the check of the stored value instead of the parsed one, it was not
permitted to use server IDs above 2^31 while they are perfectly possible.
Let's refine the parsing and also update the error message to indicate the
range. The doc was also refined to reflect the relation with hash-key.

This may be backported though it wouldn't have any effect on working
configs.
This commit is contained in:
Willy Tarreau 2026-05-19 16:59:37 +02:00
parent f2b152c95e
commit f2bf3483ba
2 changed files with 12 additions and 7 deletions

View file

@ -18876,9 +18876,13 @@ healthcheck <name>
id <value>
May be used in the following contexts: tcp, http, log
Set a persistent ID for the server. This ID must be positive and unique for
the proxy. An unused ID will automatically be assigned if unset. The first
assigned value will be 1. This ID is currently only returned in statistics.
Set a persistent ID for the server. This ID must be a 32-bit positive number
and unique for the proxy. An unused ID will automatically be assigned if
unset. The first assigned value will be 1. This ID is currently only returned
in statistics, and is used to place LB nodes when using consistent hash
algorithms when "hash-key" is set to "id" (the default). In this case, only
the 28 lowest bits of the value are used (i.e. (id % 268435356)), so better
only use values comprised between 1 and this value to avoid overlap.
idle-ping <delay>
May be used in the following contexts: tcp, http, log

View file

@ -1313,19 +1313,20 @@ static int srv_parse_pool_max_conn(char **args, int *cur_arg, struct proxy *curp
static int srv_parse_id(char **args, int *cur_arg, struct proxy *curproxy, struct server *newsrv, char **err)
{
struct server *target;
llong id;
if (!*args[*cur_arg + 1]) {
memprintf(err, "'%s' : expects an integer argument", args[*cur_arg]);
return ERR_ALERT | ERR_FATAL;
}
newsrv->puid = atol(args[*cur_arg + 1]);
if (newsrv->puid <= 0) {
memprintf(err, "'%s' : custom id has to be > 0", args[*cur_arg]);
id = atol(args[*cur_arg + 1]);
if (id < 1 || id > ~0U) {
memprintf(err, "'%s' : custom id has to be between 1 and 4294967295.", args[*cur_arg]);
return ERR_ALERT | ERR_FATAL;
}
newsrv->puid = id;
target = server_find_by_id(curproxy, newsrv->puid);
if (target) {
memprintf(err, "'%s' : custom id %d already used at %s:%d ('server %s')",