device: update metered status when getting DHCP lease

The metered status can depend on the DHCP lease, as we accept the
ANDROID_METERED vendor option. That means, on a DHCP update we need
to re-evaluate the metered flag.

This fixes a potential race, where IPv6 might succeed first and
activation completes (with GUESS_NO metered flag). A subsequent
DHCPv4 update requires to re-evaluate that decision.

Fixes-test: @connection_metered_guess_yes

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1080
This commit is contained in:
Thomas Haller 2022-02-02 08:51:33 +01:00
parent ecc73eb239
commit 3399e19df8
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -9970,7 +9970,7 @@ _dev_ipdhcpx_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_d
if (!notify_data->lease_update.l3cd) {
_LOGT_ipdhcp(addr_family, "lease lost");
return;
goto lease_update_out;
}
if (notify_data->lease_update.accepted)
@ -10004,6 +10004,8 @@ _dev_ipdhcpx_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_d
}
}
lease_update_out:
nm_device_update_metered(self);
return;
}