chiark / gitweb /
resolved: add daemon to manage resolv.conf
[elogind.git] / src / network / networkd-link.c
index 9c93776097b17d991b72cc1a40a76a4167f5bedf..5a7472ba24a09dcdb2337fbf4f8b2d37de0cb493 100644 (file)
@@ -854,8 +854,6 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
         struct in_addr netmask;
         struct in_addr gateway;
         unsigned prefixlen;
-        struct in_addr *nameservers;
-        size_t nameservers_size;
         int r;
 
         assert(client);
@@ -920,15 +918,6 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
 
         link->dhcp_lease = lease;
 
-        if (link->network->dhcp_dns) {
-                r = sd_dhcp_lease_get_dns(lease, &nameservers, &nameservers_size);
-                if (r >= 0) {
-                        r = manager_update_resolv_conf(link->manager);
-                        if (r < 0)
-                                log_error_link(link, "Failed to update resolv.conf");
-                }
-        }
-
         if (link->network->dhcp_mtu) {
                 uint16_t mtu;
 
@@ -1697,7 +1686,7 @@ int link_initialized(Link *link, struct udev_device *device) {
         if (device)
                 link->udev_device = udev_device_ref(device);
 
-        log_info_link(link, "udev initialized link");
+        log_debug_link(link, "udev initialized link");
 
         r = network_get(link->manager, device, link->ifname, &link->mac, &network);
         if (r == -ENOENT) {
@@ -1890,7 +1879,7 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
 
                 if (udev_device_get_is_initialized(device) <= 0) {
                         /* not yet ready */
-                        log_info_link(link, "udev initializing link...");
+                        log_debug_link(link, "udev initializing link...");
                         return 0;
                 }
         }
@@ -1976,6 +1965,27 @@ int link_update(Link *link, sd_rtnl_message *m) {
         return link_update_flags(link, m);
 }
 
+static void serialize_addresses(FILE *f, const char *key, Address *address) {
+        Address *ad;
+
+        assert(f);
+        assert(key);
+
+        if (!address)
+                return;
+
+        fprintf(f, "%s=", key);
+
+        LIST_FOREACH(addresses, ad, address) {
+                char buf[INET6_ADDRSTRLEN];
+
+                if (inet_ntop(address->family, &address->in_addr, buf, INET6_ADDRSTRLEN))
+                        fprintf(f, "%s%s", buf, (ad->addresses_next) ? " ": "");
+        }
+
+        fputs("\n", f);
+}
+
 int link_save(Link *link) {
         _cleanup_free_ char *temp_path = NULL;
         _cleanup_fclose_ FILE *f = NULL;
@@ -2017,12 +2027,18 @@ int link_save(Link *link) {
                 "FLAGS=%u\n",
                 admin_state, oper_state, link->flags);
 
+        if (link->network)
+                serialize_addresses(f, "DNS", link->network->dns);
+
         if (link->dhcp_lease) {
                 r = dhcp_lease_save(link->dhcp_lease, link->lease_file);
                 if (r < 0)
                         goto finish;
 
-                fprintf(f, "DHCP_LEASE=%s\n", link->lease_file);
+                fprintf(f,
+                        "DHCP_LEASE=%s\n"
+                        "DHCP_USE_DNS=%s\n",
+                        link->lease_file, yes_no(link->network->dhcp_dns));
         } else
                 unlink(link->lease_file);