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.
This commit is contained in:
Willy Tarreau 2020-09-16 19:58:34 +02:00
parent 70bf06e5f0
commit e1c4c80441

View File

@ -1026,6 +1026,12 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err)
goto error; goto error;
logsrv->addr = *sk; 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 (sk->ss_family == AF_INET || sk->ss_family == AF_INET6) {
if (port1 != port2) { if (port1 != port2) {
memprintf(err, "port ranges and offsets are not allowed in '%s'", args[1]); memprintf(err, "port ranges and offsets are not allowed in '%s'", args[1]);