BUG/MINOR: cfgparse/peers: properly handle ignored local peer case
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 6 Mar 2025 08:29:05 +0000 (09:29 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Mar 2025 15:01:04 +0000 (16:01 +0100)
commit6bd743efe66a2ce28b7bf125b7c145c30cb305f7
tree9772323d57961814eff7ae2bc59b35c26cd85144
parentfb5130fc8f0d942acf2afd20a02f6d7b35eb5a35
BUG/MINOR: cfgparse/peers: properly handle ignored local peer case

In 8ba10fea6 ("BUG/MINOR: peers: Incomplete peers sections should be
validated."), some checks were relaxed in parse_server(), and extra logic
was added in the peers section parser in an attempt to properly ignore
incomplete "server" or "peer" statement under peers section.

This was done in response to GH #565, the main intent was that haproxy
should already complain about incomplete peers section (ie: missing
localpeer).

However, 8ba10fea69 explicitly skipped the peer cleanup upon missing
srv association for local peers. This is wrong because later haproxy
code always assumes that peer->srv is valid. Indeed, we got reports
that the (invalid) config below would cause segmentation fault on
all stable versions:

 global
   localpeer 01JM0TEPAREK01FQQ439DDZXD8

 peers my-table
   peer 01JM0TEPAREK01FQQ439DDZXD8

 listen dummy
   bind localhost:8080

To fix the issue, instead of by-passing some cleanup for the local
peer, handle this case specifically by doing the regular peer cleanup
and reset some fields set on the curpeers and curpeers proxy because
of the invalid local peer (do as if the peer was not declared).

It should still comply with requirements from #565.

This patch should be backported to all stable versions.

(cherry picked from commit 054443dfb908521e30aa57335dbcb5f9cd6f7218)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/cfgparse.c