ryantimwilson / rpms / systemd

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