BUG/MINOR: server/event_hdl: propagate map port info through inetaddr event
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 7 Dec 2023 16:08:08 +0000 (17:08 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 2 Jan 2024 06:49:40 +0000 (07:49 +0100)
commitb213205f423ae211533f3264bb9d81cd2e4c4c65
tree16c7216a873638695650d447dd8c0f9e890a140d
parent4ec082db440630431ba6d034138f0bd724472590
BUG/MINOR: server/event_hdl: propagate map port info through inetaddr event

server addr:svc_port updates during runtime might set or clear the
SRV_F_MAPPORTS flag. Unfortunately, the flag update is still directly
performed by srv_update_addr_port() function while the addr:svc_port
update is being scheduled for atomic update. Given that existing readers
don't take server's lock to read addr:svc_port, they also check the
SRV_F_MAPPORTS flag right after without the lock.

So we could cause the readers to incorrectly interpret the svc_port from
the server struct because the mapport information is not published
atomically, resulting in inconsistencies between svc_port / mapport flag.
(MAPPORTS flag causes svc_port to be used differently by the reader)

To fix this, we publish the mapport information within the INETADDR server
event and we let the task responsible for updating server's addr and port
position or clear the flag depending on the mapport hint.

This patch depends on:
 - MINOR: server/event_hdl: add server_inetaddr struct to facilitate event data usage
 - MINOR: server/event_hdl: update _srv_event_hdl_prepare_inetaddr prototype

This should be backported in 2.9 with 683b2ae01 ("MINOR: server/event_hdl:
add SERVER_INETADDR event")

(cherry picked from commit 545e72546c0d729fd3de0f753adc905dd0b13908)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
include/haproxy/server-t.h
src/server.c