2b68233
From 1b8cc9fb6cac9d5882ab33b79f880d03d1859efb Mon Sep 17 00:00:00 2001
2b68233
From: Lennart Poettering <lennart@poettering.net>
2b68233
Date: Mon, 15 Feb 2016 19:11:18 +0100
2b68233
Subject: [PATCH] networkd: rework idle detection logic of networkd
2b68233
2b68233
This patch makes networkd stay around as long as there is more than just a
2b68233
loopback interface around, or the loopback device isn't fully probed yet, or
2b68233
the loopback device has a .network file attached.
2b68233
2b68233
In essence, this means networkd stays around now continously as it should,
2b68233
unless it is running in some (container?) environment that really has no
2b68233
interface except a loopback device.
2b68233
2b68233
Fixes #2577.
2b68233
2b68233
(cherry picked from commit 9dc907f9c93636cb63ca90300fa3b8c03812701f)
2b68233
---
2b68233
 src/network/networkd-manager.c | 19 ++++++++-----------
2b68233
 1 file changed, 8 insertions(+), 11 deletions(-)
2b68233
2b68233
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
2b68233
index b527191a5a..b8cb7f875d 100644
2b68233
--- a/src/network/networkd-manager.c
2b68233
+++ b/src/network/networkd-manager.c
2b68233
@@ -1091,22 +1091,19 @@ static bool manager_check_idle(void *userdata) {
2b68233
 
2b68233
         assert(m);
2b68233
 
2b68233
+        /* Check whether we are idle now. The only case when we decide to be idle is when there's only a loopback
2b68233
+         * device around, for which we have no configuration, and which already left the PENDING state. In all other
2b68233
+         * cases we are not idle. */
2b68233
+
2b68233
         HASHMAP_FOREACH(link, m->links, i) {
2b68233
-                /* we are not woken on udev activity, so let's just wait for the
2b68233
-                 * pending udev event */
2b68233
+                /* We are not woken on udev activity, so let's just wait for the pending udev event */
2b68233
                 if (link->state == LINK_STATE_PENDING)
2b68233
                         return false;
2b68233
 
2b68233
-                if (!link->network)
2b68233
-                        continue;
2b68233
+                if ((link->flags & IFF_LOOPBACK) == 0)
2b68233
+                        return false;
2b68233
 
2b68233
-                /* we are not woken on netork activity, so let's stay around */
2b68233
-                if (link_lldp_enabled(link) ||
2b68233
-                    link_ipv4ll_enabled(link) ||
2b68233
-                    link_dhcp4_server_enabled(link) ||
2b68233
-                    link_dhcp4_enabled(link) ||
2b68233
-                    link_dhcp6_enabled(link) ||
2b68233
-                    link_ipv6_accept_ra_enabled(link))
2b68233
+                if (link->network)
2b68233
                         return false;
2b68233
         }
2b68233