From: Willy Tarreau Date: Fri, 10 Jun 2022 09:11:44 +0000 (+0200) Subject: BUG/MINOR: server: do not enable DNS resolution on disabled proxies X-Git-Tag: v2.7-dev1~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b46fb4cca9ab673be8d1cdce6876a4abaa7918e;p=thirdparty%2Fhaproxy.git BUG/MINOR: server: do not enable DNS resolution on disabled proxies Leonhard Wimmer reported an interesting bug in github issue #1742. Servers in disabled proxies that are configured for resolution are still subscribed to DNS resolutions, but the LB algos are not initialized at all since the proxy is disabled, so when the server state changes, attempts to update its status cause a crash when the server's weight is recalculated via a divide by the proxy's total weight which is zero. This should be backported to all versions. Beware that before 2.5 or so, there's no PR_FL_DISABLED flag, instead px->disabled should be used (2.3-2.4) or PR_STSTOPPED for older versions. Thanks to Leonhard for his report and quick test! --- diff --git a/src/resolvers.c b/src/resolvers.c index 73968917c2..ac6b23dd4b 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -2528,6 +2528,13 @@ static int resolvers_finalize_config(void) for (px = proxies_list; px; px = px->next) { struct server *srv; + if (px->flags & PR_FL_DISABLED) { + /* must not run and will not work anyway since + * nothing in the proxy is initialized. + */ + continue; + } + for (srv = px->srv; srv; srv = srv->next) { struct resolvers *resolvers;