]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timesync: judging if network is online by networkd's address state 12762/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 9 Jun 2019 20:36:32 +0000 (05:36 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 16 Jun 2019 14:17:28 +0000 (23:17 +0900)
Closes #12752.

src/libsystemd/sd-network/network-util.c

index 8daa15fdcb7b671d42baa3acb986d7634a885e49..08ed9426389c7fbbd8df1a9b8261b0fb0ab338de 100644 (file)
@@ -7,14 +7,19 @@
 #include "strv.h"
 
 bool network_is_online(void) {
-        _cleanup_free_ char *state = NULL;
+        _cleanup_free_ char *carrier_state = NULL, *addr_state = NULL;
         int r;
 
-        r = sd_network_get_operational_state(&state);
+        r = sd_network_get_carrier_state(&carrier_state);
         if (r < 0) /* if we don't know anything, we consider the system online */
                 return true;
 
-        if (STR_IN_SET(state, "routable", "degraded"))
+        r = sd_network_get_address_state(&addr_state);
+        if (r < 0) /* if we don't know anything, we consider the system online */
+                return true;
+
+        if (STR_IN_SET(carrier_state, "degraded-carrier", "carrier") &&
+            STR_IN_SET(addr_state, "routable", "degraded"))
                 return true;
 
         return false;