1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-06 13:17:44 +03:00

resolved: filter stub listeners in manager_get_dns_server()

Commit 49ef064c8d attempts to handle
"stub loop" by switching to the next server *after the query has
been made*.

The approach may be good enough for link scopes. However, for the
manager / global scope, it is not. First of all, there are more than
one types (SYSTEM and FALLBACK) of servers it can use. Also, whether
those of type FALLBACK should be used depends.

Besides, dns_scope_good_domain() determines whether things should
be routed to a scope by checking whether the scope has a server.
The decision made would be incorrect if stubs were not filtered
beforehand.

Therefore, to avoid failing query unnecessarily, and to make sure
that extra stub listeners will not trigger unexpected and/or
inconsistent behavior, make manager_get_dns_server() do what it
should have done.
This commit is contained in:
Tom Yan 2021-12-08 10:53:07 +08:00
parent fdae4504c7
commit af45251e4c

View File

@ -875,9 +875,18 @@ DnsServer *manager_get_dns_server(Manager *m) {
manager_read_resolv_conf(m);
/* If no DNS server was chosen so far, pick the first one */
if (!m->current_dns_server)
if (!m->current_dns_server ||
/* In case m->current_dns_server != m->dns_servers */
manager_server_is_stub(m, m->current_dns_server))
manager_set_dns_server(m, m->dns_servers);
while (m->current_dns_server &&
manager_server_is_stub(m, m->current_dns_server)) {
manager_next_dns_server(m, NULL);
if (m->current_dns_server == m->dns_servers)
manager_set_dns_server(m, NULL);
}
if (!m->current_dns_server) {
bool found = false;