chiark / gitweb /
networkd-wait-online: improve interoptability and enable by default
[elogind.git] / src / network / networkd-link.c
index 51cd1d62e829b1ec0e1c00ee5d884ada3483a795..015a82d0d6022e4f83270afdc8eb3c9b9e1cc0d0 100644 (file)
@@ -30,6 +30,7 @@
 #include "bus-util.h"
 #include "network-internal.h"
 
+#include "network-util.h"
 #include "dhcp-lease-internal.h"
 
 static int ipv4ll_address_update(Link *link, bool deprecate);
@@ -144,7 +145,7 @@ static int link_enter_configured(Link *link) {
 static void link_enter_unmanaged(Link *link) {
         assert(link);
 
-        log_info_link(link, "unmanaged");
+        log_debug_link(link, "unmanaged");
 
         link->state = LINK_STATE_UNMANAGED;
 
@@ -1098,20 +1099,6 @@ static int link_acquire_conf(Link *link) {
         return 0;
 }
 
-static bool link_has_carrier(unsigned flags, uint8_t operstate) {
-        /* see Documentation/networking/operstates.txt in the kernel sources */
-
-        if (operstate == IF_OPER_UP)
-                return true;
-
-        if (operstate == IF_OPER_UNKNOWN)
-                /* operstate may not be implemented, so fall back to flags */
-                if ((flags & IFF_LOWER_UP) && !(flags & IFF_DORMANT))
-                        return true;
-
-        return false;
-}
-
 static int link_update_flags(Link *link, sd_rtnl_message *m) {
         unsigned flags, flags_added, flags_removed, generic_flags;
         uint8_t operstate;
@@ -1145,9 +1132,9 @@ static int link_update_flags(Link *link, sd_rtnl_message *m) {
                           IFF_NOARP | IFF_MASTER | IFF_SLAVE);
 
         if (flags_added & IFF_UP)
-                log_info_link(link, "link is up");
+                log_debug_link(link, "link is up");
         else if (flags_removed & IFF_UP)
-                log_info_link(link, "link is down");
+                log_debug_link(link, "link is down");
 
         if (flags_added & IFF_LOWER_UP)
                 log_debug_link(link, "link is lower up");
@@ -1509,9 +1496,11 @@ static int link_configure(Link *link) {
         }
 
         if (link_has_carrier(link->flags, link->operstate))
+        {
                 r = link_acquire_conf(link);
                 if (r < 0)
                         return r;
+        }
 
         return link_enter_enslave(link);
 }
@@ -1566,7 +1555,7 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
 
         link = *ret;
 
-        log_info_link(link, "link added");
+        log_debug_link(link, "link added");
 
         if (detect_container(NULL) <= 0) {
                 /* not in a container, udev will be around */