daandemeyer / rpms / systemd

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