richardphibel / rpms / systemd

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