summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-link.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-07-23 23:03:50 +0200
committerTom Gundersen <teg@jklm.no>2014-07-23 23:54:52 +0200
commit6f4dedb250f2d607eceefaa491f338becbeee7c0 (patch)
tree88ee8549eeb089e853ffce1640f9cb23705a3a5a /src/resolve/resolved-link.c
parent6073b6f26ab9fc6bf335faa7073ec443eef093fd (diff)
sd-network: expose DNS/NTP servers as strings
This avoids having to distinguish between IPv4 and IPv6, allowing us to keep their internal orderings. The consumers now has to turn the strings into addresses.
Diffstat (limited to 'src/resolve/resolved-link.c')
-rw-r--r--src/resolve/resolved-link.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
index 16f41a2604..3c6c757722 100644
--- a/src/resolve/resolved-link.c
+++ b/src/resolve/resolved-link.c
@@ -133,49 +133,33 @@ int link_update_rtnl(Link *l, sd_rtnl_message *m) {
}
static int link_update_dns_servers(Link *l) {
- _cleanup_free_ struct in_addr *nameservers = NULL;
- _cleanup_free_ struct in6_addr *nameservers6 = NULL;
+ _cleanup_strv_free_ char **nameservers = NULL;
+ char **nameserver;
DnsServer *s, *nx;
- int r, n, i;
+ int r;
assert(l);
LIST_FOREACH(servers, s, l->dns_servers)
s->marked = true;
- n = sd_network_get_dns(l->ifindex, &nameservers);
- if (n < 0) {
- r = n;
+ r = sd_network_get_dns(l->ifindex, &nameservers);
+ if (r < 0)
goto clear;
- }
-
- for (i = 0; i < n; i++) {
- union in_addr_union a = { .in = nameservers[i] };
-
- s = link_find_dns_server(l, AF_INET, &a);
- if (s)
- s->marked = false;
- else {
- r = dns_server_new(l->manager, NULL, l, AF_INET, &a);
- if (r < 0)
- goto clear;
- }
- }
- n = sd_network_get_dns6(l->ifindex, &nameservers6);
- if (n < 0) {
- r = n;
- goto clear;
- }
+ STRV_FOREACH(nameserver, nameservers) {
+ union in_addr_union a;
+ int family;
- for (i = 0; i < n; i++) {
- union in_addr_union a = { .in6 = nameservers6[i] };
+ r = in_addr_from_string_auto(*nameserver, &family, &a);
+ if (r < 0)
+ goto clear;
- s = link_find_dns_server(l, AF_INET6, &a);
+ s = link_find_dns_server(l, family, &a);
if (s)
s->marked = false;
else {
- r = dns_server_new(l->manager, NULL, l, AF_INET6, &a);
+ r = dns_server_new(l->manager, NULL, l, family, &a);
if (r < 0)
goto clear;
}