chiark / gitweb /
networkd: netdev - verify that newlink messages has the expected kind
[elogind.git] / src / network / networkd-manager.c
index f41914f8809a5fb20f73b4848dbe152c472fd54f..684b1c7ad31499d454f5cc5a6f539965173a4a1e 100644 (file)
@@ -33,7 +33,7 @@ const char* const network_dirs[] = {
         "/etc/systemd/network",
         "/run/systemd/network",
         "/usr/lib/systemd/network",
-#ifdef HAVE_SPLIT_USER
+#ifdef HAVE_SPLIT_USR
         "/lib/systemd/network",
 #endif
         NULL};
@@ -312,19 +312,19 @@ static int manager_rtnl_process_link(sd_rtnl *rtnl, sd_rtnl_message *message, vo
 
         r = sd_rtnl_message_link_get_ifindex(message, &ifindex);
         if (r < 0 || ifindex <= 0) {
-                log_debug("received RTM_NEWLINK message without valid ifindex");
+                log_warning("received RTM_NEWLINK message without valid ifindex");
                 return 0;
         }
 
         r = sd_rtnl_message_read_string(message, IFLA_IFNAME, &name);
         if (r < 0)
-                log_debug("received RTM_NEWLINK message without valid IFLA_IFNAME");
+                log_warning("received RTM_NEWLINK message without valid ifname");
         else {
                 NetDev *netdev;
 
                 r = netdev_get(m, name, &netdev);
                 if (r >= 0) {
-                        r = netdev_set_ifindex(netdev, ifindex);
+                        r = netdev_set_ifindex(netdev, message);
                         if (r < 0)
                                 log_debug("could not set ifindex of netdev '%s' to %d: %s",
                                           name, ifindex, strerror(-r));
@@ -407,10 +407,6 @@ int manager_update_resolv_conf(Manager *m) {
 
         assert(m);
 
-        r = mkdir_safe_label("/run/systemd/network", 0755, 0, 0);
-        if (r < 0)
-                return r;
-
         r = fopen_temporary("/run/systemd/network/resolv.conf", &f, &temp_path);
         if (r < 0)
                 return r;
@@ -446,10 +442,17 @@ int manager_update_resolv_conf(Manager *m) {
                 }
         }
 
-        HASHMAP_FOREACH(link, m->links, i)
-                if (link->network && link->network->dns)
-                        append_dns(f, &link->network->dns->in_addr.in,
-                                   link->network->dns->family, &count);
+        HASHMAP_FOREACH(link, m->links, i) {
+                if (link->network && link->network->dns) {
+                        Address *address;
+                        Iterator j;
+
+                        SET_FOREACH(address, link->network->dns, j) {
+                                append_dns(f, &address->in_addr.in,
+                                           address->family, &count);
+                        }
+                }
+        }
 
         fflush(f);