|
|
146a1d |
From 957e8465acdb9aaca0fbc797ac6df1efc2270f57 Mon Sep 17 00:00:00 2001
|
|
|
146a1d |
From: Antonio Cardace <acardace@redhat.com>
|
|
|
146a1d |
Date: Tue, 4 Aug 2020 18:19:47 +0200
|
|
|
146a1d |
Subject: [PATCH] bond: fix can_reapply_change() false positives
|
|
|
146a1d |
|
|
|
146a1d |
can_reapply_change() would wrongly return true for
|
|
|
146a1d |
unsupported reapply values because it used 'nm_setting_bond_get_option_default()'
|
|
|
146a1d |
that is ill-named because it returns the overriden option other than
|
|
|
146a1d |
its default value.
|
|
|
146a1d |
|
|
|
146a1d |
https://bugzilla.redhat.com/show_bug.cgi?id=1847814
|
|
|
146a1d |
|
|
|
146a1d |
Fixes: 9bd07336ef16 ('bond: bond options logic rework')
|
|
|
146a1d |
(cherry picked from commit 04d6ca1fb8bdbfffd70a257424f9e8c29fcb8037)
|
|
|
146a1d |
(cherry picked from commit 63b5274dda0c52148ec8e8ca41e94e47b1e7d653)
|
|
|
146a1d |
---
|
|
|
146a1d |
src/devices/nm-device-bond.c | 31 +++++++------------------------
|
|
|
146a1d |
1 file changed, 7 insertions(+), 24 deletions(-)
|
|
|
146a1d |
|
|
|
146a1d |
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
|
|
|
146a1d |
index e36eba61b..164f6aaa7 100644
|
|
|
146a1d |
--- a/src/devices/nm-device-bond.c
|
|
|
146a1d |
+++ b/src/devices/nm-device-bond.c
|
|
|
146a1d |
@@ -516,14 +516,12 @@ create_and_realize (NMDevice *device,
|
|
|
146a1d |
static gboolean
|
|
|
146a1d |
check_changed_options (NMSettingBond *s_a, NMSettingBond *s_b, GError **error)
|
|
|
146a1d |
{
|
|
|
146a1d |
- guint i, num;
|
|
|
146a1d |
- const char *name = NULL, *value_a = NULL, *value_b = NULL;
|
|
|
146a1d |
+ const char **option_list;
|
|
|
146a1d |
|
|
|
146a1d |
- /* Check that options in @s_a have compatible changes in @s_b */
|
|
|
146a1d |
+ option_list = nm_setting_bond_get_valid_options (NULL);
|
|
|
146a1d |
|
|
|
146a1d |
- num = nm_setting_bond_get_num_options (s_a);
|
|
|
146a1d |
- for (i = 0; i < num; i++) {
|
|
|
146a1d |
- nm_setting_bond_get_option (s_a, i, &name, &value_a);
|
|
|
146a1d |
+ for (; *option_list; ++option_list) {
|
|
|
146a1d |
+ const char *name = *option_list;
|
|
|
146a1d |
|
|
|
146a1d |
/* We support changes to these */
|
|
|
146a1d |
if (NM_IN_STRSET (name,
|
|
|
146a1d |
@@ -532,15 +530,9 @@ check_changed_options (NMSettingBond *s_a, NMSettingBond *s_b, GError **error)
|
|
|
146a1d |
continue;
|
|
|
146a1d |
}
|
|
|
146a1d |
|
|
|
146a1d |
- /* Missing in @s_b, but has a default value in @s_a */
|
|
|
146a1d |
- value_b = nm_setting_bond_get_option_by_name (s_b, name);
|
|
|
146a1d |
- if ( !value_b
|
|
|
146a1d |
- && nm_streq0 (value_a, nm_setting_bond_get_option_default (s_a, name))) {
|
|
|
146a1d |
- continue;
|
|
|
146a1d |
- }
|
|
|
146a1d |
-
|
|
|
146a1d |
/* Reject any other changes */
|
|
|
146a1d |
- if (!nm_streq0 (value_a, value_b)) {
|
|
|
146a1d |
+ if (!nm_streq0 (nm_setting_bond_get_option_normalized (s_a, name),
|
|
|
146a1d |
+ nm_setting_bond_get_option_normalized (s_b, name))) {
|
|
|
146a1d |
g_set_error (error,
|
|
|
146a1d |
NM_DEVICE_ERROR,
|
|
|
146a1d |
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
|
|
146a1d |
@@ -562,7 +554,6 @@ can_reapply_change (NMDevice *device,
|
|
|
146a1d |
GError **error)
|
|
|
146a1d |
{
|
|
|
146a1d |
NMDeviceClass *device_class;
|
|
|
146a1d |
- NMSettingBond *s_bond_old, *s_bond_new;
|
|
|
146a1d |
|
|
|
146a1d |
/* Only handle bond setting here, delegate other settings to parent class */
|
|
|
146a1d |
if (nm_streq (setting_name, NM_SETTING_BOND_SETTING_NAME)) {
|
|
|
146a1d |
@@ -572,15 +563,7 @@ can_reapply_change (NMDevice *device,
|
|
|
146a1d |
NM_SETTING_BOND_OPTIONS))
|
|
|
146a1d |
return FALSE;
|
|
|
146a1d |
|
|
|
146a1d |
- s_bond_old = NM_SETTING_BOND (s_old);
|
|
|
146a1d |
- s_bond_new = NM_SETTING_BOND (s_new);
|
|
|
146a1d |
-
|
|
|
146a1d |
- if ( !check_changed_options (s_bond_old, s_bond_new, error)
|
|
|
146a1d |
- || !check_changed_options (s_bond_new, s_bond_old, error)) {
|
|
|
146a1d |
- return FALSE;
|
|
|
146a1d |
- }
|
|
|
146a1d |
-
|
|
|
146a1d |
- return TRUE;
|
|
|
146a1d |
+ return check_changed_options (NM_SETTING_BOND (s_old), NM_SETTING_BOND (s_new), error);
|
|
|
146a1d |
}
|
|
|
146a1d |
|
|
|
146a1d |
device_class = NM_DEVICE_CLASS (nm_device_bond_parent_class);
|
|
|
146a1d |
--
|
|
|
146a1d |
2.26.2
|
|
|
146a1d |
|