diff --git a/doc/configuration.txt b/doc/configuration.txt index 0d6ba70d1..65dafcb5d 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -18876,9 +18876,13 @@ healthcheck id 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 May be used in the following contexts: tcp, http, log diff --git a/src/server.c b/src/server.c index 9d6a2f481..819e1c05a 100644 --- a/src/server.c +++ b/src/server.c @@ -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')",