From 098a5e5c0b9e6821c03945295dd1350e5d834eb3 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Thu, 15 May 2025 15:54:13 +0200 Subject: [PATCH] BUG/MINOR: sink: detect and warn when using "send-proxy" options with ring servers using "send-proxy" or "send-proxy-v2" option on a ring server is not relevant nor supported. Worse, on 2.4 it causes haproxy process to crash as reported in GH #2965. Let's be more explicit about the fact that this keyword is not supported under "ring" context by ignoring the option and emitting a warning message to inform the user about that. Ideally, we should do the same for peers and log servers. The proper way would be to check servers options during postparsing but we currently lack proper cross-type server postparsing hooks. This will come later and thus will give us a chance to perform the compatibilty checks for server options depending on proxy type. But for now let's simply fix the "ring" case since it is the only one that's known to cause a crash. It may be backported to all stable versions. --- src/sink.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/sink.c b/src/sink.c index f85f43e55..a801f697d 100644 --- a/src/sink.c +++ b/src/sink.c @@ -1088,6 +1088,19 @@ int cfg_parse_ring(const char *file, int linenum, char **args, int kwm) err_code |= parse_server(file, linenum, args, cfg_sink->forward_px, NULL, SRV_PARSE_PARSE_ADDR|SRV_PARSE_INITIAL_RESOLVE); + + if (err_code & ERR_CODE) + goto err; + + /* FIXME: ideally this check should be performed during server postparsing + * for all proxies where this option is unsupported, but for now we lack + * server postparsing rules for sinks so let's put that here + */ + if (cfg_sink->forward_px->srv && cfg_sink->forward_px->srv->pp_opts) { + cfg_sink->forward_px->srv->pp_opts = 0; + ha_warning("parsing [%s:%d] : 'send-proxy*' server option is unsupported there, ignoring it\n", file, linenum); + err_code |= ERR_WARN; + } } else if (strcmp(args[0],"timeout") == 0) { if (!cfg_sink || !cfg_sink->forward_px) {