[systemd-commits] 3 commits - src/libsystemd src/network

Tom Gundersen tomegun at kemper.freedesktop.org
Sat Apr 19 12:42:19 PDT 2014


 src/libsystemd/sd-rtnl/rtnl-message.c |    8 +++---
 src/network/networkd-link.c           |   12 ++++++++++
 src/network/networkd-manager.c        |   40 ++++++++--------------------------
 3 files changed, 26 insertions(+), 34 deletions(-)

New commits:
commit 667fcc6d7dab1b98dfbbb65f8f14127d8690e70f
Author: Tom Gundersen <teg at jklm.no>
Date:   Sat Apr 19 20:49:06 2014 +0200

    networkd: manager - add a bit of debug output to udev ADD events

diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 4c1987d..28de791 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -182,7 +182,7 @@ bool manager_should_reload(Manager *m) {
 
 static int manager_udev_process_link(Manager *m, struct udev_device *device) {
         Link *link = NULL;
-        int r;
+        int r, ifindex;
 
         assert(m);
         assert(device);
@@ -190,12 +190,17 @@ static int manager_udev_process_link(Manager *m, struct udev_device *device) {
         if (!streq_ptr(udev_device_get_action(device), "add"))
                 return 0;
 
-        r = link_get(m, udev_device_get_ifindex(device), &link);
-        if (r < 0)
-                return r;
+        ifindex = udev_device_get_ifindex(device);
+        if (ifindex <= 0) {
+                log_debug("ignoring udev ADD event for device with invalid ifindex");
+                return 0;
+        }
 
-        if (!link)
+        r = link_get(m, ifindex, &link);
+        if (r == -ENODEV)
                 return 0;
+        else if (r < 0)
+                return r;
 
         r = link_initialized(link, device);
         if (r < 0)
@@ -203,32 +208,7 @@ static int manager_udev_process_link(Manager *m, struct udev_device *device) {
 
         return 0;
 }
-/*
-        if (streq_ptr(udev_device_get_action(device), "remove")) {
-                log_debug("%s: link removed", udev_device_get_sysname(device));
-
-                if (link)
-                        link_free(link);
-        } else {
-                if (link) {
-                        log_debug("%s: link already exists, ignoring",
-                                  link->ifname);
-                        return 0;
-                }
 
-                r = link_add(m, device, &link);
-                if (r < 0) {
-                        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;
-}
-*/
 static int manager_rtnl_process_link(sd_rtnl *rtnl, sd_rtnl_message *message, void *userdata) {
         Manager *m = userdata;
         Link *link = NULL;

commit b8941f74c87b56c341d0f4f14aae8aab268eadc0
Author: Tom Gundersen <teg at jklm.no>
Date:   Sat Apr 19 20:39:17 2014 +0200

    networkd: link - track interface renames

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 319f290..aad72de 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1487,14 +1487,26 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
 int link_update(Link *link, sd_rtnl_message *m) {
         unsigned flags;
         struct ether_addr mac;
+        char *ifname;
         int r;
 
         assert(link);
+        assert(link->ifname);
         assert(m);
 
         if (link->state == LINK_STATE_FAILED)
                 return 0;
 
+        r = sd_rtnl_message_read_string(m, IFLA_IFNAME, &ifname);
+        if (r >= 0 && !streq(ifname, link->ifname)) {
+                log_info_link(link, "renamed to %s", ifname);
+
+                free(link->ifname);
+                link->ifname = strdup(ifname);
+                if (!link->ifname)
+                        return -ENOMEM;
+        }
+
         if (!link->original_mtu) {
                 r = sd_rtnl_message_read_u16(m, IFLA_MTU, &link->original_mtu);
                 if (r >= 0)

commit d4ef4f46cfa393f65c7312a18bc798db43018cd0
Author: Tom Gundersen <teg at jklm.no>
Date:   Sat Apr 19 20:32:01 2014 +0200

    sd-rtnl: socet_read_message - make sure we only shrink the partial rqueue when processing multi-part message

diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 3362958..a5b09ed 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -1226,16 +1226,16 @@ int socket_read_message(sd_rtnl *rtnl) {
                 if (r < 0)
                         return r;
 
-                if (i < rtnl->rqueue_partial_size) {
+                rtnl->rqueue[rtnl->rqueue_size ++] = first;
+                first = NULL;
+
+                if (multi_part && (i < rtnl->rqueue_partial_size)) {
                         /* remove the message form the partial read queue */
                         memmove(rtnl->rqueue_partial + i,rtnl->rqueue_partial + i + 1,
                                 sizeof(sd_rtnl_message*) * (rtnl->rqueue_partial_size - i - 1));
                         rtnl->rqueue_partial_size --;
                 }
 
-                rtnl->rqueue[rtnl->rqueue_size ++] = first;
-                first = NULL;
-
                 return 1;
         } else {
                 /* we only got a partial multi-part message, push it on the



More information about the systemd-commits mailing list