From 9b3310b066136b0674a926da094b7fe87a13a58b Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Thu, 8 May 2014 17:32:32 +0200 Subject: [PATCH] timesyncd: read global operational state from networkd --- src/timesync/timesyncd.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c index eb55bc068..13cd3b1ed 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, -- 2.30.2