summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-01-16 19:32:22 +0100
committerTom Gundersen <teg@jklm.no>2014-01-16 20:32:08 +0100
commit7ae4ef6d23bc884d0e0ee2ec9cf87ec99d0686bb (patch)
treee042cd409684df14801911af4ddfa239b6060cf8 /src/network
parent1346b1f0388f4100bb3c2a2bb23bc881769c020c (diff)
sd-dhcp-client: refactor DNS support
Rather than keeping an array of pointers to addresses, just keep an array of addresses.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-link.c5
-rw-r--r--src/network/networkd-manager.c9
2 files changed, 8 insertions, 6 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 444af8f6db..7f692d1f9b 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -491,7 +491,8 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) {
if (event == DHCP_EVENT_IP_CHANGE || event == DHCP_EVENT_IP_ACQUIRE) {
_cleanup_address_free_ Address *addr = NULL;
_cleanup_route_free_ Route *rt = NULL;
- struct in_addr **nameservers;
+ struct in_addr *nameservers;
+ size_t nameservers_size;
log_struct_link(LOG_INFO, link,
"MESSAGE=%s: DHCPv4 address %u.%u.%u.%u/%u via %u.%u.%u.%u",
@@ -535,7 +536,7 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) {
rt = NULL;
if (link->network->dhcp_dns) {
- r = sd_dhcp_client_get_dns(client, &nameservers);
+ r = sd_dhcp_client_get_dns(client, &nameservers, &nameservers_size);
if (r >= 0) {
r = manager_update_resolv_conf(link->manager);
if (r < 0)
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index ca781e2bb4..3b542149c0 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -338,14 +338,15 @@ int manager_update_resolv_conf(Manager *m) {
HASHMAP_FOREACH(link, m->links, i) {
if (link->dhcp) {
- struct in_addr **nameservers;
+ struct in_addr *nameservers;
+ size_t nameservers_size;
- r = sd_dhcp_client_get_dns(link->dhcp, &nameservers);
+ r = sd_dhcp_client_get_dns(link->dhcp, &nameservers, &nameservers_size);
if (r >= 0) {
unsigned j;
- for (j = 0; nameservers[j]; j++)
- append_dns(f, nameservers[j], AF_INET, &count);
+ for (j = 0; j < nameservers_size; j++)
+ append_dns(f, &nameservers[j], AF_INET, &count);
}
}
}