]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: sink: detect and warn when using "send-proxy" options with ring servers
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 15 May 2025 13:54:13 +0000 (15:54 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 15 May 2025 14:18:31 +0000 (16:18 +0200)
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

index f85f43e55da346c89725b53bd60e6c85df0c25db..a801f697d8fb6ba67fbc64be1b553cbd7ed9f91f 100644 (file)
@@ -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) {