From b94a0254295802a2324ca051e8a74aa520905e43 Mon Sep 17 00:00:00 2001 From: Per von Zweigbergk Date: Sun, 15 Mar 2026 12:17:37 +0000 Subject: [PATCH 1/3] connection: ensure IPv6 literals are surrounded by [] Fixes: #11558 Signed-off-by: Per von Zweigbergk --- include/fluent-bit/flb_connection.h | 11 ++++++----- src/flb_connection.c | 25 ++++++++++++++++--------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/include/fluent-bit/flb_connection.h b/include/fluent-bit/flb_connection.h index 53f28b974e4..57c0aa996e5 100644 --- a/include/fluent-bit/flb_connection.h +++ b/include/fluent-bit/flb_connection.h @@ -36,13 +36,14 @@ /* FLB_CONNECTION_MAX_LABEL_LENGTH is the maximum length of * any of the following variants plus an optional colon if - * the spec includes a port number : + * the spec includes a port number, as well as enclosing + * square brackets for IPv6 addresses : * - * udp:// - * tcp:// - * unix:// + * udp:// (6 for prefix + 1 for colon + 2 for brackets = 9 total) + * tcp:// (6 for prefix + 1 for colon + 2 for brackets = 9 total) + * unix:// (7 for prefix) */ -#define FLB_CONNECTION_MAX_LABEL_LENGTH 7 +#define FLB_CONNECTION_MAX_LABEL_LENGTH 9 #define FLB_CONNECTION_MAX_IPV4_ADDRESS_LENGTH 15 #define FLB_CONNECTION_MAX_IPV6_ADDRESS_LENGTH 39 diff --git a/src/flb_connection.c b/src/flb_connection.c index a3ed402651b..df72ae58a70 100644 --- a/src/flb_connection.c +++ b/src/flb_connection.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -89,17 +90,23 @@ static void compose_user_friendly_remote_host(struct flb_connection *connection) connection_type = connection->stream->transport; - if (connection_type == FLB_TRANSPORT_TCP) { - snprintf(connection->user_friendly_remote_host, - sizeof(connection->user_friendly_remote_host), - "tcp://%s:%u", - connection->remote_host, - connection->remote_port); - } - else if (connection_type == FLB_TRANSPORT_UDP) { + if (connection_type == FLB_TRANSPORT_TCP || + connection_type == FLB_TRANSPORT_UDP) { + const char *fmt; + + /* If the address is an IPv6 literal, we need to + * enclose the address in square brackets. + */ + if (strchr(connection->remote_host, ':') != NULL) { + fmt = "%s://[%s]:%u"; + } + else { + fmt = "%s://%s:%u"; + } snprintf(connection->user_friendly_remote_host, sizeof(connection->user_friendly_remote_host), - "udp://%s:%u", + fmt, + connection_type == FLB_TRANSPORT_TCP ? "tcp" : "udp", connection->remote_host, connection->remote_port); } From a0ca954b1c5f204623b87c271a5e9ac1a09d9d65 Mon Sep 17 00:00:00 2001 From: Per von Zweigbergk Date: Sun, 15 Mar 2026 12:18:27 +0000 Subject: [PATCH 2/3] network: do not use IPv4-mapped IPv6-addresses Fixes: #11560 Signed-off-by: Per von Zweigbergk --- src/flb_network.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/flb_network.c b/src/flb_network.c index 5783d93c50d..3bf19c53aae 100644 --- a/src/flb_network.c +++ b/src/flb_network.c @@ -2145,6 +2145,7 @@ static int net_address_ip_str(flb_sockfd_t fd, size_t *output_data_size) { void *address_data; + int family; int result; errno = 0; @@ -2184,7 +2185,22 @@ static int net_address_ip_str(flb_sockfd_t fd, return -1; } - if ((inet_ntop(address->ss_family, + family = address->ss_family; + + /* + * For IPv4-mapped IPv6 addresses (e.g. ::ffff:127.0.0.1), + * emit a plain IPv4 literal instead. + */ + if (address->ss_family == AF_INET6) { + struct in6_addr *addr6 = (struct in6_addr *) address_data; + + if (IN6_IS_ADDR_V4MAPPED(addr6)) { + family = AF_INET; + address_data = &addr6->s6_addr[12]; + } + } + + if ((inet_ntop(family, address_data, output_buffer, output_buffer_size)) == NULL) { From 6ca6772a6a94e4c7ce503343ec08785d962c29e8 Mon Sep 17 00:00:00 2001 From: Per von Zweigbergk Date: Mon, 16 Mar 2026 06:44:53 +0000 Subject: [PATCH 3/3] in_syslog: changed host/port seperator in log messages to "port" (#11559) Signed-off-by: Per von Zweigbergk --- plugins/in_syslog/syslog_server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/in_syslog/syslog_server.c b/plugins/in_syslog/syslog_server.c index 5ccdecd71d1..952450b0a16 100644 --- a/plugins/in_syslog/syslog_server.c +++ b/plugins/in_syslog/syslog_server.c @@ -164,12 +164,12 @@ static int syslog_server_net_create(struct flb_syslog *ctx) &ctx->ins->net_setup); if (ctx->downstream != NULL) { - flb_info("[in_syslog] %s server binding %s:%s", + flb_info("[in_syslog] %s server binding %s port %s", ((ctx->mode == FLB_SYSLOG_TCP) ? "TCP" : "UDP"), ctx->listen, ctx->port); } else { - flb_error("[in_syslog] could not bind address %s:%s. Aborting", + flb_error("[in_syslog] could not bind address %s port %s. Aborting", ctx->listen, ctx->port); return -1;