chiark / gitweb /
networkd: improve logging
authorTom Gundersen <teg@jklm.no>
Fri, 3 Jan 2014 15:38:18 +0000 (16:38 +0100)
committerTom Gundersen <teg@jklm.no>
Fri, 3 Jan 2014 15:56:09 +0000 (16:56 +0100)
This gives a bit better messages when a link is added twice.

src/network/networkd-link.c
src/network/networkd-manager.c

index f0fb0d9..889efc8 100644 (file)
@@ -102,13 +102,11 @@ int link_add(Manager *m, struct udev_device *device) {
         ifindex = udev_device_get_ifindex(device);
         link = hashmap_get(m->links, &ifindex);
         if (link)
-                return 0;
+                return -EEXIST;
 
         r = link_new(m, device, &link);
-        if (r < 0) {
-                log_error("Could not create link: %s", strerror(-r));
+        if (r < 0)
                 return r;
-        }
 
         devtype = udev_device_get_devtype(device);
         if (streq_ptr(devtype, "bridge")) {
index e994497..11c3efe 100644 (file)
@@ -143,14 +143,17 @@ 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);
                 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",
+                                          udev_device_get_sysname(device));
+                        else
+                                log_error("%s: could not handle link: %s",
+                                          udev_device_get_sysname(device),
+                                          strerror(-r));
+                } else
+                        log_debug("%s: link added", udev_device_get_sysname(device));
         }
 
         return 0;