[systemd-commits] 2 commits - src/network

Tom Gundersen tomegun at kemper.freedesktop.org
Fri Jan 3 08:09:17 PST 2014


 src/network/networkd-link.c    |   57 +++++++++++++++++++++++------------------
 src/network/networkd-manager.c |   15 ++++++----
 2 files changed, 42 insertions(+), 30 deletions(-)

New commits:
commit 2672953bde548f3648eb6a24dbda415604262cea
Author: Tom Gundersen <teg at jklm.no>
Date:   Fri Jan 3 16:38:18 2014 +0100

    networkd: improve logging
    
    This gives a bit better messages when a link is added twice.

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index f0fb0d9..889efc8 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -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")) {
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index e994497..11c3efe 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -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;

commit efbc88b8ed8a47c3e09f094f8dcb39422f855a01
Author: Tom Gundersen <teg at jklm.no>
Date:   Fri Jan 3 16:20:10 2014 +0100

    networkd: improve link state change logging

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index b004936..f0fb0d9 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -450,33 +450,44 @@ static int link_update_flags(Link *link, unsigned flags) {
         if (link->state == LINK_STATE_FAILED)
                 return 0;
 
-        if (link->flags & IFF_UP && !(flags & IFF_UP))
-                log_info("%s: interface is down", link->ifname);
-        else if (!(link->flags & IFF_UP) && flags & IFF_UP)
-                log_info("%s: interface is up", link->ifname);
-
-        if (link->flags & IFF_LOWER_UP && !(flags & IFF_LOWER_UP)) {
-                log_info("%s: disconnected", link->ifname);
-
-                if (link->network->dhcp) {
-                        r = sd_dhcp_client_stop(link->dhcp);
-                        if (r < 0) {
-                                link_enter_failed(link);
-                                return r;
+        if (link->flags == flags) {
+                log_debug("%s: link status unchanged: %#x", link->ifname, flags);
+                return 0;
+        }
+
+        if ((link->flags & IFF_UP) != (flags & IFF_UP)) {
+                if (flags & IFF_UP)
+                        log_info("%s: power on", link->ifname);
+                else
+                        log_info("%s: power off", link->ifname);
+        }
+
+        if ((link->flags & IFF_LOWER_UP) != (flags & IFF_LOWER_UP)) {
+                if (flags & IFF_LOWER_UP) {
+                        log_info("%s: carrier on", link->ifname);
+
+                        if (link->network->dhcp) {
+                                r = link_acquire_conf(link);
+                                if (r < 0) {
+                                        link_enter_failed(link);
+                                        return r;
+                                }
                         }
-                }
-        } else if (!(link->flags & IFF_LOWER_UP) && flags & IFF_LOWER_UP) {
-                log_info("%s: connected", link->ifname);
-
-                if (link->network->dhcp) {
-                        r = link_acquire_conf(link);
-                        if (r < 0) {
-                                link_enter_failed(link);
-                                return r;
+                } else {
+                        log_info("%s: carrier off", link->ifname);
+
+                        if (link->network->dhcp) {
+                                r = sd_dhcp_client_stop(link->dhcp);
+                                if (r < 0) {
+                                        link_enter_failed(link);
+                                        return r;
+                                }
                         }
                 }
         }
 
+        log_debug("%s: link status updated: %#x -> %#x", link->ifname, link->flags, flags);
+
         link->flags = flags;
 
         return 0;



More information about the systemd-commits mailing list