CLEANUP: cfgparse: lookup proxy ID using existing functions

The code used to detect proxy id conflicts uses an open-coded lookup
in the ID tree which is not necessary since we already have functions
for this. Let's switch to that instead.
This commit is contained in:
Willy Tarreau 2025-07-09 16:13:44 +02:00
parent 31526f73e6
commit a3443db2eb

View File

@ -710,7 +710,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
} }
} }
else if (strcmp(args[0], "id") == 0) { else if (strcmp(args[0], "id") == 0) {
struct eb32_node *node; struct proxy *conflict;
if (curproxy->cap & PR_CAP_DEF) { if (curproxy->cap & PR_CAP_DEF) {
ha_alert("parsing [%s:%d]: '%s' not allowed in 'defaults' section.\n", ha_alert("parsing [%s:%d]: '%s' not allowed in 'defaults' section.\n",
@ -740,12 +740,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
goto out; goto out;
} }
node = eb32_lookup(&used_proxy_id, curproxy->uuid); conflict = proxy_find_by_id(curproxy->uuid, 0, 0);
if (node) { if (conflict) {
struct proxy *target = container_of(node, struct proxy, conf.id);
ha_alert("parsing [%s:%d]: %s %s reuses same custom id as %s %s (declared at %s:%d).\n", ha_alert("parsing [%s:%d]: %s %s reuses same custom id as %s %s (declared at %s:%d).\n",
file, linenum, proxy_type_str(curproxy), curproxy->id, file, linenum, proxy_type_str(curproxy), curproxy->id,
proxy_type_str(target), target->id, target->conf.file, target->conf.line); proxy_type_str(conflict), conflict->id, conflict->conf.file, conflict->conf.line);
err_code |= ERR_ALERT | ERR_FATAL; err_code |= ERR_ALERT | ERR_FATAL;
goto out; goto out;
} }