diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2020-01-28 16:48:47 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2020-01-30 15:43:16 +0100 |
commit | 6c1daa4fa942efcd9ad00ff5c89f0f3d185731bb (patch) | |
tree | e573e9b517381c0dfeeeba1cf87896413dbe3be7 | |
parent | 5182ca8782407a0d50704fc93d7487a1b10d98eb (diff) | |
download | NetworkManager-6c1daa4fa942efcd9ad00ff5c89f0f3d185731bb.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.
(cherry picked from commit df75c21b4d5ef8e7c52a028c93f0ce692c9d534f)
-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 c6f7ea0149..051040497f 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7758,9 +7758,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); @@ -7771,6 +7772,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, @@ -7943,7 +7953,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); |