summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-05-26 18:29:50 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2016-05-31 10:59:43 +0200
commit0dc999d80ec65dfaf230b8e909d543acef4af677 (patch)
tree832d67cdf42b39f86a8f4c1bb610157fcaf216e5
parenta2f5ba8e06eed1090c0960652641c74a83f15896 (diff)
downloadNetworkManager-0dc999d80ec65dfaf230b8e909d543acef4af677.tar.gz
libnm-core: fix comparison of team configuration
NMSettingTeam implements a custom compare_property() method in order to perform a relaxed matching on team configurations when it is necessary to assume a connection. However, the method is called also when the core needs to check if a connection has changed before an update. In that case it is better to use the default string comparison on the property, otherwise the second of these commands would not have effect: $ nmcli connection modify team0 team.config '' $ nmcli connection modify team0 team.config '{ }' because compare_property() returns TRUE. Use the @flags argument to distinguish the two cases. Fixes: 82f8a54854f65d2bf648329d1d9b411de04959cb
-rw-r--r--libnm-core/nm-setting-team-port.c8
-rw-r--r--libnm-core/nm-setting-team.c8
2 files changed, 14 insertions, 2 deletions
diff --git a/libnm-core/nm-setting-team-port.c b/libnm-core/nm-setting-team-port.c
index d9a444fe45..8d570c9e1c 100644
--- a/libnm-core/nm-setting-team-port.c
+++ b/libnm-core/nm-setting-team-port.c
@@ -136,7 +136,13 @@ compare_property (NMSetting *setting,
{
NMSettingClass *parent_class;
- if (nm_streq0 (prop_spec->name, NM_SETTING_TEAM_PORT_CONFIG)) {
+ /* If we are trying to match a connection in order to assume it (and thus
+ * @flags contains INFERRABLE), use the "relaxed" matching for team
+ * configuration. Otherwise, for all other purposes (including connection
+ * comparison before an update), resort to the default string comparison.
+ */
+ if ( NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)
+ && nm_streq0 (prop_spec->name, NM_SETTING_TEAM_PORT_CONFIG)) {
return _nm_utils_team_config_equal (NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->config,
NM_SETTING_TEAM_PORT_GET_PRIVATE (other)->config,
TRUE);
diff --git a/libnm-core/nm-setting-team.c b/libnm-core/nm-setting-team.c
index f3bf758633..36cd312b6e 100644
--- a/libnm-core/nm-setting-team.c
+++ b/libnm-core/nm-setting-team.c
@@ -109,7 +109,13 @@ compare_property (NMSetting *setting,
{
NMSettingClass *parent_class;
- if (nm_streq0 (prop_spec->name, NM_SETTING_TEAM_CONFIG)) {
+ /* If we are trying to match a connection in order to assume it (and thus
+ * @flags contains INFERRABLE), use the "relaxed" matching for team
+ * configuration. Otherwise, for all other purposes (including connection
+ * comparison before an update), resort to the default string comparison.
+ */
+ if ( NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)
+ && nm_streq0 (prop_spec->name, NM_SETTING_TEAM_CONFIG)) {
return _nm_utils_team_config_equal (NM_SETTING_TEAM_GET_PRIVATE (setting)->config,
NM_SETTING_TEAM_GET_PRIVATE (other)->config,
FALSE);