diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2024-02-16 11:19:40 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2024-02-20 09:29:55 +0100 |
commit | a80fef9f37c890947f9d4f90965341a1d6cc8516 (patch) | |
tree | cdf1cb7d126a333ffe6d36c48b83789d8dc8c9b7 | |
parent | 06e039b18a1f58d4d7efe491a2c7fa8ec3eb74c9 (diff) |
dhcp: remove l3cds when the lease expiresbg/dhcp-expiry-acd
When the lease is lost, NM tries to get a new by restarting the DHCP
transaction. However, it doesn't delete the existing l3cds (one from
the DHCP client with flag ONLY_FOR_ACD, the other from
NMDevice). Therefore, the l3cfg still tracks the ACD state of the
address as "external-removed", and when NM gets the same address via
DHCP, ACD is considered as failed; as a consequence, NM sends a
DECLINE message to the server.
Moreover, the l3cd added by NMDevice for DHCP has a zero ACD timeout,
and so it's not possible to do ACD again on the same address.
Remove those l3cds when the lease expires, so that any ACD state is
cleared and DHCP can perform ACD again.
Fixes: 240ec7f89119 ('dhcp: implement ACD (address collision detection) for DHCPv4')
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1853
-rw-r--r-- | src/core/devices/nm-device.c | 9 | ||||
-rw-r--r-- | src/core/dhcp/nm-dhcp-client.c | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index a9e8c08508..35011a3db9 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -10880,7 +10880,16 @@ _dev_ipdhcpx_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_d case NM_DHCP_CLIENT_NOTIFY_TYPE_LEASE_UPDATE: if (!notify_data->lease_update.l3cd) { + const NML3ConfigData *dhcp_l3cd = priv->l3cds[L3_CONFIG_DATA_TYPE_DHCP_X(IS_IPv4)].d; + _LOGT_ipdhcp(addr_family, "lease lost"); + if (dhcp_l3cd + && nm_l3cfg_remove_config( + priv->l3cfg, + _dev_l3_config_data_tag_get(priv, L3_CONFIG_DATA_TYPE_DHCP_X(IS_IPv4)), + dhcp_l3cd)) { + _dev_l3_cfg_commit(self, FALSE); + } goto lease_update_out; } diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c index 4be03f4bab..8770656b73 100644 --- a/src/core/dhcp/nm-dhcp-client.c +++ b/src/core/dhcp/nm-dhcp-client.c @@ -899,6 +899,12 @@ _nm_dhcp_client_notify(NMDhcpClient *self, l3_cfg_notify_check_connected(self); + if (!priv->l3cd_curr) { + /* When the lease is lost, any cached ACD information is no longer relevant. + * Remove it so that it doesn't interfere with a new lease we might get. */ + _acd_state_reset(self, TRUE, TRUE); + } + _emit_notify(self, NM_DHCP_CLIENT_NOTIFY_TYPE_LEASE_UPDATE, .lease_update = { |