[systemd-commits] 2 commits - src/network

Tom Gundersen tomegun at kemper.freedesktop.org
Thu Jul 3 13:55:58 PDT 2014


 src/network/networkd-link.c |   67 +++++++++++++++++++++++++-------------------
 1 file changed, 39 insertions(+), 28 deletions(-)

New commits:
commit 4958aee4977f325be19f0e1e4b424922c3cada5f
Author: Tom Gundersen <teg at jklm.no>
Date:   Thu Jul 3 22:47:51 2014 +0200

    networkd: properly track addresses when first added
    
    When doing a NEWADDR, the reply we get back is the NEWADDR itself, rather
    than just an empty ack (unlike how NEWLINK works). For this reason, the
    process that did the NEWADDR does not get the broadcast message.
    
    We were only listening for broadcast messages, and hence not tracking the
    addresses we added ourselves. This went unnoticed as the kernel will usually
    send NEWADDR messages from time to time anyway, so things would mostly work,
    but in the worst case we would not notice that a routable address was available
    and consider ourselves offline.

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 961c1ab..6257372 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -599,10 +599,35 @@ static int route_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata)
         return 0;
 }
 
+static int link_get_address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
+        _cleanup_link_unref_ Link *link = userdata;
+        int r;
+
+        assert(rtnl);
+        assert(m);
+        assert(link);
+        assert(link->manager);
+
+        for (; m; m = sd_rtnl_message_next(m)) {
+                r = sd_rtnl_message_get_errno(m);
+                if (r < 0) {
+                        log_debug_link(link, "getting address failed: %s", strerror(-r));
+                        continue;
+                }
+
+                r = link_rtnl_process_address(rtnl, m, link->manager);
+                if (r < 0)
+                        log_warning_link(link, "could not process address: %s", strerror(-r));
+        }
+
+        return 1;
+}
+
 static int address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
         _cleanup_link_unref_ Link *link = userdata;
         int r;
 
+        assert(rtnl);
         assert(m);
         assert(link);
         assert(link->ifname);
@@ -623,6 +648,11 @@ static int address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
                                 link->ifname, strerror(-r),
                                 "ERRNO=%d", -r,
                                 NULL);
+        if (r >= 0) {
+                /* calling handler directly so take a ref */
+                link_ref(link);
+                link_get_address_handler(rtnl, m, link);
+        }
 
         if (link->addr_messages == 0) {
                 log_debug_link(link, "addresses set");
@@ -2233,30 +2263,6 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
         return 1;
 }
 
-static int link_get_address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
-        _cleanup_link_unref_ Link *link = userdata;
-        int r;
-
-        assert(rtnl);
-        assert(m);
-        assert(link);
-        assert(link->manager);
-
-        for (; m; m = sd_rtnl_message_next(m)) {
-                r = sd_rtnl_message_get_errno(m);
-                if (r < 0) {
-                        log_debug_link(link, "getting address failed: %s", strerror(-r));
-                        continue;
-                }
-
-                r = link_rtnl_process_address(rtnl, m, link->manager);
-                if (r < 0)
-                        log_warning_link(link, "could not process address: %s", strerror(-r));
-        }
-
-        return 1;
-}
-
 int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
         Link *link;
         _cleanup_rtnl_message_unref_ sd_rtnl_message *req = NULL;

commit 393c0c5e64d0cb85ce14f25a06fa8958c9e119e7
Author: Tom Gundersen <teg at jklm.no>
Date:   Thu Jul 3 21:35:03 2014 +0200

    networkd: link - improve link tracking logging

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 14c0417..961c1ab 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -2140,7 +2140,7 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
 
         r = address_new_dynamic(&address);
         if (r < 0)
-                return 0;
+                return r;
 
         r = sd_rtnl_message_addr_get_family(message, &address->family);
         if (r < 0 || !IN_SET(address->family, AF_INET, AF_INET6)) {
@@ -2204,7 +2204,10 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
         case RTM_NEWADDR:
                 if (!address_dropped)
                         log_debug_link(link, "added address: %s/%u", buf,
-                                      address->prefixlen);
+                                       address->prefixlen);
+                else
+                        log_debug_link(link, "updated address: %s/%u", buf,
+                                       address->prefixlen);
 
                 LIST_PREPEND(addresses, link->addresses, address);
                 address = NULL;
@@ -2215,10 +2218,12 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
         case RTM_DELADDR:
                 if (address_dropped) {
                         log_debug_link(link, "removed address: %s/%u", buf,
-                                      address->prefixlen);
+                                       address->prefixlen);
 
                         link_save(link);
-                }
+                } else
+                        log_warning_link(link, "removing non-existent address: %s/%u",
+                                         buf, address->prefixlen);
 
                 break;
         default:



More information about the systemd-commits mailing list