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: 82f8a54854
This commit is contained in:
Beniamino Galvani 2016-05-26 18:29:50 +02:00
parent a2f5ba8e06
commit 0dc999d80e
2 changed files with 14 additions and 2 deletions

View file

@ -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);

View file

@ -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);