From: Wolf480pl Date: Tue, 21 Nov 2023 10:53:59 +0000 (+0100) Subject: write_prometheus: don't use AI_ADDRCONFIG for resolving bind address X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=951fababf57087dbf77fa241e133f98ad73a7389;p=thirdparty%2Fcollectd.git write_prometheus: don't use AI_ADDRCONFIG for resolving bind address Fixes #4150 write_prometheus uses getaddrinfo to resolve the bind address. The AI_ADDRCONFIG flag causes getaddrinfo to refuse to resolve 0.0.0.0 when the system has no non-loopback IPv4 addresses configured and refuse to resolve :: when the system has no non-loopback IPv6 configured. We want binding to a wildcard address (0.0.0.0 or ::) to always work, even if the network is down. To achieve that, don't pass the AI_ADDRCONFIG flag when resolving a bind address. --- diff --git a/src/write_prometheus.c b/src/write_prometheus.c index 6e519bc8a..63845b23a 100644 --- a/src/write_prometheus.c +++ b/src/write_prometheus.c @@ -757,7 +757,7 @@ static int prom_open_socket(int addrfamily) { struct addrinfo *res; int status = getaddrinfo(httpd_host, service, &(struct addrinfo){ - .ai_flags = AI_PASSIVE | AI_ADDRCONFIG, + .ai_flags = AI_PASSIVE, .ai_family = addrfamily, .ai_socktype = SOCK_STREAM, },