mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 01:20:16 +01:00
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.
This commit is contained in:
parent
a4ddb56923
commit
df75c21b4d
1 changed files with 13 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue