From 7daf63461de4195b1626ca15f835fc7cbc56e847 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 29 Jan 2015 13:02:59 -0600 Subject: [PATCH] dhcp: gracefully recover from failed DHCP BOUND state transitions (bgo #743700) First, configure.ac's grep was wrong and wasn't setting DHCPCD_SUPPORTS_IPV6, which caused dhcpcd to acquire a DHCPv6 address when NM didn't think that was going to happen, and thus DHCP options couldn't be parsed. Second, even if that does happen, don't just assert and quit, but set the DHCP state to failed. https://bugzilla.gnome.org/show_bug.cgi?id=743700 (cherry picked from commit 511a7395bff0253f8d1e0d7f35849151d9caa98f) --- configure.ac | 4 ++-- src/dhcp-manager/nm-dhcp-client.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5c87c7e507..57919cc863 100644 --- a/configure.ac +++ b/configure.ac @@ -685,10 +685,10 @@ fi if test "$with_dhcpcd" = "yes"; then AC_PATH_PROGS(with_dhcpcd, dhcpcd, no, /sbin:/usr/sbin:/usr/local/sbin) if test "$with_dhcpcd" != "no"; then - if ! $with_dhcpcd --version 2>&1 | grep -q "^dhcpcd [[456789]]\."; then + if ! $with_dhcpcd --version 2>&1 | grep -q "^dhcpcd [456789]\."; then AC_MSG_WARN([Cannot use dhcpcd, version 4.x or higher is required]) with_dhcpcd=no - elif $with_dhcpcd --version 2>&1 | grep -q "^dhcpcd [[6789]]\."; then + elif $with_dhcpcd --version 2>&1 | grep -q "^dhcpcd [6789]\."; then AC_DEFINE(DHCPCD_SUPPORTS_IPV6, 1, [Define if dhcpcd supports IPv6 (6.x+)]) fi fi diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c index 47fa53171f..951674953a 100644 --- a/src/dhcp-manager/nm-dhcp-client.c +++ b/src/dhcp-manager/nm-dhcp-client.c @@ -767,7 +767,13 @@ nm_dhcp_client_handle_event (gpointer unused, str_options, priv->priority); } - g_warn_if_fail (ip_config != NULL); + + /* Fail if no valid IP config was received */ + if (ip_config == NULL) { + nm_log_warn (LOGD_DHCP, "(%s): DHCP client bound but IP config not received", iface); + new_state = NM_DHCP_STATE_FAIL; + g_clear_pointer (&str_options, g_hash_table_unref); + } } }