summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-server.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-01 16:04:12 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-01 16:06:39 +0200
commit4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4 (patch)
treeb36f290a2aeda5bfb77d20b2953898c3d3c36382 /src/resolve/resolved-dns-server.c
parente70df46b9721a3d025e7a0b4ffb5893cbde5e55d (diff)
resolved: beef up DNS server configuration logic
We now maintain two lists of DNS servers: system servers and fallback servers. system servers are used in combination with any per-link servers. fallback servers are only used if there are no system servers or per-link servers configured. The system server list is supposed to be populated from a foreign tool's /etc/resolv.conf (not implemented yet). Also adds a configuration switch for LLMNR, that allows configuring whether LLMNR shall be used simply for resolving or also for responding.
Diffstat (limited to 'src/resolve/resolved-dns-server.c')
-rw-r--r--src/resolve/resolved-dns-server.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
index 2be81ff1d8..2c413370ea 100644
--- a/src/resolve/resolved-dns-server.c
+++ b/src/resolve/resolved-dns-server.c
@@ -24,6 +24,7 @@
int dns_server_new(
Manager *m,
DnsServer **ret,
+ DnsServerType type,
Link *l,
int family,
const union in_addr_union *in_addr) {
@@ -31,26 +32,40 @@ int dns_server_new(
DnsServer *s, *tail;
assert(m);
+ assert((type == DNS_SERVER_LINK) == !!l);
assert(in_addr);
s = new0(DnsServer, 1);
if (!s)
return -ENOMEM;
+ s->type = type;
s->family = family;
s->address = *in_addr;
- if (l) {
+ if (type == DNS_SERVER_LINK) {
LIST_FIND_TAIL(servers, l->dns_servers, tail);
LIST_INSERT_AFTER(servers, l->dns_servers, tail, s);
s->link = l;
- } else {
+ } else if (type == DNS_SERVER_SYSTEM) {
LIST_FIND_TAIL(servers, m->dns_servers, tail);
LIST_INSERT_AFTER(servers, m->dns_servers, tail, s);
- }
+ } else if (type == DNS_SERVER_FALLBACK) {
+ LIST_FIND_TAIL(servers, m->fallback_dns_servers, tail);
+ LIST_INSERT_AFTER(servers, m->fallback_dns_servers, tail, s);
+ } else
+ assert_not_reached("Unknown server type");
s->manager = m;
+ /* A new DNS server that isn't fallback is added and the one
+ * we used so far was a fallback one? Then let's try to pick
+ * the new one */
+ if (type != DNS_SERVER_FALLBACK &&
+ s->manager->current_dns_server &&
+ s->manager->current_dns_server->type == DNS_SERVER_FALLBACK)
+ s->manager->current_dns_server = NULL;
+
if (ret)
*ret = s;
@@ -62,10 +77,14 @@ DnsServer* dns_server_free(DnsServer *s) {
return NULL;
if (s->manager) {
- if (s->link)
+ if (s->type == DNS_SERVER_LINK)
LIST_REMOVE(servers, s->link->dns_servers, s);
- else
+ else if (s->type == DNS_SERVER_SYSTEM)
LIST_REMOVE(servers, s->manager->dns_servers, s);
+ else if (s->type == DNS_SERVER_FALLBACK)
+ LIST_REMOVE(servers, s->manager->fallback_dns_servers, s);
+ else
+ assert_not_reached("Unknown server type");
}
if (s->link && s->link->current_dns_server == s)