diff options
author | Tom Gundersen <teg@jklm.no> | 2014-05-08 17:32:32 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-05-08 17:32:32 +0200 |
commit | 9b3310b066136b0674a926da094b7fe87a13a58b (patch) | |
tree | 0cc911fcb2afa1c9dfe6d53b0b41a8fe9d03f6bf /src/timesync/timesyncd.c | |
parent | bbf7c04821a71fec67eaf0e7a34d17afc5913c13 (diff) |
timesyncd: read global operational state from networkd
Diffstat (limited to 'src/timesync/timesyncd.c')
-rw-r--r-- | src/timesync/timesyncd.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c index eb55bc068c..13cd3b1ed3 100644 --- a/src/timesync/timesyncd.c +++ b/src/timesync/timesyncd.c @@ -1063,26 +1063,14 @@ static int manager_parse_config_file(Manager *m) { } static bool network_is_online(void) { - _cleanup_free_ unsigned *indices = NULL; - int r, n, i; + _cleanup_free_ char *state = NULL; + int r; - n = sd_network_get_ifindices(&indices); - if (n <= 0) + r = sd_network_get_operational_state(&state); + if (r >= 0 && streq("carrier", state)) + return true; + else return false; - - for (i = 0; i < n; i++) { - _cleanup_free_ char *oper_state = NULL; - - if (sd_network_link_is_loopback(indices[i])) - /* ignore loopback devices */ - continue; - - r = sd_network_get_link_operational_state(indices[i], &oper_state); - if (r >= 0 && streq(oper_state, "carrier")) - return true; - } - - return false; } static int manager_network_event_handler(sd_event_source *s, int fd, uint32_t revents, |