mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-10 18:20:37 +01:00
Merge branch 'bg/dhcp-keep'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/243 https://bugzilla.redhat.com/show_bug.cgi?id=1688329
This commit is contained in:
commit
a7dd935d87
2 changed files with 31 additions and 11 deletions
|
|
@ -1009,7 +1009,7 @@ int n_dhcp4_client_probe_transition_accept(NDhcp4ClientProbe *probe, NDhcp4Incom
|
|||
|
||||
probe->state = N_DHCP4_CLIENT_PROBE_STATE_BOUND;
|
||||
|
||||
/* XXX: trigger timers */
|
||||
n_dhcp4_client_arm_timer (probe->client);
|
||||
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -7736,7 +7736,13 @@ dhcp4_fail (NMDevice *self, NMDhcpState dhcp_state)
|
|||
_ip_state_to_string (priv->ip_state_4),
|
||||
priv->dhcp4.was_active);
|
||||
|
||||
/* Keep client running if there are static addresses configured
|
||||
/* The client is always left running after a failure. */
|
||||
|
||||
/* Nothing to do if we failed before... */
|
||||
if (priv->ip_state_4 == NM_DEVICE_IP_STATE_FAIL)
|
||||
goto clear_config;
|
||||
|
||||
/* ... and also if there are static addresses configured
|
||||
* on the interface.
|
||||
*/
|
||||
if ( priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE
|
||||
|
|
@ -7752,14 +7758,12 @@ dhcp4_fail (NMDevice *self, NMDhcpState dhcp_state)
|
|||
*/
|
||||
if ( dhcp_state == NM_DHCP_STATE_TERMINATED
|
||||
|| (!priv->dhcp4.was_active && priv->ip_state_4 == NM_DEVICE_IP_STATE_CONF)) {
|
||||
dhcp4_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
|
||||
nm_device_activate_schedule_ip_config_timeout (self, AF_INET);
|
||||
return;
|
||||
}
|
||||
|
||||
/* In any other case (expired lease, assumed connection, etc.),
|
||||
* start a grace period in which we keep the client running,
|
||||
* hoping that it will regain a lease.
|
||||
* 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,
|
||||
|
|
@ -7787,8 +7791,8 @@ dhcp4_dad_cb (NMDevice *self, NMIP4Config **configs, gboolean success)
|
|||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
if (success) {
|
||||
nm_dhcp_client_accept (priv->dhcp4.client, NULL);
|
||||
nm_device_activate_schedule_ip_config_result (self, AF_INET, NM_IP_CONFIG_CAST (configs[1]));
|
||||
nm_device_activate_schedule_ip_config_result (self, AF_INET,
|
||||
NM_IP_CONFIG_CAST (configs[1]));
|
||||
} else {
|
||||
nm_dhcp_client_decline (priv->dhcp4.client, "Address conflict detected", NULL);
|
||||
nm_device_ip_method_failed (self, AF_INET,
|
||||
|
|
@ -8381,10 +8385,16 @@ dhcp6_fail (NMDevice *self, NMDhcpState dhcp_state)
|
|||
_ip_state_to_string (priv->ip_state_6),
|
||||
priv->dhcp6.was_active);
|
||||
|
||||
/* The client is always left running after a failure. */
|
||||
|
||||
/* Nothing to do if we failed before... */
|
||||
if (priv->ip_state_6 == NM_DEVICE_IP_STATE_FAIL)
|
||||
goto clear_config;
|
||||
|
||||
is_dhcp_managed = (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED);
|
||||
|
||||
if (is_dhcp_managed) {
|
||||
/* Keep client running if there are static addresses configured
|
||||
/* ... and also if there are static addresses configured
|
||||
* on the interface.
|
||||
*/
|
||||
if ( priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE
|
||||
|
|
@ -8400,14 +8410,12 @@ dhcp6_fail (NMDevice *self, NMDhcpState dhcp_state)
|
|||
*/
|
||||
if ( dhcp_state == NM_DHCP_STATE_TERMINATED
|
||||
|| (!priv->dhcp6.was_active && priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF)) {
|
||||
dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
|
||||
nm_device_activate_schedule_ip_config_timeout (self, AF_INET6);
|
||||
return;
|
||||
}
|
||||
|
||||
/* In any other case (expired lease, assumed connection, etc.),
|
||||
* start a grace period in which we keep the client running,
|
||||
* hoping that it will regain a lease.
|
||||
* 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,
|
||||
|
|
@ -10774,6 +10782,18 @@ activate_stage5_ip_config_result_4 (NMDevice *self)
|
|||
}
|
||||
}
|
||||
|
||||
if (priv->dhcp4.client) {
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
if (!nm_dhcp_client_accept (priv->dhcp4.client, &error)) {
|
||||
_LOGW (LOGD_DHCP4,
|
||||
"Activation: Stage 5 of 5 (IPv4 Commit) error accepting lease: %s",
|
||||
error->message);
|
||||
nm_device_ip_method_failed (self, AF_INET, NM_DEVICE_STATE_REASON_DHCP_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* If IPv4 wasn't the first to complete, and DHCP was used, then ensure
|
||||
* dispatcher scripts get the DHCP lease information.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue