mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-27 23:22:09 +00:00
BUG/MEDIUM: server/lbprm: fix crash in _srv_set_inetaddr_port()
Sincefaa8c3e
("MEDIUM: lb-chash: Deterministic node hashes based on server address") the following configuration will cause haproxy to crash: backend test1 mode http balance hash int(1) server s1 haproxy.org:80 This is because lbprm.update_server_eweight() method is now systematically called in _srv_set_inetaddr_port() upon srv addr/port change (and with the above config it happens during startup after initial dns resolution). However, depending on the chosen lbprm algo, update_server_eweight function may not be set (it is not a mandatory method, some lb implementations don't define it). Thus, using 'balance hash' with map-based hashing or 'balance sticky' will cause a crash due to a NULL de-reference in _srv_set_inetaddr_port(). To fix the issue, we first check that the update_server_eweight() method is set before using it. No backport needed unlessfaa8c3e
("MEDIUM: lb-chash: Deterministic node hashes based on server address") gets backported.
This commit is contained in:
parent
0e14bac7bd
commit
837a26ab05
@ -184,8 +184,10 @@ static void _srv_set_inetaddr_port(struct server *srv,
|
||||
else
|
||||
srv->flags &= ~SRV_F_MAPPORTS;
|
||||
|
||||
/* balancers (chash in particular) may use the addr in their routing decisions */
|
||||
srv->proxy->lbprm.update_server_eweight(srv);
|
||||
if (srv->proxy->lbprm.update_server_eweight) {
|
||||
/* some balancers (chash in particular) may use the addr in their routing decisions */
|
||||
srv->proxy->lbprm.update_server_eweight(srv);
|
||||
}
|
||||
|
||||
if (srv->log_target && srv->log_target->type == LOG_TARGET_DGRAM) {
|
||||
/* server is used as a log target, manually update log target addr for DGRAM */
|
||||
|
Loading…
Reference in New Issue
Block a user