]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server: make srv_alloc_lb() allocate lb_nodes for consistent hash
authorWilly Tarreau <w@1wt.eu>
Tue, 20 Apr 2021 09:37:45 +0000 (11:37 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 20 Apr 2021 09:39:54 +0000 (11:39 +0200)
The test in srv_alloc_lb() to allocate the lb_nodes[] array used in the
consistent hash was incorrect, it wouldn't do it for consistent hash and
could do it for regular random.

No backport is needed as this was added for dynamic servers in 2.4-dev by
commit f99f77a50 ("MEDIUM: server: implement 'add server' cli command").

src/server.c

index 3f05904fdd19c9bcd41345e81c1ffae61240b9f0..fb7b750c7fbc48afb8262e1ef9a5c6343874d2d3 100644 (file)
@@ -4299,7 +4299,8 @@ static int srv_alloc_lb(struct server *sv, struct proxy *be)
        sv->lb_nodes_tot = sv->uweight * BE_WEIGHT_SCALE;
        sv->lb_nodes_now = 0;
 
-       if ((be->lbprm.algo & BE_LB_PARM) == BE_LB_RR_RANDOM) {
+       if (((be->lbprm.algo & (BE_LB_KIND | BE_LB_PARM)) == (BE_LB_KIND_RR | BE_LB_RR_RANDOM)) ||
+           ((be->lbprm.algo & (BE_LB_KIND | BE_LB_HASH_TYPE)) == (BE_LB_KIND_HI | BE_LB_HASH_CONS))) {
                sv->lb_nodes = calloc(sv->lb_nodes_tot, sizeof(*sv->lb_nodes));
 
                if (!sv->lb_nodes)