]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: proxy: return "none" and "unknown" for unknown LB algos
authorWilly Tarreau <w@1wt.eu>
Sat, 26 Nov 2016 14:52:04 +0000 (15:52 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 26 Nov 2016 14:58:27 +0000 (15:58 +0100)
When a backend doesn't use any known LB algorithm, backend_lb_algo_str()
returns NULL. It used to cause "nil" to be printed in the stats dump
since version 1.4 but causes 1.7 to try to parse this NULL to encode
it as a CSV string, causing a crash on "show stat" in this case.

The only situation where this can happen is when "transparent" or
"dispatch" are used in a proxy, in which case the LB algorithm is
BE_LB_ALGO_NONE. Thus now we explicitly report "none" when this
situation is detected, and we preventively report "unknown" if any
unknown algorithm is detected, which may happen if such an algo is
added in the future and the function is not updated.

This fix must be backported to 1.7 and may be backported as far as
1.4, though it has less impact there.

src/backend.c

index 176a10a4b819872e6ccf288e30da073accf4b987..d34b5eca120a5d7215d58de18d91393035672bf0 100644 (file)
@@ -1429,8 +1429,10 @@ const char *backend_lb_algo_str(int algo) {
                return "hdr";
        else if (algo == BE_LB_ALGO_RCH)
                return "rdp-cookie";
+       else if (algo == BE_LB_ALGO_NONE)
+               return "none";
        else
-               return NULL;
+               return "unknown";
 }
 
 /* This function parses a "balance" statement in a backend section describing