From 0dc999d80ec65dfaf230b8e909d543acef4af677 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 26 May 2016 18:29:50 +0200 Subject: [PATCH] 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 --- libnm-core/nm-setting-team-port.c | 8 +++++++- libnm-core/nm-setting-team.c | 8 +++++++- 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);