summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2019-08-21 08:54:03 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2019-09-18 09:29:51 +0200
commit8b5bf6e4d1f739d6ce9725d30e39a4e54a527b01 (patch)
tree4d85ad4c24728e24c25995418df00f1c3f74966b
parent687d0dd95ed933859f6a6f0a594ef6757be86130 (diff)
downloadNetworkManager-8b5bf6e4d1f739d6ce9725d30e39a4e54a527b01.tar.gz
device: accept lease only after addresses are configured
In the accept() callback, the nettools client creates a UDP socket with the received address as source, so the address must be already configured on the interface. Also, handle errors returned by nm_dhcp_client_accept(). Fixes: 401fee7c2040 ('dhcp: support notifying the client of the result of DAD')
-rw-r--r--src/devices/nm-device.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 5ea94c7959..81e8d934f9 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -7787,8 +7787,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,
@@ -10774,6 +10774,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.
*/