]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server-state: Don't load server-state file for disabled backends
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 4 Mar 2021 15:35:26 +0000 (16:35 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 4 Mar 2021 15:49:10 +0000 (16:49 +0100)
Recent changes on the server-state file loading have introduced a
regression. HAproxy crashes if a backend with no server-state file is
disabled in the configuration. Indeed, configuration of such backends is not
finalized. Thus many fields are not defined.

To fix the bug, disabled backends must be ignored. In addition a BUG_ON()
has been added to verify the proxy mode regarding the server-state file. It
must be specified (none, global or local) for enabled backends.

No backport needed.

src/server_state.c

index 302ffb34dd94a7d8d7f929f63725ec9e9f55f5e3..a4df1fa7d05e8bed8e90f2e787eebc8d37308593 100644 (file)
@@ -815,10 +815,13 @@ void apply_server_state(void)
        for (curproxy = proxies_list; curproxy != NULL; curproxy = curproxy->next) {
                struct eb_root local_state_tree = EB_ROOT_UNIQUE;
 
-               /* servers are only in backends */
-               if (!(curproxy->cap & PR_CAP_BE) || !curproxy->srv)
+               /* Must be an enabled backend with at least a server */
+               if (!(curproxy->cap & PR_CAP_BE) || curproxy->disabled || !curproxy->srv)
                        continue; /* next proxy */
 
+               /* Mode must be specified */
+               BUG_ON(curproxy->load_server_state_from_file == PR_SRV_STATE_FILE_UNSPEC);
+
                /* No server-state file for this proxy */
                if (curproxy->load_server_state_from_file == PR_SRV_STATE_FILE_NONE)
                        continue;  /* next proxy */