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 5f71bfe..c1c6eda 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1026,6 +1026,12 @@
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]);