From: Willy Tarreau Date: Wed, 16 Sep 2020 17:58:34 +0000 (+0200) Subject: BUG/MINOR: log: gracefully handle the "udp@" address format for log servers X-Git-Tag: v2.3-dev5~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e1c4c80441cbffaf0236d9970582293ce0b9089c;p=thirdparty%2Fhaproxy.git BUG/MINOR: log: gracefully handle the "udp@" address format for log servers 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. --- diff --git a/src/log.c b/src/log.c index 5f71bfe35f..c1c6eda3cd 100644 --- 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]);