diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c index 995a872154..d9bfd7e17d 100644 --- a/src/libnm-core-impl/nm-setting-ip-config.c +++ b/src/libnm-core-impl/nm-setting-ip-config.c @@ -5024,6 +5024,7 @@ _routing_rules_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) success = TRUE; out: + *out_is_modified = rules_changed; if (rules_changed) _routing_rules_notify(NM_SETTING_IP_CONFIG(setting)); return success; @@ -5760,6 +5761,7 @@ _nm_setting_property_from_dbus_fcn_direct_ip_config_gateway( connection_dict, value, parse_flags, + out_is_modified, error); } diff --git a/src/libnm-core-impl/nm-setting-ip4-config.c b/src/libnm-core-impl/nm-setting-ip4-config.c index 8f8cbbb7e3..21b7e494ce 100644 --- a/src/libnm-core-impl/nm-setting-ip4-config.c +++ b/src/libnm-core-impl/nm-setting-ip4-config.c @@ -361,8 +361,10 @@ ip4_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) /* FIXME: properly handle errors */ - if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) + if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) { + *out_is_modified = FALSE; return TRUE; + } addrs = nm_utils_ip4_addresses_from_variant(value, &gateway); @@ -449,8 +451,10 @@ ip4_address_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) /* FIXME: properly handle errors */ /* Ignore 'address-data' if we're going to process 'addresses' */ - if (_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) + if (_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) { + *out_is_modified = FALSE; return TRUE; + } addrs = nm_utils_ip_addresses_from_variant(value, AF_INET); g_object_set(setting, NM_SETTING_IP_CONFIG_ADDRESSES, addrs, NULL); @@ -474,8 +478,10 @@ ip4_routes_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) /* FIXME: properly handle errors */ - if (!_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) + if (!_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) { + *out_is_modified = FALSE; return TRUE; + } routes = nm_utils_ip4_routes_from_variant(value); g_object_set(setting, property_info->name, routes, NULL); @@ -503,8 +509,10 @@ ip4_route_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) /* FIXME: properly handle errors */ /* Ignore 'route-data' if we're going to process 'routes' */ - if (_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) + if (_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) { + *out_is_modified = FALSE; return TRUE; + } routes = nm_utils_ip_routes_from_variant(value, AF_INET); g_object_set(setting, NM_SETTING_IP_CONFIG_ROUTES, routes, NULL); diff --git a/src/libnm-core-impl/nm-setting-ip6-config.c b/src/libnm-core-impl/nm-setting-ip6-config.c index 8273a51bd1..1ba213dc42 100644 --- a/src/libnm-core-impl/nm-setting-ip6-config.c +++ b/src/libnm-core-impl/nm-setting-ip6-config.c @@ -398,10 +398,10 @@ ip6_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) GPtrArray *addrs; char * gateway = NULL; - /* FIXME: properly handle errors */ - - if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) + if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) { + *out_is_modified = FALSE; return TRUE; + } addrs = nm_utils_ip6_addresses_from_variant(value, &gateway); @@ -433,11 +433,11 @@ ip6_address_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *addrs; - /* FIXME: properly handle errors */ - /* Ignore 'address-data' if we're going to process 'addresses' */ - if (_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) + if (_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) { + *out_is_modified = FALSE; return TRUE; + } addrs = nm_utils_ip_addresses_from_variant(value, AF_INET6); g_object_set(setting, NM_SETTING_IP_CONFIG_ADDRESSES, addrs, NULL); @@ -459,10 +459,10 @@ ip6_routes_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *routes; - /* FIXME: properly handle errors */ - - if (!_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) + if (!_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) { + *out_is_modified = FALSE; return TRUE; + } routes = nm_utils_ip6_routes_from_variant(value); g_object_set(setting, property_info->name, routes, NULL); @@ -487,11 +487,11 @@ ip6_route_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *routes; - /* FIXME: properly handle errors */ - /* Ignore 'route-data' if we're going to process 'routes' */ - if (_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) + if (_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) { + *out_is_modified = FALSE; return TRUE; + } routes = nm_utils_ip_routes_from_variant(value, AF_INET6); g_object_set(setting, NM_SETTING_IP_CONFIG_ROUTES, routes, NULL); diff --git a/src/libnm-core-impl/nm-setting-tc-config.c b/src/libnm-core-impl/nm-setting-tc-config.c index 4157fbb4a9..cd13709a47 100644 --- a/src/libnm-core-impl/nm-setting-tc-config.c +++ b/src/libnm-core-impl/nm-setting-tc-config.c @@ -1486,12 +1486,10 @@ tc_qdiscs_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) static gboolean tc_qdiscs_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { - GPtrArray *qdiscs; + gs_unref_ptrarray GPtrArray *qdiscs = NULL; qdiscs = _qdiscs_from_variant(value); g_object_set(setting, NM_SETTING_TC_CONFIG_QDISCS, qdiscs, NULL); - g_ptr_array_unref(qdiscs); - return TRUE; } diff --git a/src/libnm-core-impl/nm-setting-wireguard.c b/src/libnm-core-impl/nm-setting-wireguard.c index f615f526ed..27b8148891 100644 --- a/src/libnm-core-impl/nm-setting-wireguard.c +++ b/src/libnm-core-impl/nm-setting-wireguard.c @@ -1677,6 +1677,7 @@ _peers_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) success = TRUE; out: + *out_is_modified = peers_changed; if (peers_changed) _peers_notify(setting); return success; diff --git a/src/libnm-core-impl/nm-setting-wireless.c b/src/libnm-core-impl/nm-setting-wireless.c index d959e53ae3..7562795491 100644 --- a/src/libnm-core-impl/nm-setting-wireless.c +++ b/src/libnm-core-impl/nm-setting-wireless.c @@ -771,6 +771,7 @@ _from_dbus_fcn_seen_bssids(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) if (_nm_utils_is_manager_process) { /* in the manager process, we don't accept seen-bssid from the client. * Do nothing. */ + *out_is_modified = FALSE; return TRUE; } diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index b7c7bc2650..0fb43925b8 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -1071,6 +1071,7 @@ _nm_setting_property_to_dbus_fcn_gprop(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_n gboolean _nm_setting_property_from_dbus_fcn_ignore(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { + *out_is_modified = FALSE; return TRUE; } @@ -1091,8 +1092,10 @@ _nm_setting_property_from_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_FROM_DB if (nm_strdup_reset_take( _nm_setting_get_private(setting, sett_info, property_info->direct_offset), - length > 0 ? nm_utils_hwaddr_ntoa(array, length) : NULL)) + length > 0 ? nm_utils_hwaddr_ntoa(array, length) : NULL)) { g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec); + } else + *out_is_modified = FALSE; return TRUE; } @@ -1125,6 +1128,8 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _success; \ }) + *out_is_modified = FALSE; + switch (property_info->property_type->direct_type) { case NM_VALUE_TYPE_BOOL: { @@ -1239,6 +1244,7 @@ out_unchanged: return TRUE; out_notify: + *out_is_modified = TRUE; g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec); return TRUE; @@ -1282,6 +1288,7 @@ _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _ g_value_init(&object_value, property_info->param_spec->value_type); if (!set_property_from_dbus(property_info, value, &object_value)) { /* for backward behavior, fail unless best-effort is chosen. */ + *out_is_modified = FALSE; if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)) return TRUE; g_set_error(error, @@ -1302,6 +1309,7 @@ _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _ property_info->param_spec->name, &object_value, &local)) { + *out_is_modified = FALSE; if (!NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) return TRUE; g_set_error(error, @@ -1567,9 +1575,14 @@ _property_set_from_dbus(const NMSettInfoSetting * sett_info, GVariant * connection_dict, GVariant * value, NMSettingParseFlags parse_flags, + gboolean * out_is_modified, GError ** error) { - gs_free_error GError *local = NULL; + gs_free_error GError *local = NULL; + NMTernary is_modified = NM_TERNARY_DEFAULT; + gboolean success; + + NM_SET_OUT(out_is_modified, FALSE); if (!property_info->property_type->from_dbus_fcn) { nm_assert(!property_info->param_spec); @@ -1597,16 +1610,24 @@ _property_set_from_dbus(const NMSettInfoSetting * sett_info, return FALSE; } - if (!property_info->property_type->from_dbus_fcn(sett_info, - property_info, - setting, - connection_dict, - value, - parse_flags, - &local)) { + success = property_info->property_type->from_dbus_fcn(sett_info, + property_info, + setting, + connection_dict, + value, + parse_flags, + &is_modified, + &local); + + /* We allow the from_dbus_fcn() to leave is_modified at NM_TERNARY_DEFAULT, + * which we assume to also mean that it was modified. That is, we err on the + * side of assuming modification happened. */ + NM_SET_OUT(out_is_modified, is_modified != FALSE); + + if (!success) { if (property_info->property_type->from_dbus_is_full) { /* the error we received from from_dbus_fcn() should be propagated, even - * in non-strict mode. */ + * in non-strict mode. */ } else if (!NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) return TRUE; g_set_error(error, @@ -1711,6 +1732,7 @@ init_from_dbus(NMSetting * setting, connection_dict, value, parse_flags, + NULL, error)) return FALSE; } diff --git a/src/libnm-core-impl/nm-utils.c b/src/libnm-core-impl/nm-utils.c index 7032fe0cf5..04ae5f91b5 100644 --- a/src/libnm-core-impl/nm-utils.c +++ b/src/libnm-core-impl/nm-utils.c @@ -4084,14 +4084,18 @@ _nm_utils_hwaddr_cloned_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) if (!_nm_setting_use_legacy_property(setting, connection_dict, "cloned-mac-address", - "assigned-mac-address")) + "assigned-mac-address")) { + *out_is_modified = FALSE; return TRUE; + } length = 0; array = g_variant_get_fixed_array(value, &length, 1); - if (!length) + if (!length) { + *out_is_modified = FALSE; return TRUE; + } str = nm_utils_hwaddr_ntoa(array, length); g_object_set(setting, "cloned-mac-address", str, NULL); @@ -4143,8 +4147,10 @@ _nm_utils_hwaddr_cloned_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) if (_nm_setting_use_legacy_property(setting, connection_dict, "cloned-mac-address", - "assigned-mac-address")) + "assigned-mac-address")) { + *out_is_modified = FALSE; return TRUE; + } g_object_set(setting, "cloned-mac-address", diff --git a/src/libnm-core-intern/nm-core-internal.h b/src/libnm-core-intern/nm-core-internal.h index 7add89db8f..3fed38d552 100644 --- a/src/libnm-core-intern/nm-core-internal.h +++ b/src/libnm-core-intern/nm-core-internal.h @@ -716,7 +716,7 @@ typedef struct { #define _NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS \ const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property_info, \ NMSetting *setting, GVariant *connection_dict, GVariant *value, \ - NMSettingParseFlags parse_flags, GError **error + NMSettingParseFlags parse_flags, NMTernary *out_is_modified, GError **error gboolean (*from_dbus_fcn)(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);