]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: log: gracefully handle the "udp@" address format for log servers
authorWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 17:58:34 +0000 (19:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 18:11:52 +0000 (20:11 +0200)
Commit 3835c0dcb ("MEDIUM: udp: adds minimal proto udp support for
message listeners.") introduced a problematic side effect in log server
address parser: if "udp@", "udp4@" or "udp6@" prefixes a log server's
address, the adress is passed as-is to the log server with a non-existing
family and fails like this when trying to send:

  [ALERT] 259/195708 (3474) : socket() failed in logger #1: Address family not supported by protocol (errno=97)

The problem is that till now there was no UDP family, so logs expect an
AF_INET family to be passed for UDP there.

This patch manually remaps AF_CUST_UDP4 and AF_CUST_UDP6 to their "tcp"
equivalent that the log server parser expects. No backport is needed.

src/log.c

index 5f71bfe35f520f3c0f160fe36abeebecad0c71d4..c1c6eda3cd4076bf6d6226aa3c9a8bfa517bd672 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1026,6 +1026,12 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err)
                goto error;
        logsrv->addr = *sk;
 
+       /* handle nicely the case where "udp@" is forced */
+       if (sk->ss_family == AF_CUST_UDP4)
+               sk->ss_family = AF_INET;
+       else if (sk->ss_family == AF_CUST_UDP6)
+               sk->ss_family = AF_INET6;
+
        if (sk->ss_family == AF_INET || sk->ss_family == AF_INET6) {
                if (port1 != port2) {
                        memprintf(err, "port ranges and offsets are not allowed in '%s'", args[1]);