]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: log-forward: Fix log-forward proxies not fully initialized
authorEmeric Brun <ebrun@haproxy.com>
Thu, 18 Aug 2022 13:53:21 +0000 (15:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 19 Aug 2022 14:08:03 +0000 (16:08 +0200)
Some initialisation for log forward proxies was missing such
as ssl configuration on 'log-forward's 'bind' lines.

After the loop on the proxy initialization code for proxies present
in the main proxies list, this patch force to loop again on this code
for proxies present in the log forward proxies list.

Those two lists should be merged. This will be part of a global
re-work of proxy initialization including peers proxies and resolver
proxies.

This patch was made in first attempt to fix the bug and to facilitate
the backport on older branches waiting for a cleaner re-work on proxies
initialization on the dev branch.

This patch should be backported as far as 2.3.

src/cfgparse.c

index fc447d6eb5e2a45539fdcf696ae5454fab1efbca..989f313a9349a271a3dc7339cb29ec786abaa1fa 100644 (file)
@@ -2453,6 +2453,7 @@ int check_config_validity()
 {
        int cfgerr = 0;
        struct proxy *curproxy = NULL;
+       struct proxy *init_proxies_list = NULL;
        struct stktable *t;
        struct server *newsrv = NULL;
        int err_code = 0;
@@ -2532,7 +2533,11 @@ int check_config_validity()
                proxies_list = next;
        }
 
-       for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
+       /* starting to initialize the main proxies list */
+       init_proxies_list = proxies_list;
+
+init_proxies_list_stage1:
+       for (curproxy = init_proxies_list; curproxy; curproxy = curproxy->next) {
                struct switching_rule *rule;
                struct server_rule *srule;
                struct sticking_rule *mrule;
@@ -2728,11 +2733,16 @@ int check_config_validity()
                case PR_MODE_CLI:
                        cfgerr += proxy_cfg_ensure_no_http(curproxy);
                        break;
+
                case PR_MODE_SYSLOG:
+                       /* this mode is initialized as the classic tcp proxy */
+                       cfgerr += proxy_cfg_ensure_no_http(curproxy);
+                       break;
+
                case PR_MODE_PEERS:
                case PR_MODES:
                        /* should not happen, bug gcc warn missing switch statement */
-                       ha_alert("%s '%s' cannot use peers or syslog mode for this proxy. NOTE: PLEASE REPORT THIS TO DEVELOPERS AS YOU'RE NOT SUPPOSED TO BE ABLE TO CREATE A CONFIGURATION TRIGGERING THIS!\n",
+                       ha_alert("%s '%s' cannot initialize this proxy mode (peers) in this way. NOTE: PLEASE REPORT THIS TO DEVELOPERS AS YOU'RE NOT SUPPOSED TO BE ABLE TO CREATE A CONFIGURATION TRIGGERING THIS!\n",
                                 proxy_type_str(curproxy), curproxy->id);
                        cfgerr++;
                        break;
@@ -3890,6 +3900,15 @@ out_uri_auth_compat:
                }
        }
 
+       /*
+        * We have just initialized the main proxies list
+        * we must also configure the log-forward proxies list
+        */
+       if (init_proxies_list == proxies_list) {
+               init_proxies_list = cfg_log_forward;
+               goto init_proxies_list_stage1;
+       }
+
        /***********************************************************/
        /* At this point, target names have already been resolved. */
        /***********************************************************/
@@ -3943,7 +3962,11 @@ out_uri_auth_compat:
 
        /* perform the final checks before creating tasks */
 
-       for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
+       /* starting to initialize the main proxies list */
+       init_proxies_list = proxies_list;
+
+init_proxies_list_stage2:
+       for (curproxy = init_proxies_list; curproxy; curproxy = curproxy->next) {
                struct listener *listener;
                unsigned int next_id;
 
@@ -4029,6 +4052,15 @@ out_uri_auth_compat:
                }
        }
 
+       /*
+        * We have just initialized the main proxies list
+        * we must also configure the log-forward proxies list
+        */
+       if (init_proxies_list == proxies_list) {
+               init_proxies_list = cfg_log_forward;
+               goto init_proxies_list_stage2;
+       }
+
        if (diag_no_cluster_secret)
                ha_diag_warning("No cluster secret was set. The stateless reset and Retry"
                                " features are disabled for all QUIC bindings.\n");