summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Cardace <acardace@redhat.com>2020-08-04 18:19:47 +0200
committerThomas Haller <thaller@redhat.com>2020-08-28 10:20:27 +0200
commit12387d8a026c72144643f53eda126ed7316301f2 (patch)
tree737045c9b74974dfedfa79854c36979a46468af4
parent2c24b6b4b693e18ce3e0714fc8bf3314fef87557 (diff)
downloadNetworkManager-th/nm-1-24.tar.gz
bond: fix can_reapply_change() false positivesth/nm-1-24
can_reapply_change() would wrongly return true for unsupported reapply values because it used 'nm_setting_bond_get_option_default()' that is ill-named because it returns the overriden option other than its default value. https://bugzilla.redhat.com/show_bug.cgi?id=1847814 Fixes: 9bd07336ef16 ('bond: bond options logic rework') (cherry picked from commit 04d6ca1fb8bdbfffd70a257424f9e8c29fcb8037) (cherry picked from commit 63b5274dda0c52148ec8e8ca41e94e47b1e7d653)
-rw-r--r--src/devices/nm-device-bond.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index c15605ce16..025b851260 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -431,14 +431,12 @@ create_and_realize (NMDevice *device,
static gboolean
check_changed_options (NMSettingBond *s_a, NMSettingBond *s_b, GError **error)
{
- guint i, num;
- const char *name = NULL, *value_a = NULL, *value_b = NULL;
+ const char **option_list;
- /* Check that options in @s_a have compatible changes in @s_b */
+ option_list = nm_setting_bond_get_valid_options (NULL);
- num = nm_setting_bond_get_num_options (s_a);
- for (i = 0; i < num; i++) {
- nm_setting_bond_get_option (s_a, i, &name, &value_a);
+ for (; *option_list; ++option_list) {
+ const char *name = *option_list;
/* We support changes to these */
if (NM_IN_STRSET (name,
@@ -447,15 +445,9 @@ check_changed_options (NMSettingBond *s_a, NMSettingBond *s_b, GError **error)
continue;
}
- /* Missing in @s_b, but has a default value in @s_a */
- value_b = nm_setting_bond_get_option_by_name (s_b, name);
- if ( !value_b
- && nm_streq0 (value_a, nm_setting_bond_get_option_default (s_a, name))) {
- continue;
- }
-
/* Reject any other changes */
- if (!nm_streq0 (value_a, value_b)) {
+ if (!nm_streq0 (nm_setting_bond_get_option_normalized (s_a, name),
+ nm_setting_bond_get_option_normalized (s_b, name))) {
g_set_error (error,
NM_DEVICE_ERROR,
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
@@ -477,7 +469,6 @@ can_reapply_change (NMDevice *device,
GError **error)
{
NMDeviceClass *device_class;
- NMSettingBond *s_bond_old, *s_bond_new;
/* Only handle bond setting here, delegate other settings to parent class */
if (nm_streq (setting_name, NM_SETTING_BOND_SETTING_NAME)) {
@@ -487,15 +478,7 @@ can_reapply_change (NMDevice *device,
NM_SETTING_BOND_OPTIONS))
return FALSE;
- s_bond_old = NM_SETTING_BOND (s_old);
- s_bond_new = NM_SETTING_BOND (s_new);
-
- if ( !check_changed_options (s_bond_old, s_bond_new, error)
- || !check_changed_options (s_bond_new, s_bond_old, error)) {
- return FALSE;
- }
-
- return TRUE;
+ return check_changed_options (NM_SETTING_BOND (s_old), NM_SETTING_BOND (s_new), error);
}
device_class = NM_DEVICE_CLASS (nm_device_bond_parent_class);