From: Willy Tarreau Date: Wed, 9 Jul 2025 14:13:44 +0000 (+0200) Subject: CLEANUP: cfgparse: lookup proxy ID using existing functions X-Git-Tag: v3.3-dev4~92 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a3443db2eb2f7ab33b4b6a3091956b8518099384;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index eaf07379a..bcc36c938 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -710,7 +710,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) } } else if (strcmp(args[0], "id") == 0) { - struct eb32_node *node; + struct proxy *conflict; if (curproxy->cap & PR_CAP_DEF) { 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; } - node = eb32_lookup(&used_proxy_id, curproxy->uuid); - if (node) { - struct proxy *target = container_of(node, struct proxy, conf.id); + conflict = proxy_find_by_id(curproxy->uuid, 0, 0); + if (conflict) { 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, - 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; goto out; }