libnm: add out_is_modified argument to from_dbus_fcn() to detect modification
Note that most implementations use g_object_set(), and it's not easy to detect modification. In those cases, we assume that modification happened -- just like also the GObject setter will emit a notification (as none of our properties use G_PARAM_EXPLICIT_NOTIFY).
This commit is contained in:
@@ -5024,6 +5024,7 @@ _routing_rules_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
|
|||||||
success = TRUE;
|
success = TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
*out_is_modified = rules_changed;
|
||||||
if (rules_changed)
|
if (rules_changed)
|
||||||
_routing_rules_notify(NM_SETTING_IP_CONFIG(setting));
|
_routing_rules_notify(NM_SETTING_IP_CONFIG(setting));
|
||||||
return success;
|
return success;
|
||||||
@@ -5760,6 +5761,7 @@ _nm_setting_property_from_dbus_fcn_direct_ip_config_gateway(
|
|||||||
connection_dict,
|
connection_dict,
|
||||||
value,
|
value,
|
||||||
parse_flags,
|
parse_flags,
|
||||||
|
out_is_modified,
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -361,8 +361,10 @@ ip4_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
|
|||||||
|
|
||||||
/* FIXME: properly handle errors */
|
/* 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;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
addrs = nm_utils_ip4_addresses_from_variant(value, &gateway);
|
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 */
|
/* FIXME: properly handle errors */
|
||||||
|
|
||||||
/* Ignore 'address-data' if we're going to process 'addresses' */
|
/* 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;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
addrs = nm_utils_ip_addresses_from_variant(value, AF_INET);
|
addrs = nm_utils_ip_addresses_from_variant(value, AF_INET);
|
||||||
g_object_set(setting, NM_SETTING_IP_CONFIG_ADDRESSES, addrs, NULL);
|
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 */
|
/* 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;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
routes = nm_utils_ip4_routes_from_variant(value);
|
routes = nm_utils_ip4_routes_from_variant(value);
|
||||||
g_object_set(setting, property_info->name, routes, NULL);
|
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 */
|
/* FIXME: properly handle errors */
|
||||||
|
|
||||||
/* Ignore 'route-data' if we're going to process 'routes' */
|
/* 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;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
routes = nm_utils_ip_routes_from_variant(value, AF_INET);
|
routes = nm_utils_ip_routes_from_variant(value, AF_INET);
|
||||||
g_object_set(setting, NM_SETTING_IP_CONFIG_ROUTES, routes, NULL);
|
g_object_set(setting, NM_SETTING_IP_CONFIG_ROUTES, routes, NULL);
|
||||||
|
@@ -398,10 +398,10 @@ ip6_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
|
|||||||
GPtrArray *addrs;
|
GPtrArray *addrs;
|
||||||
char * gateway = NULL;
|
char * gateway = NULL;
|
||||||
|
|
||||||
/* FIXME: properly handle errors */
|
if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) {
|
||||||
|
*out_is_modified = FALSE;
|
||||||
if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data"))
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
addrs = nm_utils_ip6_addresses_from_variant(value, &gateway);
|
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;
|
GPtrArray *addrs;
|
||||||
|
|
||||||
/* FIXME: properly handle errors */
|
|
||||||
|
|
||||||
/* Ignore 'address-data' if we're going to process 'addresses' */
|
/* 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;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
addrs = nm_utils_ip_addresses_from_variant(value, AF_INET6);
|
addrs = nm_utils_ip_addresses_from_variant(value, AF_INET6);
|
||||||
g_object_set(setting, NM_SETTING_IP_CONFIG_ADDRESSES, addrs, NULL);
|
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;
|
GPtrArray *routes;
|
||||||
|
|
||||||
/* FIXME: properly handle errors */
|
if (!_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) {
|
||||||
|
*out_is_modified = FALSE;
|
||||||
if (!_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data"))
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
routes = nm_utils_ip6_routes_from_variant(value);
|
routes = nm_utils_ip6_routes_from_variant(value);
|
||||||
g_object_set(setting, property_info->name, routes, NULL);
|
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;
|
GPtrArray *routes;
|
||||||
|
|
||||||
/* FIXME: properly handle errors */
|
|
||||||
|
|
||||||
/* Ignore 'route-data' if we're going to process 'routes' */
|
/* 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;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
routes = nm_utils_ip_routes_from_variant(value, AF_INET6);
|
routes = nm_utils_ip_routes_from_variant(value, AF_INET6);
|
||||||
g_object_set(setting, NM_SETTING_IP_CONFIG_ROUTES, routes, NULL);
|
g_object_set(setting, NM_SETTING_IP_CONFIG_ROUTES, routes, NULL);
|
||||||
|
@@ -1486,12 +1486,10 @@ tc_qdiscs_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil)
|
|||||||
static gboolean
|
static gboolean
|
||||||
tc_qdiscs_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
|
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);
|
qdiscs = _qdiscs_from_variant(value);
|
||||||
g_object_set(setting, NM_SETTING_TC_CONFIG_QDISCS, qdiscs, NULL);
|
g_object_set(setting, NM_SETTING_TC_CONFIG_QDISCS, qdiscs, NULL);
|
||||||
g_ptr_array_unref(qdiscs);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1677,6 +1677,7 @@ _peers_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
|
|||||||
success = TRUE;
|
success = TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
*out_is_modified = peers_changed;
|
||||||
if (peers_changed)
|
if (peers_changed)
|
||||||
_peers_notify(setting);
|
_peers_notify(setting);
|
||||||
return success;
|
return success;
|
||||||
|
@@ -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) {
|
if (_nm_utils_is_manager_process) {
|
||||||
/* in the manager process, we don't accept seen-bssid from the client.
|
/* in the manager process, we don't accept seen-bssid from the client.
|
||||||
* Do nothing. */
|
* Do nothing. */
|
||||||
|
*out_is_modified = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1071,6 +1071,7 @@ _nm_setting_property_to_dbus_fcn_gprop(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_n
|
|||||||
gboolean
|
gboolean
|
||||||
_nm_setting_property_from_dbus_fcn_ignore(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
|
_nm_setting_property_from_dbus_fcn_ignore(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
|
||||||
{
|
{
|
||||||
|
*out_is_modified = FALSE;
|
||||||
return TRUE;
|
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(
|
if (nm_strdup_reset_take(
|
||||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset),
|
_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);
|
g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec);
|
||||||
|
} else
|
||||||
|
*out_is_modified = FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1125,6 +1128,8 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||||||
_success; \
|
_success; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
*out_is_modified = FALSE;
|
||||||
|
|
||||||
switch (property_info->property_type->direct_type) {
|
switch (property_info->property_type->direct_type) {
|
||||||
case NM_VALUE_TYPE_BOOL:
|
case NM_VALUE_TYPE_BOOL:
|
||||||
{
|
{
|
||||||
@@ -1239,6 +1244,7 @@ out_unchanged:
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
out_notify:
|
out_notify:
|
||||||
|
*out_is_modified = TRUE;
|
||||||
g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec);
|
g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec);
|
||||||
return TRUE;
|
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);
|
g_value_init(&object_value, property_info->param_spec->value_type);
|
||||||
if (!set_property_from_dbus(property_info, value, &object_value)) {
|
if (!set_property_from_dbus(property_info, value, &object_value)) {
|
||||||
/* for backward behavior, fail unless best-effort is chosen. */
|
/* 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))
|
if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
g_set_error(error,
|
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,
|
property_info->param_spec->name,
|
||||||
&object_value,
|
&object_value,
|
||||||
&local)) {
|
&local)) {
|
||||||
|
*out_is_modified = FALSE;
|
||||||
if (!NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT))
|
if (!NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
@@ -1567,9 +1575,14 @@ _property_set_from_dbus(const NMSettInfoSetting * sett_info,
|
|||||||
GVariant * connection_dict,
|
GVariant * connection_dict,
|
||||||
GVariant * value,
|
GVariant * value,
|
||||||
NMSettingParseFlags parse_flags,
|
NMSettingParseFlags parse_flags,
|
||||||
|
gboolean * out_is_modified,
|
||||||
GError ** error)
|
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) {
|
if (!property_info->property_type->from_dbus_fcn) {
|
||||||
nm_assert(!property_info->param_spec);
|
nm_assert(!property_info->param_spec);
|
||||||
@@ -1597,13 +1610,21 @@ _property_set_from_dbus(const NMSettInfoSetting * sett_info,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!property_info->property_type->from_dbus_fcn(sett_info,
|
success = property_info->property_type->from_dbus_fcn(sett_info,
|
||||||
property_info,
|
property_info,
|
||||||
setting,
|
setting,
|
||||||
connection_dict,
|
connection_dict,
|
||||||
value,
|
value,
|
||||||
parse_flags,
|
parse_flags,
|
||||||
&local)) {
|
&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) {
|
if (property_info->property_type->from_dbus_is_full) {
|
||||||
/* the error we received from from_dbus_fcn() should be propagated, even
|
/* the error we received from from_dbus_fcn() should be propagated, even
|
||||||
* in non-strict mode. */
|
* in non-strict mode. */
|
||||||
@@ -1711,6 +1732,7 @@ init_from_dbus(NMSetting * setting,
|
|||||||
connection_dict,
|
connection_dict,
|
||||||
value,
|
value,
|
||||||
parse_flags,
|
parse_flags,
|
||||||
|
NULL,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -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,
|
if (!_nm_setting_use_legacy_property(setting,
|
||||||
connection_dict,
|
connection_dict,
|
||||||
"cloned-mac-address",
|
"cloned-mac-address",
|
||||||
"assigned-mac-address"))
|
"assigned-mac-address")) {
|
||||||
|
*out_is_modified = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
length = 0;
|
length = 0;
|
||||||
array = g_variant_get_fixed_array(value, &length, 1);
|
array = g_variant_get_fixed_array(value, &length, 1);
|
||||||
|
|
||||||
if (!length)
|
if (!length) {
|
||||||
|
*out_is_modified = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
str = nm_utils_hwaddr_ntoa(array, length);
|
str = nm_utils_hwaddr_ntoa(array, length);
|
||||||
g_object_set(setting, "cloned-mac-address", str, NULL);
|
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,
|
if (_nm_setting_use_legacy_property(setting,
|
||||||
connection_dict,
|
connection_dict,
|
||||||
"cloned-mac-address",
|
"cloned-mac-address",
|
||||||
"assigned-mac-address"))
|
"assigned-mac-address")) {
|
||||||
|
*out_is_modified = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
g_object_set(setting,
|
g_object_set(setting,
|
||||||
"cloned-mac-address",
|
"cloned-mac-address",
|
||||||
|
@@ -716,7 +716,7 @@ typedef struct {
|
|||||||
#define _NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS \
|
#define _NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS \
|
||||||
const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property_info, \
|
const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property_info, \
|
||||||
NMSetting *setting, GVariant *connection_dict, GVariant *value, \
|
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);
|
gboolean (*from_dbus_fcn)(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user