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
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')",