cloud-setup: always replace addresses, routes and rules in _nmc_mangle_connection()

If the list of addresses, routes and rules is empty, we still want to mangle
the applied connection, to also have an empty list.

nm-cloud-setup has certain expectations. For example, that the static addresses,
routes and rules of the active connection is entirely under the control of the
tool. For example, so it usually replaces the lists entirely. It also should do
that, if the new list is empty.

Maybe, one day there could be more complex merging strategies, where the user could
also add static addresses, routes, or rules to the profile, and nm-cloud-setup
would preserve them. However, that is not implemented, nor is it clear how exactly
that would work.
This commit is contained in:
Thomas Haller 2020-07-20 19:02:57 +02:00
parent 6f29ed9f3f
commit e73bd2cf5f
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -358,23 +358,17 @@ _nmc_mangle_connection (NMDevice *device,
for (i = 0; i < config_data->iproutes_len; ++i)
g_ptr_array_add (routes_new, config_data->iproutes_arr[i]);
if (addrs_new->len) {
addrs_changed = nmcs_setting_ip_replace_ipv4_addresses (s_ip,
(NMIPAddress **) addrs_new->pdata,
addrs_new->len);
}
addrs_changed = nmcs_setting_ip_replace_ipv4_addresses (s_ip,
(NMIPAddress **) addrs_new->pdata,
addrs_new->len);
if (routes_new->len) {
routes_changed = nmcs_setting_ip_replace_ipv4_routes (s_ip,
(NMIPRoute **) routes_new->pdata,
routes_new->len);
}
routes_changed = nmcs_setting_ip_replace_ipv4_routes (s_ip,
(NMIPRoute **) routes_new->pdata,
routes_new->len);
if (rules_new->len) {
rules_changed = nmcs_setting_ip_replace_ipv4_rules (s_ip,
(NMIPRoutingRule **) rules_new->pdata,
rules_new->len);
}
rules_changed = nmcs_setting_ip_replace_ipv4_rules (s_ip,
(NMIPRoutingRule **) rules_new->pdata,
rules_new->len);
NM_SET_OUT (out_changed, addrs_changed
|| routes_changed