networkd: link - don't fail if master netdev already exists
authorTom Gundersen <teg@jklm.no>
Tue, 1 Jul 2014 11:30:23 +0000 (13:30 +0200)
committerTom Gundersen <teg@jklm.no>
Tue, 1 Jul 2014 11:30:23 +0000 (13:30 +0200)
This allows restarts to work gracefully.

src/network/networkd-link.c

index ce9fbb5..a523a3e 100644 (file)
@@ -1723,6 +1723,8 @@ static int link_enslaved(Link *link) {
         assert(link->state == LINK_STATE_ENSLAVING);
         assert(link->network);
 
+        log_debug_link(link, "enslaved");
+
         if (!(link->flags & IFF_UP)) {
                 r = link_up(link);
                 if (r < 0) {
@@ -1749,7 +1751,7 @@ static int enslave_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
                 return 1;
 
         r = sd_rtnl_message_get_errno(m);
-        if (r < 0) {
+        if (r < 0 && r != -EEXIST) {
                 log_struct_link(LOG_ERR, link,
                                 "MESSAGE=%-*s: could not enslave: %s",
                                 IFNAMSIZ,
@@ -1760,9 +1762,7 @@ static int enslave_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
                 return 1;
         }
 
-        log_debug_link(link, "enslaved");
-
-        if (link->enslaving == 0)
+        if (link->enslaving <= 0)
                 link_enslaved(link);
 
         return 1;