chiark / gitweb /
networkd: refuse to use .network files with missing Address/Gateway key
[elogind.git] / src / network / networkd-manager.c
index e9944973ad16666faf38f8913a89847b28d84481..4e2cf45791d024993904273b9802e2a07719b34d 100644 (file)
@@ -143,14 +143,18 @@ static int manager_process_link(Manager *m, struct udev_device *device) {
 
                 link_free(link);
         } else {
-                log_debug("%s: link added", udev_device_get_sysname(device));
-
-                r = link_add(m, device);
+                r = link_add(m, device, &link);
                 if (r < 0) {
-                        log_error("Could not handle link %s: %s",
-                                        udev_device_get_sysname(device),
-                                        strerror(-r));
-                }
+                        if (r == -EEXIST)
+                                log_debug("%s: link already exists, ignoring",
+                                          link->ifname);
+                        else
+                                log_error("%s: could not handle link: %s",
+                                          udev_device_get_sysname(device),
+                                          strerror(-r));
+                } else
+                        log_debug("%s: link (with ifindex %" PRIu64") added",
+                                  link->ifname, link->ifindex);
         }
 
         return 0;
@@ -237,6 +241,7 @@ int manager_udev_listen(Manager *m) {
 static int manager_rtnl_process_link(sd_rtnl *rtnl, sd_rtnl_message *message, void *userdata) {
         Manager *m = userdata;
         Link *link;
+        uint64_t ifindex_64;
         int r, ifindex;
 
         r = sd_rtnl_message_link_get_ifindex(message, &ifindex);
@@ -245,9 +250,10 @@ static int manager_rtnl_process_link(sd_rtnl *rtnl, sd_rtnl_message *message, vo
                 return 0;
         }
 
-        link = hashmap_get(m->links, &ifindex);
+        ifindex_64 = ifindex;
+        link = hashmap_get(m->links, &ifindex_64);
         if (!link) {
-                log_debug("received RTM_NEWLINK message for ifindex we are not tracking (%d)", ifindex);
+                log_debug("received RTM_NEWLINK message for untracked ifindex %d", ifindex);
                 return 0;
         }
 
@@ -257,7 +263,7 @@ static int manager_rtnl_process_link(sd_rtnl *rtnl, sd_rtnl_message *message, vo
                 if (r < 0)
                         return 0;
         } else
-                log_debug("received RTM_NEWLINK message for link we are not managing (%d)", ifindex);
+                log_debug("%s: received RTM_NEWLINK message for unmanaged link", link->ifname);
 
         return 1;
 }