[systemd-commits] 2 commits - src/network

Tom Gundersen tomegun at kemper.freedesktop.org
Tue Aug 19 08:59:34 PDT 2014


 src/network/networkd-link.c   |    3 ---
 src/network/networkd-netdev.c |   40 ++++++++++++++++++++++++++++++----------
 2 files changed, 30 insertions(+), 13 deletions(-)

New commits:
commit 6c3e68e7c1adc6176526e69769bf2eba86cdd257
Author: Tom Gundersen <teg at jklm.no>
Date:   Tue Aug 19 17:51:50 2014 +0200

    networkd: netdev - add missing callback when adding stacked devices
    
    As the comment says, the passed in callback must always be invoked, or the underlying link
    will hang. This was missed when reworking the code, so add it back in.

diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 825b86d..1a436f7 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -445,13 +445,17 @@ int netdev_get_mac(const char *ifname, struct ether_addr **ret) {
         return 0;
 }
 
-static int netdev_create(NetDev *netdev, Link *link) {
+static int netdev_create(NetDev *netdev, Link *link,
+                         sd_rtnl_message_handler_t callback) {
         int r;
 
         assert(netdev);
+        assert(!link || callback);
 
         /* create netdev */
         if (NETDEV_VTABLE(netdev)->create) {
+                assert(!link);
+
                 r = NETDEV_VTABLE(netdev)->create(netdev);
                 if (r < 0)
                         return r;
@@ -546,14 +550,30 @@ static int netdev_create(NetDev *netdev, Link *link) {
                 }
 
 
-                r = sd_rtnl_call_async(netdev->manager->rtnl, m, netdev_create_handler, netdev, 0, NULL);
-                if (r < 0) {
-                        log_error_netdev(netdev,
-                                         "Could not send rtnetlink message: %s", strerror(-r));
-                        return r;
-                }
+                if (link) {
+                        r = sd_rtnl_call_async(netdev->manager->rtnl, m,
+                                               callback, link, 0, NULL);
+                        if (r < 0) {
+                                log_error_netdev(netdev,
+                                                 "Could not send rtnetlink message: %s",
+                                                 strerror(-r));
+                                return r;
+                        }
 
-                netdev_ref(netdev);
+                        link_ref(link);
+                } else {
+                        r = sd_rtnl_call_async(netdev->manager->rtnl, m,
+                                               netdev_create_handler, netdev, 0,
+                                               NULL);
+                        if (r < 0) {
+                                log_error_netdev(netdev,
+                                                 "Could not send rtnetlink message: %s",
+                                                 strerror(-r));
+                                return r;
+                        }
+
+                        netdev_ref(netdev);
+                }
 
                 netdev->state = NETDEV_STATE_CREATING;
 
@@ -580,7 +600,7 @@ int netdev_join(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback)
 
                 break;
         case NETDEV_CREATE_STACKED:
-                r = netdev_create(netdev, link);
+                r = netdev_create(netdev, link, callback);
                 if (r < 0)
                         return r;
 
@@ -699,7 +719,7 @@ static int netdev_load_one(Manager *manager, const char *filename) {
         switch (NETDEV_VTABLE(netdev)->create_type) {
         case NETDEV_CREATE_MASTER:
         case NETDEV_CREATE_INDEPENDENT:
-                r = netdev_create(netdev, NULL);
+                r = netdev_create(netdev, NULL, NULL);
                 if (r < 0)
                         return r;
 

commit 2a5948f715b1b4a5510b723755a263602349a8af
Author: Tom Gundersen <teg at jklm.no>
Date:   Tue Aug 19 17:50:38 2014 +0200

    networkd: link - don't enforce ENSLAVING state
    
    We are only guaranteed to stay in ENSLAVING state whilst enslaving by bridges/bonds, not
    when adding stacked devices (as then the underlying device can be IFF_UP'ed and configured
    in parallel), so drop these asserts.

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 2480221..b5f5863 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1052,7 +1052,6 @@ static int link_joined(Link *link) {
         int r;
 
         assert(link);
-        assert(link->state == LINK_STATE_ENSLAVING);
         assert(link->network);
 
         if (!(link->flags & IFF_UP)) {
@@ -1072,8 +1071,6 @@ static int netdev_join_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
         int r;
 
         assert(link);
-        assert(IN_SET(link->state, LINK_STATE_ENSLAVING, LINK_STATE_FAILED,
-                      LINK_STATE_LINGER));
         assert(link->network);
 
         link->enslaving --;



More information about the systemd-commits mailing list