diff options
Diffstat (limited to 'src/dhcp/nm-dhcp-nettools.c')
| -rw-r--r-- | src/dhcp/nm-dhcp-nettools.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c index b4c0a451..45ff46f5 100644 --- a/src/dhcp/nm-dhcp-nettools.c +++ b/src/dhcp/nm-dhcp-nettools.c @@ -977,7 +977,7 @@ lease_save (NMDhcpNettools *self, NDhcp4ClientLease *lease, const char *lease_fi } static void -bound4_handle (NMDhcpNettools *self, NDhcp4ClientLease *lease) +bound4_handle (NMDhcpNettools *self, NDhcp4ClientLease *lease, gboolean extended) { NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE (self); const char *iface = nm_dhcp_client_get_iface (NM_DHCP_CLIENT (self)); @@ -985,7 +985,7 @@ bound4_handle (NMDhcpNettools *self, NDhcp4ClientLease *lease) gs_unref_hashtable GHashTable *options = NULL; GError *error = NULL; - _LOGT ("lease available"); + _LOGT ("lease available (%s)", extended ? "extended" : "new"); ip4_config = lease_to_ip4_config (nm_dhcp_client_get_multi_idx (NM_DHCP_CLIENT (self)), iface, @@ -1006,7 +1006,7 @@ bound4_handle (NMDhcpNettools *self, NDhcp4ClientLease *lease) lease_save (self, lease, priv->lease_file); nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), - NM_DHCP_STATE_BOUND, + extended ? NM_DHCP_STATE_EXTENDED : NM_DHCP_STATE_BOUND, NM_IP_CONFIG_CAST (ip4_config), options); } @@ -1037,10 +1037,10 @@ dhcp4_event_handle (NMDhcpNettools *self, break; case N_DHCP4_CLIENT_EVENT_GRANTED: priv->lease = n_dhcp4_client_lease_ref (event->granted.lease); - bound4_handle (self, event->granted.lease); + bound4_handle (self, event->granted.lease, FALSE); break; case N_DHCP4_CLIENT_EVENT_EXTENDED: - bound4_handle (self, event->extended.lease); + bound4_handle (self, event->extended.lease, TRUE); break; case N_DHCP4_CLIENT_EVENT_DOWN: /* ignore down events, they are purely informational */ @@ -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); |