summary refs log tree commit diff
path: root/src/dhcp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dhcp')
-rw-r--r--src/dhcp/nm-dhcp-client.c5
-rw-r--r--src/dhcp/nm-dhcp-client.h4
-rw-r--r--src/dhcp/nm-dhcp-nettools.c14
3 files changed, 17 insertions, 6 deletions
diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c
index faac18e0..81c4ad9c 100644
--- a/src/dhcp/nm-dhcp-client.c
+++ b/src/dhcp/nm-dhcp-client.c
@@ -1010,8 +1010,8 @@ set_property (GObject *object, guint prop_id,
 	case PROP_IFACE:
 		/* construct-only */
 		priv->iface = g_value_dup_string (value);
-		g_return_if_fail (   priv->iface
-		                  && nm_utils_is_valid_iface_name (priv->iface, NULL));
+		g_return_if_fail (priv->iface);
+		nm_assert (nm_utils_ifname_valid_kernel (priv->iface, NULL));
 		break;
 	case PROP_IFINDEX:
 		/* construct-only */
@@ -1203,6 +1203,7 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
 	                       G_PARAM_READWRITE |
 	                       G_PARAM_STATIC_STRINGS);
 
+	G_STATIC_ASSERT_EXPR (G_MAXINT32 == NM_DHCP_TIMEOUT_INFINITY);
 	obj_properties[PROP_TIMEOUT] =
 	    g_param_spec_uint (NM_DHCP_CLIENT_TIMEOUT, "", "",
 	                       1, G_MAXINT32, NM_DHCP_TIMEOUT_DEFAULT,
diff --git a/src/dhcp/nm-dhcp-client.h b/src/dhcp/nm-dhcp-client.h
index 884de850..1ff09067 100644
--- a/src/dhcp/nm-dhcp-client.h
+++ b/src/dhcp/nm-dhcp-client.h
@@ -12,8 +12,8 @@
 #include "nm-ip6-config.h"
 #include "nm-dhcp-utils.h"
 
-#define NM_DHCP_TIMEOUT_DEFAULT ((guint32) 45) /* default DHCP timeout, in seconds */
-#define NM_DHCP_TIMEOUT_INFINITY G_MAXINT32
+#define NM_DHCP_TIMEOUT_DEFAULT  ((guint32) 45) /* default DHCP timeout, in seconds */
+#define NM_DHCP_TIMEOUT_INFINITY ((guint32) G_MAXINT32)
 
 #define NM_TYPE_DHCP_CLIENT            (nm_dhcp_client_get_type ())
 #define NM_DHCP_CLIENT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_CLIENT, NMDhcpClient))
diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c
index 036a46ba..45ff46f5 100644
--- a/src/dhcp/nm-dhcp-nettools.c
+++ b/src/dhcp/nm-dhcp-nettools.c
@@ -1064,8 +1064,18 @@ dhcp4_event_cb (GIOChannel *source,
 	int r;
 
 	r = n_dhcp4_client_dispatch (priv->client);
-	if (r < 0)
-		return G_SOURCE_CONTINUE;
+	if (r < 0) {
+		/* FIXME: if any operation (e.g. send()) fails during the
+		 * dispatch, n-dhcp4 returns an error without arming timers
+		 * or progressing state, so the only reasonable thing to do
+		 * is to move to failed state so that the client will be
+		 * restarted. Ideally n-dhcp4 should retry failed operations
+		 * a predefined number of times (possibly infinite).
+		 */
+		_LOGE ("error %d dispatching events", r);
+		nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
+		return G_SOURCE_REMOVE;
+	}
 
 	while (!n_dhcp4_client_pop_event (priv->client, &event) && event) {
 		dhcp4_event_handle (self, event);