richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
Pablo Greco 48fc63
From 583aea0f48640611f0c1d5da9dec8d3759521ce9 Mon Sep 17 00:00:00 2001
Pablo Greco 48fc63
From: Andrew Jeddeloh <andrewjeddeloh@gmail.com>
Pablo Greco 48fc63
Date: Thu, 31 Aug 2017 01:58:39 -0700
Pablo Greco 48fc63
Subject: [PATCH] networkd: dont crash when mtu changes (#6594)
Pablo Greco 48fc63
Pablo Greco 48fc63
Prevent networkd from crashing when UseMTU is used. Many drivers will
Pablo Greco 48fc63
bring the link down and then back up to configure a new MTU. Networkd
Pablo Greco 48fc63
will also asynchonously send rtnl messages to configure the link and may
Pablo Greco 48fc63
receive responses after the link has gone down and come back up (which
Pablo Greco 48fc63
networkd will handle and set the lease and network to NULL.
Pablo Greco 48fc63
Pablo Greco 48fc63
This changes the behavior to instead return if this is the case instead
Pablo Greco 48fc63
of crashing via assert.
Pablo Greco 48fc63
Pablo Greco 48fc63
(cherry picked from commit 0c9b15a38a558d8f84257455ee24174221069e9e)
Pablo Greco 48fc63
Pablo Greco 48fc63
Related: #1663365
Pablo Greco 48fc63
---
Pablo Greco 48fc63
 src/network/networkd-dhcp4.c | 8 ++++++--
Pablo Greco 48fc63
 1 file changed, 6 insertions(+), 2 deletions(-)
Pablo Greco 48fc63
Pablo Greco 48fc63
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
Pablo Greco 48fc63
index 295e44fdd7..a47286af6b 100644
Pablo Greco 48fc63
--- a/src/network/networkd-dhcp4.c
Pablo Greco 48fc63
+++ b/src/network/networkd-dhcp4.c
Pablo Greco 48fc63
@@ -57,8 +57,12 @@ static int link_set_dhcp_routes(Link *link) {
Pablo Greco 48fc63
         int r, n, i;
Pablo Greco 48fc63
 
Pablo Greco 48fc63
         assert(link);
Pablo Greco 48fc63
-        assert(link->dhcp_lease);
Pablo Greco 48fc63
-        assert(link->network);
Pablo Greco 48fc63
+
Pablo Greco 48fc63
+        if (!link->dhcp_lease) /* link went down while we configured the IP addresses? */
Pablo Greco 48fc63
+                return 0;
Pablo Greco 48fc63
+
Pablo Greco 48fc63
+        if (!link->network) /* link went down while we configured the IP addresses? */
Pablo Greco 48fc63
+                return 0;
Pablo Greco 48fc63
 
Pablo Greco 48fc63
         if (!link->network->dhcp_routes)
Pablo Greco 48fc63
                 return 0;