summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-12-14 23:54:11 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-12-15 03:30:13 +0900
commit713e6e631d4071c7d9287d5d343bebb69a58b29c (patch)
treeab708766cc196b105f2b81fba25357df3c5eb8b4 /src
parent7a12328735af2bca53dbbb1c85a14ba5cf1e084c (diff)
downloadsystemd-713e6e631d4071c7d9287d5d343bebb69a58b29c.tar.gz
timesync: ignore IPv6 addresses when the kernel does not support IPv6
Fixes #25728.
Diffstat (limited to 'src')
-rw-r--r--src/timesync/timesyncd-manager.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index 15a18217f7..c05a832316 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");