mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-19 04:18:30 +02:00
dhcp: derive the grace period duration from the timeout property
Currently the duration of the DHCP grace period (in which we try to acquire a new lease after expiration) is hardcoded to 480 seconds. That value seems arbitrary and too long for the default configuration. Since we already have a property that allows the user to configure how long NM should try to get the lease initially, it makes sense to use it also for retries after lease expirations. In particular, setting the ipvx.dhcp-timeout to a high value extends also the grace period to a very long time, potentially forever.
This commit is contained in:
parent
d0caad7a8d
commit
aee78ca788
1 changed files with 33 additions and 9 deletions
|
|
@ -76,7 +76,7 @@ _LOG_DECLARE_SELF (NMDevice);
|
|||
/*****************************************************************************/
|
||||
|
||||
#define DEFAULT_AUTOCONNECT TRUE
|
||||
#define DHCP_GRACE_PERIOD_SEC 480
|
||||
#define DHCP_GRACE_PERIOD_MULTIPLIER 2U
|
||||
|
||||
#define CARRIER_WAIT_TIME_MS 6000
|
||||
#define CARRIER_WAIT_TIME_AFTER_MTU_MS 10000
|
||||
|
|
@ -7860,12 +7860,24 @@ dhcp4_fail (NMDevice *self, NMDhcpState dhcp_state)
|
|||
* wait for some time before failing the IP method.
|
||||
*/
|
||||
if (!priv->dhcp4.grace_id) {
|
||||
priv->dhcp4.grace_id = g_timeout_add_seconds (DHCP_GRACE_PERIOD_SEC,
|
||||
guint32 timeout;
|
||||
|
||||
/* Start a grace period equal to the DHCP timeout multiplied
|
||||
* by a constant factor. */
|
||||
timeout = get_dhcp_timeout (self, AF_INET);
|
||||
if (timeout < G_MAXUINT32 / DHCP_GRACE_PERIOD_MULTIPLIER) {
|
||||
timeout *= DHCP_GRACE_PERIOD_MULTIPLIER;
|
||||
_LOGI (LOGD_DHCP4,
|
||||
"DHCPv4: trying to acquire a new lease within %u seconds",
|
||||
timeout);
|
||||
} else {
|
||||
timeout = G_MAXUINT32;
|
||||
_LOGI (LOGD_DHCP4, "DHCPv4: trying to acquire a new lease");
|
||||
}
|
||||
|
||||
priv->dhcp4.grace_id = g_timeout_add_seconds (timeout,
|
||||
dhcp4_grace_period_expired,
|
||||
self);
|
||||
_LOGI (LOGD_DHCP4,
|
||||
"DHCPv4: %u seconds grace period started",
|
||||
DHCP_GRACE_PERIOD_SEC);
|
||||
goto clear_config;
|
||||
}
|
||||
return;
|
||||
|
|
@ -8653,12 +8665,24 @@ dhcp6_fail (NMDevice *self, NMDhcpState dhcp_state)
|
|||
* wait for some time before failing the IP method.
|
||||
*/
|
||||
if (!priv->dhcp6.grace_id) {
|
||||
priv->dhcp6.grace_id = g_timeout_add_seconds (DHCP_GRACE_PERIOD_SEC,
|
||||
guint32 timeout;
|
||||
|
||||
/* Start a grace period equal to the DHCP timeout multiplied
|
||||
* by a constant factor. */
|
||||
timeout = get_dhcp_timeout (self, AF_INET6);
|
||||
if (timeout < G_MAXUINT32 / DHCP_GRACE_PERIOD_MULTIPLIER) {
|
||||
timeout *= DHCP_GRACE_PERIOD_MULTIPLIER;
|
||||
_LOGI (LOGD_DHCP6,
|
||||
"DHCPv6: trying to acquire a new lease within %u seconds",
|
||||
timeout);
|
||||
} else {
|
||||
timeout = G_MAXUINT32;
|
||||
_LOGI (LOGD_DHCP6, "DHCPv6: trying to acquire a new lease");
|
||||
}
|
||||
|
||||
priv->dhcp6.grace_id = g_timeout_add_seconds (timeout,
|
||||
dhcp6_grace_period_expired,
|
||||
self);
|
||||
_LOGI (LOGD_DHCP6,
|
||||
"DHCPv6: %u seconds grace period started",
|
||||
DHCP_GRACE_PERIOD_SEC);
|
||||
goto clear_config;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue