mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-01 18:28:00 +02:00
dhcp: don't start grace period if the client is not running
We shouldn't start a grace period when the client is not running.
This commit is contained in:
parent
0a25b90813
commit
567e277e64
1 changed files with 31 additions and 33 deletions
|
|
@ -7307,7 +7307,7 @@ dhcp4_grace_period_expired (gpointer user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
dhcp4_fail (NMDevice *self)
|
||||
dhcp4_fail (NMDevice *self, NMDhcpState dhcp_state)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
|
|
@ -7323,11 +7323,14 @@ dhcp4_fail (NMDevice *self)
|
|||
&& nm_ip4_config_get_num_addresses (priv->con_ip_config_4) > 0)
|
||||
goto clear_config;
|
||||
|
||||
/* Fail the method in case of timeout or failure during initial
|
||||
* configuration.
|
||||
/* Fail the method when one of the following is true:
|
||||
* 1) the DHCP client terminated: it does not make sense to start a grace
|
||||
* period without a client running;
|
||||
* 2) we failed to get an initial lease AND the client was
|
||||
* not active before.
|
||||
*/
|
||||
if ( !priv->dhcp4.was_active
|
||||
&& priv->ip4_state == IP_CONF) {
|
||||
if ( dhcp_state == NM_DHCP_STATE_TERMINATED
|
||||
|| (!priv->dhcp4.was_active && priv->ip4_state == IP_CONF)) {
|
||||
dhcp4_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
|
||||
nm_device_activate_schedule_ip4_config_timeout (self);
|
||||
return;
|
||||
|
|
@ -7390,7 +7393,7 @@ dhcp4_state_changed (NMDhcpClient *client,
|
|||
case NM_DHCP_STATE_BOUND:
|
||||
if (!ip4_config) {
|
||||
_LOGW (LOGD_DHCP4, "failed to get IPv4 config in response to DHCP event.");
|
||||
dhcp4_fail (self);
|
||||
dhcp4_fail (self, state);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -7433,11 +7436,11 @@ dhcp4_state_changed (NMDhcpClient *client,
|
|||
if (dhcp4_lease_change (self, ip4_config))
|
||||
nm_device_update_metered (self);
|
||||
else
|
||||
dhcp4_fail (self);
|
||||
dhcp4_fail (self, state);
|
||||
}
|
||||
break;
|
||||
case NM_DHCP_STATE_TIMEOUT:
|
||||
dhcp4_fail (self);
|
||||
dhcp4_fail (self, state);
|
||||
break;
|
||||
case NM_DHCP_STATE_EXPIRE:
|
||||
/* Ignore expiry before we even have a lease (NAK, old lease, etc) */
|
||||
|
|
@ -7447,7 +7450,7 @@ dhcp4_state_changed (NMDhcpClient *client,
|
|||
case NM_DHCP_STATE_DONE:
|
||||
case NM_DHCP_STATE_FAIL:
|
||||
case NM_DHCP_STATE_TERMINATED:
|
||||
dhcp4_fail (self);
|
||||
dhcp4_fail (self, state);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -8062,7 +8065,7 @@ dhcp6_grace_period_expired (gpointer user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
dhcp6_fail (NMDevice *self)
|
||||
dhcp6_fail (NMDevice *self, NMDhcpState dhcp_state)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
gboolean is_dhcp_managed;
|
||||
|
|
@ -8082,11 +8085,14 @@ dhcp6_fail (NMDevice *self)
|
|||
&& nm_ip6_config_get_num_addresses (priv->con_ip_config_6))
|
||||
goto clear_config;
|
||||
|
||||
/* Fail the method in case of timeout or failure during initial
|
||||
* configuration.
|
||||
/* Fail the method when one of the following is true:
|
||||
* 1) the DHCP client terminated: it does not make sense to start a grace
|
||||
* period without a client running;
|
||||
* 2) we failed to get an initial lease AND the client was
|
||||
* not active before.
|
||||
*/
|
||||
if ( !priv->dhcp6.was_active
|
||||
&& priv->ip6_state == IP_CONF) {
|
||||
if ( dhcp_state == NM_DHCP_STATE_TERMINATED
|
||||
|| (!priv->dhcp6.was_active && priv->ip6_state == IP_CONF)) {
|
||||
dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
|
||||
nm_device_activate_schedule_ip6_config_timeout (self);
|
||||
return;
|
||||
|
|
@ -8122,21 +8128,6 @@ clear_config:
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dhcp6_timeout (NMDevice *self, NMDhcpClient *client)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED)
|
||||
dhcp6_fail (self);
|
||||
else {
|
||||
/* not a hard failure; just live with the RA info */
|
||||
dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
|
||||
if (priv->ip6_state == IP_CONF)
|
||||
nm_device_activate_schedule_ip6_config_result (self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dhcp6_state_changed (NMDhcpClient *client,
|
||||
NMDhcpState state,
|
||||
|
|
@ -8194,15 +8185,22 @@ dhcp6_state_changed (NMDhcpClient *client,
|
|||
nm_device_activate_schedule_ip6_config_result (self);
|
||||
} else if (priv->ip6_state == IP_DONE)
|
||||
if (!dhcp6_lease_change (self))
|
||||
dhcp6_fail (self);
|
||||
dhcp6_fail (self, state);
|
||||
break;
|
||||
case NM_DHCP_STATE_TIMEOUT:
|
||||
dhcp6_timeout (self, client);
|
||||
if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED)
|
||||
dhcp6_fail (self, state);
|
||||
else {
|
||||
/* not a hard failure; just live with the RA info */
|
||||
dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
|
||||
if (priv->ip6_state == IP_CONF)
|
||||
nm_device_activate_schedule_ip6_config_result (self);
|
||||
}
|
||||
break;
|
||||
case NM_DHCP_STATE_EXPIRE:
|
||||
/* Ignore expiry before we even have a lease (NAK, old lease, etc) */
|
||||
if (priv->ip6_state != IP_CONF)
|
||||
dhcp6_fail (self);
|
||||
dhcp6_fail (self, state);
|
||||
break;
|
||||
case NM_DHCP_STATE_TERMINATED:
|
||||
/* In IPv6 info-only mode, the client doesn't handle leases so it
|
||||
|
|
@ -8214,7 +8212,7 @@ dhcp6_state_changed (NMDhcpClient *client,
|
|||
/* fall through */
|
||||
case NM_DHCP_STATE_DONE:
|
||||
case NM_DHCP_STATE_FAIL:
|
||||
dhcp6_fail (self);
|
||||
dhcp6_fail (self, state);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue