ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
c62b8e
From fd14e0686820eaff61c2583d98aefc391a8164fe Mon Sep 17 00:00:00 2001
c62b8e
From: Anssi Hannula <anssi.hannula@iki.fi>
c62b8e
Date: Tue, 17 Apr 2018 18:12:00 +0300
c62b8e
Subject: [PATCH] networkd: fix dhcp4 link without routes not being considered
c62b8e
 ready (#8728)
c62b8e
c62b8e
The dhcp4 code sets link->dhcp4_configured when dhcp4_route_handler()
c62b8e
has processed the last message.
c62b8e
c62b8e
However, in case UseRoutes=no has been set in the [DHCP] section, or
c62b8e
in case the DHCP server simply sends no routes, link_set_dhcp_routes()
c62b8e
will not send any netlink messages and dhcp4_route_handler() will
c62b8e
therefore never be called.
c62b8e
c62b8e
This causes the link to never reach LINK_STATE_CONFIGURED, and e.g.
c62b8e
systemd-networkd-wait-online will not consider the link as ready.
c62b8e
c62b8e
Fix that by setting link->dhcp4_configured = true and calling
c62b8e
link_check_ready() in dhcp4_address_handler() in case
c62b8e
link_set_dhcp_routes() sent no netlink messages (dhcp4_messages is
c62b8e
zero).
c62b8e
c62b8e
(cherry picked from commit 223932c786ada7f758a7b7878a6ad2dae0d1e5fb)
c62b8e
c62b8e
Related: #1663365
c62b8e
c62b8e
[jsynacek: Note that link_client_handler() was used instead of
c62b8e
link_check_ready(). The former is an older version of the latter.]
c62b8e
---
c62b8e
 src/network/networkd-dhcp4.c | 5 +++++
c62b8e
 1 file changed, 5 insertions(+)
c62b8e
c62b8e
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
c62b8e
index 354c760ba9..295e44fdd7 100644
c62b8e
--- a/src/network/networkd-dhcp4.c
c62b8e
+++ b/src/network/networkd-dhcp4.c
c62b8e
@@ -305,6 +305,11 @@ static int dhcp4_address_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
c62b8e
 
c62b8e
         link_set_dhcp_routes(link);
c62b8e
 
c62b8e
+        if (link->dhcp4_messages == 0) {
c62b8e
+                link->dhcp4_configured = true;
c62b8e
+                link_client_handler(link);
c62b8e
+        }
c62b8e
+
c62b8e
         return 1;
c62b8e
 }
c62b8e