From: Yu Watanabe Date: Wed, 14 Dec 2022 14:54:11 +0000 (+0900) Subject: timesync: ignore IPv6 addresses when the kernel does not support IPv6 X-Git-Tag: v253-rc1~279^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F25743%2Fhead;p=thirdparty%2Fsystemd.git timesync: ignore IPv6 addresses when the kernel does not support IPv6 Fixes #25728. --- diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 15a18217f72..c05a832316b 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -806,11 +806,6 @@ int manager_connect(Manager *m) { if (m->current_server_address && m->current_server_address->addresses_next) manager_set_server_address(m, m->current_server_address->addresses_next); else { - static const struct addrinfo hints = { - .ai_flags = AI_NUMERICSERV|AI_ADDRCONFIG, - .ai_socktype = SOCK_DGRAM, - }; - /* Hmm, we are through all addresses, let's look for the next host instead */ if (m->current_server_name && m->current_server_name->names_next) manager_set_server_name(m, m->current_server_name->names_next); @@ -878,6 +873,12 @@ int manager_connect(Manager *m) { log_debug("Resolving %s...", m->current_server_name->string); + struct addrinfo hints = { + .ai_flags = AI_NUMERICSERV|AI_ADDRCONFIG, + .ai_socktype = SOCK_DGRAM, + .ai_family = socket_ipv6_is_supported() ? AF_UNSPEC : AF_INET, + }; + r = resolve_getaddrinfo(m->resolve, &m->resolve_query, m->current_server_name->string, "123", &hints, manager_resolve_handler, NULL, m); if (r < 0) return log_error_errno(r, "Failed to create resolver: %m");