]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: proxy: always initialize the default settings after init
authorWilly Tarreau <w@1wt.eu>
Mon, 13 Nov 2023 08:17:05 +0000 (09:17 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 Nov 2023 08:17:05 +0000 (09:17 +0100)
The proxy's initialization is rather odd. First, init_new_proxy() is
called to zero all the lists and certain values, except those that can
come from defaults, which are initialized by proxy_preset_defaults().
The default server settings are also only set there.

This results in these settings not to be set for a number of internal
proxies that do not explicitly call proxy_preset_defaults() after
allocation, such as sink and log forwarders.

This was revealed by last commit 79aa63823 ("MINOR: server: always
initialize pp_tlvs for default servers") which crashes in log parsers
when applied to certain proxies which did not initialize their default
servers.

In theory this should be backported, however it would be desirable to
wait a bit before backporting it, in case certain parts would rely on
these elements not being initialized.

src/cfgparse-listen.c
src/hlua.c
src/http_client.c
src/proxy.c

index 6c7cc6382adf9602519ee1a2c8fb58c274b96351..70820bab4923a7ef2bbcc78c425a86dc1911ecf7 100644 (file)
@@ -213,7 +213,6 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
        if (!last_defproxy) {
                /* we need a default proxy and none was created yet */
                last_defproxy = alloc_new_proxy("", PR_CAP_DEF|PR_CAP_LISTEN, &errmsg);
-               proxy_preset_defaults(last_defproxy);
 
                curr_defproxy = last_defproxy;
                if (!last_defproxy) {
index c5a1c615bd06dbb69e4d49b6b7fda37d2b50af7c..d1b28b939b67d5447c297dc0b3fc03f29baefddd 100644 (file)
@@ -13877,7 +13877,6 @@ void hlua_init(void) {
                fprintf(stderr, "Lua init: %s\n", errmsg);
                exit(1);
        }
-       proxy_preset_defaults(socket_proxy);
 
        /* Init TCP server: unchanged parameters */
        socket_tcp = new_server(socket_proxy);
index fca13a29761c4554d0937440846df966b15b3586..3e761b81afef67df96e9994545b3a2563e113eac 100644 (file)
@@ -1213,8 +1213,6 @@ struct proxy *httpclient_create_proxy(const char *id)
                goto err;
        }
 
-       proxy_preset_defaults(px);
-
        px->options |= PR_O_WREQ_BODY;
        px->retry_type |= PR_RE_CONN_FAILED | PR_RE_DISCONNECTED | PR_RE_TIMEOUT;
        px->options2 |= PR_O2_INDEPSTR;
index 544c22f826987a63e18ae5e8e3946cddd7f3bb19..f1b81f6f8a58f22f2343b937e47d8b5b17c7c9fb 100644 (file)
@@ -1430,6 +1430,9 @@ void init_new_proxy(struct proxy *p)
        p->extra_counters_be = NULL;
 
        HA_RWLOCK_INIT(&p->lock);
+
+       /* initialize the default settings */
+       proxy_preset_defaults(p);
 }
 
 /* Preset default settings onto proxy <defproxy>. */
@@ -1946,9 +1949,6 @@ struct proxy *parse_new_proxy(const char *name, unsigned int cap,
                        return NULL;
                }
        }
-       else {
-               proxy_preset_defaults(curproxy);
-       }
 
        curproxy->conf.args.file = curproxy->conf.file = strdup(file);
        curproxy->conf.args.line = curproxy->conf.line = linenum;