diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2020-01-28 16:48:47 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2020-01-30 09:08:58 +0100 |
commit | 003753e9ae4d6990d6a29c574dd2f6e33ee57dac (patch) | |
tree | 177fd25413ada2a80f2d76dda4190f7d020c6ca9 | |
parent | 020b074bb0d0c4482a80306e8106026930800f90 (diff) | |
download | NetworkManager-003753e9ae4d6990d6a29c574dd2f6e33ee57dac.tar.gz |
device: accept new leases in NM_DEVICE_IP_STATE_DONE
If the current lease expires, we start the grace period in which the
clients starts again from the INIT DHCP state (i.e. sending DISCOVER
messages). If it is able to obtain a new lease, it must be accepted or
otherwise the client will not renew it.
-rw-r--r-- | src/devices/nm-device.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index c89c26e3b1..0f410807a6 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7784,9 +7784,10 @@ ip_config_merge_and_apply (NMDevice *self, } static gboolean -dhcp4_lease_change (NMDevice *self, NMIP4Config *config) +dhcp4_lease_change (NMDevice *self, NMIP4Config *config, gboolean bound) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + gs_free_error GError *error = NULL; g_return_val_if_fail (config, FALSE); @@ -7797,6 +7798,15 @@ dhcp4_lease_change (NMDevice *self, NMIP4Config *config) return FALSE; } + /* TODO: we should perform DAD again whenever we obtain a + * new lease after an expiry. But what should we do if + * a duplicate address is detected? Fail the connection; + * restart DHCP; continue without an address? */ + if (bound && !nm_dhcp_client_accept (priv->dhcp4.client, &error)) { + _LOGW (LOGD_DHCP4, "error accepting lease: %s", error->message); + return FALSE; + } + nm_dispatcher_call_device (NM_DISPATCHER_ACTION_DHCP4_CHANGE, self, NULL, @@ -7969,7 +7979,8 @@ dhcp4_state_changed (NMDhcpClient *client, ipv4_dad_start (self, configs, dhcp4_dad_cb); } else if (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE) { - if (dhcp4_lease_change (self, ip4_config)) + if (dhcp4_lease_change (self, ip4_config, + state == NM_DHCP_STATE_BOUND)) nm_device_update_metered (self); else dhcp4_fail (self, state); |