diff --git a/src/libnm-core-impl/nm-setting-ip4-config.c b/src/libnm-core-impl/nm-setting-ip4-config.c index c6a8bbab0f..e2d6a26bbc 100644 --- a/src/libnm-core-impl/nm-setting-ip4-config.c +++ b/src/libnm-core-impl/nm-setting-ip4-config.c @@ -994,7 +994,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) "address-labels", NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING_ARRAY, .to_dbus_fcn = ip4_address_labels_get, - .compare_fcn = _nm_setting_property_compare_fcn_default, )); + .compare_fcn = _nm_setting_property_compare_fcn_ignore, )); /* ---dbus--- * property: address-data @@ -1010,7 +1010,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) "address-data", NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = ip4_address_data_get, - .compare_fcn = _nm_setting_property_compare_fcn_default, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip4_address_data_set, )); /* ---dbus--- @@ -1065,7 +1065,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) "route-data", NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = ip4_route_data_get, - .compare_fcn = _nm_setting_property_compare_fcn_default, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip4_route_data_set, )); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/src/libnm-core-impl/nm-setting-ip6-config.c b/src/libnm-core-impl/nm-setting-ip6-config.c index 15b87433c4..a2cbd69e04 100644 --- a/src/libnm-core-impl/nm-setting-ip6-config.c +++ b/src/libnm-core-impl/nm-setting-ip6-config.c @@ -1062,7 +1062,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) "address-data", NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = ip6_address_data_get, - .compare_fcn = _nm_setting_property_compare_fcn_default, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip6_address_data_set, )); /* ---dbus--- @@ -1105,7 +1105,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) "route-data", NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = ip6_route_data_get, - .compare_fcn = _nm_setting_property_compare_fcn_default, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip6_route_data_set, )); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/src/libnm-core-impl/nm-setting-private.h b/src/libnm-core-impl/nm-setting-private.h index 43001b8b1f..c939111236 100644 --- a/src/libnm-core-impl/nm-setting-private.h +++ b/src/libnm-core-impl/nm-setting-private.h @@ -303,6 +303,14 @@ gboolean _nm_setting_aggregate(NMSetting *setting, NMConnectionAggregateType typ gboolean _nm_setting_slave_type_is_valid(const char *slave_type, const char **out_port_type); +NMTernary _nm_setting_property_compare_fcn_ignore(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags); + NMTernary _nm_setting_property_compare_fcn_default(const NMSettInfoSetting * sett_info, const NMSettInfoProperty *property_info, NMConnection * con_a, diff --git a/src/libnm-core-impl/nm-setting-wireless.c b/src/libnm-core-impl/nm-setting-wireless.c index ee2f1c5ed9..726bd19f4f 100644 --- a/src/libnm-core-impl/nm-setting-wireless.c +++ b/src/libnm-core-impl/nm-setting-wireless.c @@ -1926,7 +1926,7 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) "security", NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING, .to_dbus_fcn = nm_setting_wireless_get_security, - .compare_fcn = _nm_setting_property_compare_fcn_default, )); + .compare_fcn = _nm_setting_property_compare_fcn_ignore, )); /** * NMSettingWireless:wake-on-wlan: diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index a16cd9da66..a89396f66a 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -1714,6 +1714,18 @@ _nm_setting_should_compare_secret_property(NMSetting * setting, /*****************************************************************************/ +NMTernary +_nm_setting_property_compare_fcn_ignore(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) +{ + return NM_TERNARY_DEFAULT; +} + NMTernary _nm_setting_property_compare_fcn_default(const NMSettInfoSetting * sett_info, const NMSettInfoProperty *property_info, @@ -1726,7 +1738,7 @@ _nm_setting_property_compare_fcn_default(const NMSettInfoSetting * sett_info, const GParamSpec *param_spec = property_info->param_spec; if (!param_spec) - return NM_TERNARY_DEFAULT; + return nm_assert_unreachable_val(NM_TERNARY_DEFAULT); if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_FUZZY) && NM_FLAGS_ANY(param_spec->flags, NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET)) @@ -2730,7 +2742,7 @@ _nm_setting_get_deprecated_virtual_interface_name(const NMSettInfoSetting * const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interface_name = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING, - .compare_fcn = _nm_setting_property_compare_fcn_default, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .to_dbus_fcn = _nm_setting_get_deprecated_virtual_interface_name, ); @@ -2738,13 +2750,13 @@ const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT( G_VARIANT_TYPE_INT32, /* No functions set. This property type is to silently ignore the value on D-Bus. */ - .compare_fcn = _nm_setting_property_compare_fcn_default, ); + .compare_fcn = _nm_setting_property_compare_fcn_ignore); const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT( G_VARIANT_TYPE_UINT32, /* No functions set. This property type is to silently ignore the value on D-Bus. */ - .compare_fcn = _nm_setting_property_compare_fcn_default, ); + .compare_fcn = _nm_setting_property_compare_fcn_ignore); const NMSettInfoPropertType nm_sett_info_propert_type_plain_i = NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_INT32, diff --git a/src/libnm-core-impl/nm-utils.c b/src/libnm-core-impl/nm-utils.c index 0d86e26e7a..e5467bbad4 100644 --- a/src/libnm-core-impl/nm-utils.c +++ b/src/libnm-core-impl/nm-utils.c @@ -4121,7 +4121,7 @@ _nm_utils_hwaddr_cloned_data_set(NMSetting * setting, const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING, - .compare_fcn = _nm_setting_property_compare_fcn_default, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .to_dbus_fcn = _nm_utils_hwaddr_cloned_data_synth, .from_dbus_fcn = _nm_utils_hwaddr_cloned_data_set, ); diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index 1d6fc9ee61..a8aeed8596 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -4525,7 +4525,19 @@ check_done:; g_assert_not_reached(); if (sip->property_type->compare_fcn == _nm_setting_property_compare_fcn_default) { - /* pass */ + g_assert(sip->param_spec); + } else if (sip->property_type->compare_fcn == _nm_setting_property_compare_fcn_ignore) { + if (NM_IN_SET(sip->property_type, + &nm_sett_info_propert_type_deprecated_ignore_i, + &nm_sett_info_propert_type_deprecated_ignore_u, + &nm_sett_info_propert_type_assigned_mac_address)) { + /* pass */ + } else if (!sip->param_spec) { + /* pass */ + } else { + /* ignoring a property for comparison make only sense in very specific cases. */ + g_assert_not_reached(); + } } else if (sip->property_type->compare_fcn) { /* pass */ } else {