From ca0062d303b31d85d363a1322f1b4eff905df032 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Fri, 21 Feb 2025 11:03:39 +0100 Subject: [PATCH] BUG/MINOR: log: fix outgoing abns address family While reviewing the code in an attempt to fix GH #2875, I stumbled on another case similar to aac570c ("BUG/MEDIUM: uxst: fix outgoing abns address family in connect()") that caused abns(z) addresses to fail when used as log targets. The underlying cause is the same as aac570c, which is the rework of the unix socket families in order to support custom addresses for different adressing schemes, where a real_family() was overlooked before passing a haproxy-internal address struct to socket-oriented syscall. To fix the issue, we first copy the target's addr, and then leverage real_family() to set the proper low-level address family that is passed to sendmsg() syscall. It should be backported in 3.1 (cherry picked from commit c9d41927266849208508b144ef15809a3a15c6cb) Signed-off-by: Christopher Faulet --- src/log.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/log.c b/src/log.c index 4710e2b..7d0a4e3 100644 --- a/src/log.c +++ b/src/log.c @@ -2783,6 +2783,7 @@ static inline void __do_send_log(struct log_target *target, struct log_header hd sent = fd_write_frag_line(*plogfd, maxlen, msg_header, nbelem, &msg, 1, 1); } else { + struct sockaddr_storage addr; int i = 0; int totlen = maxlen - 1; /* save space for the final '\n' */ @@ -2808,7 +2809,9 @@ static inline void __do_send_log(struct log_target *target, struct log_header hd i++; msghdr.msg_iovlen = i; - msghdr.msg_name = (struct sockaddr *)target->addr; + addr = *target->addr; + addr.ss_family = real_family(target->addr->ss_family); + msghdr.msg_name = (struct sockaddr *)&addr; msghdr.msg_namelen = get_addr_len(target->addr); sent = sendmsg(*plogfd, &msghdr, MSG_DONTWAIT | MSG_NOSIGNAL); -- 1.7.10.4