]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: backend: fix reuse with set-dst/set-dst-port
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 31 Mar 2025 15:57:56 +0000 (17:57 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 2 Apr 2025 12:57:40 +0000 (14:57 +0200)
On backend connection reuse, a hash is calculated from various
parameters, to ensure the selected connection match the requested
parameters. Notably, destination address is one of these parameters.
However, it is only taken into account if using a transparent server
(server address 0.0.0.0).

This may cause issue where an incorrect connection is reused, which is
not targetted to the correct destination address. This may be the case
if a set-dst/set-dst-port is used with a transparent proxy (proxy option
transparent).

The fix is simple enough. Destination address is now always used as
input to the connection reuse hash.

This must be backported up to 2.6. Note that for reverse HTTP to work,
it relies on the following patch, which ensures destination address
remains NULL in this case.

  commit e94baf6ca71cb2319610baa74dbf17b9bc602b18
  BUG/MINOR: rhttp: fix incorrect dst/dst_port values

src/backend.c

index 1791a38e6d92c0d3cdabb3a444b1942812cefa14..b897c15515dd7cdf73d9847211cf78c8572eef9c 100644 (file)
@@ -1597,8 +1597,7 @@ int connect_server(struct stream *s)
        }
 
        /* 3. destination address */
-       if (srv && srv_is_transparent(srv))
-               hash_params.dst_addr = s->scb->dst;
+       hash_params.dst_addr = s->scb->dst;
 
        /* 4. source address */
        hash_params.src_addr = bind_addr;