summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-conf.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-24 17:59:40 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-25 21:58:37 +0100
commit0eac462399c8e87bcce252cf058eba9f2678f2bd (patch)
tree31f3297ad47d256ebcc5dba55697e21431341174 /src/resolve/resolved-conf.c
parentf2f1dbe50fea13abadc9c1e845a29031b90b40f3 (diff)
resolved: rework dns server lifecycle logic
Previously, there was a chance of memory corruption, because when switching to the next DNS server we didn't care whether they linked list of DNS servers was still valid. Clean up lifecycle of the dns server logic: - When a DnsServer object is still in the linked list of DnsServers for a link or the manager, indicate so with a "linked" boolean field, and never follow the linked list if that boolean is not set. - When picking a DnsServer to use for a link ot manager, always explicitly take a reference. This also rearranges some logic, to make the tracking of dns servers by link and globally more alike.
Diffstat (limited to 'src/resolve/resolved-conf.c')
-rw-r--r--src/resolve/resolved-conf.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c
index 8b49d46a59..fe88006fb7 100644
--- a/src/resolve/resolved-conf.c
+++ b/src/resolve/resolved-conf.c
@@ -29,8 +29,8 @@
int manager_add_dns_server_by_string(Manager *m, DnsServerType type, const char *word) {
union in_addr_union address;
- DnsServer *first, *s;
int family, r;
+ DnsServer *s;
assert(m);
assert(word);
@@ -39,13 +39,8 @@ int manager_add_dns_server_by_string(Manager *m, DnsServerType type, const char
if (r < 0)
return r;
- first = type == DNS_SERVER_FALLBACK ? m->fallback_dns_servers : m->dns_servers;
-
/* Filter out duplicates */
- LIST_FOREACH(servers, s, first)
- if (s->family == family && in_addr_equal(family, &s->address, &address))
- break;
-
+ s = manager_find_dns_server(m, type, family, &address);
if (s) {
/*
* Drop the marker. This is used to find the servers