diff --git a/NEWS b/NEWS index c5950d390b..77b7463b1f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,13 @@ +============================================ +NetworkManager-1.6 +Overview of changes since NetworkManager-1.4 +============================================ + +This is a new stable release of NetworkManager. Notable changes include: + +* Fix emission of NM-style PropertiesChanged signals and deprecate them + for PropertiesChanged on "org.freedesktop.DBus.Properties" interface. + ============================================ NetworkManager-1.4 Overview of changes since NetworkManager-1.2 diff --git a/introspection/nm-access-point.xml b/introspection/nm-access-point.xml index 0c1ebf23ca..617c8671b6 100644 --- a/introspection/nm-access-point.xml +++ b/introspection/nm-access-point.xml @@ -93,6 +93,8 @@ diff --git a/introspection/nm-active-connection.xml b/introspection/nm-active-connection.xml index a4e9417041..383ede34a9 100644 --- a/introspection/nm-active-connection.xml +++ b/introspection/nm-active-connection.xml @@ -148,6 +148,8 @@ diff --git a/introspection/nm-checkpoint.xml b/introspection/nm-checkpoint.xml index d0fbda8dec..1c5050f279 100644 --- a/introspection/nm-checkpoint.xml +++ b/introspection/nm-checkpoint.xml @@ -34,6 +34,8 @@ diff --git a/introspection/nm-device-adsl.xml b/introspection/nm-device-adsl.xml index 5ad397e6a4..0986f06995 100644 --- a/introspection/nm-device-adsl.xml +++ b/introspection/nm-device-adsl.xml @@ -5,6 +5,8 @@ diff --git a/introspection/nm-device-bond.xml b/introspection/nm-device-bond.xml index fc0249d937..e6288a1530 100644 --- a/introspection/nm-device-bond.xml +++ b/introspection/nm-device-bond.xml @@ -28,6 +28,8 @@ diff --git a/introspection/nm-device-bridge.xml b/introspection/nm-device-bridge.xml index c2e8ffd3b3..a6c5710dc3 100644 --- a/introspection/nm-device-bridge.xml +++ b/introspection/nm-device-bridge.xml @@ -28,6 +28,8 @@ diff --git a/introspection/nm-device-bt.xml b/introspection/nm-device-bt.xml index 6249085b2e..f891220d25 100644 --- a/introspection/nm-device-bt.xml +++ b/introspection/nm-device-bt.xml @@ -28,6 +28,8 @@ diff --git a/introspection/nm-device-ethernet.xml b/introspection/nm-device-ethernet.xml index ddfa74bb09..3aa4540fb5 100644 --- a/introspection/nm-device-ethernet.xml +++ b/introspection/nm-device-ethernet.xml @@ -42,6 +42,8 @@ diff --git a/introspection/nm-device-generic.xml b/introspection/nm-device-generic.xml index e79ff700ac..39aafc2c1b 100644 --- a/introspection/nm-device-generic.xml +++ b/introspection/nm-device-generic.xml @@ -19,6 +19,8 @@ diff --git a/introspection/nm-device-infiniband.xml b/introspection/nm-device-infiniband.xml index 9848a07430..34b5fadd1f 100644 --- a/introspection/nm-device-infiniband.xml +++ b/introspection/nm-device-infiniband.xml @@ -20,6 +20,8 @@ diff --git a/introspection/nm-device-ip-tunnel.xml b/introspection/nm-device-ip-tunnel.xml index 45f3a3f710..dda71e3e67 100644 --- a/introspection/nm-device-ip-tunnel.xml +++ b/introspection/nm-device-ip-tunnel.xml @@ -86,6 +86,8 @@ diff --git a/introspection/nm-device-macvlan.xml b/introspection/nm-device-macvlan.xml index 876b685cc9..e0b58ba4da 100644 --- a/introspection/nm-device-macvlan.xml +++ b/introspection/nm-device-macvlan.xml @@ -33,6 +33,8 @@ diff --git a/introspection/nm-device-modem.xml b/introspection/nm-device-modem.xml index 1d4bd65ee9..29eff68246 100644 --- a/introspection/nm-device-modem.xml +++ b/introspection/nm-device-modem.xml @@ -5,6 +5,8 @@ diff --git a/introspection/nm-device-olpc-mesh.xml b/introspection/nm-device-olpc-mesh.xml index b2ab126ec6..3d6162f334 100644 --- a/introspection/nm-device-olpc-mesh.xml +++ b/introspection/nm-device-olpc-mesh.xml @@ -27,7 +27,7 @@ PropertiesChanged: @properties: A dictionary containing the FIXME: check changed parameters. - Emitted when the wireless device's properties changed. + DEPRECATED. Use the standard "PropertiesChanged" signal from "org.freedesktop.DBus.Properties" instead which exists since version NetworkManager 1.2.0. --> diff --git a/introspection/nm-device-statistics.xml b/introspection/nm-device-statistics.xml index bdb19c89ce..84c3b6fe47 100644 --- a/introspection/nm-device-statistics.xml +++ b/introspection/nm-device-statistics.xml @@ -29,6 +29,8 @@ diff --git a/introspection/nm-device-team.xml b/introspection/nm-device-team.xml index 64faaec4b0..c7b50a386d 100644 --- a/introspection/nm-device-team.xml +++ b/introspection/nm-device-team.xml @@ -35,6 +35,8 @@ diff --git a/introspection/nm-device-tun.xml b/introspection/nm-device-tun.xml index a11461c1a1..68167cc57d 100644 --- a/introspection/nm-device-tun.xml +++ b/introspection/nm-device-tun.xml @@ -57,6 +57,8 @@ diff --git a/introspection/nm-device-veth.xml b/introspection/nm-device-veth.xml index b064874e0d..93c7c87024 100644 --- a/introspection/nm-device-veth.xml +++ b/introspection/nm-device-veth.xml @@ -12,6 +12,8 @@ diff --git a/introspection/nm-device-vlan.xml b/introspection/nm-device-vlan.xml index 7d8fbdce92..e5bf7c44ed 100644 --- a/introspection/nm-device-vlan.xml +++ b/introspection/nm-device-vlan.xml @@ -34,6 +34,8 @@ diff --git a/introspection/nm-device-vxlan.xml b/introspection/nm-device-vxlan.xml index ec17717d6f..8eae63c647 100644 --- a/introspection/nm-device-vxlan.xml +++ b/introspection/nm-device-vxlan.xml @@ -131,6 +131,8 @@ diff --git a/introspection/nm-device-wifi.xml b/introspection/nm-device-wifi.xml index c1f378d8c0..1973b417dc 100644 --- a/introspection/nm-device-wifi.xml +++ b/introspection/nm-device-wifi.xml @@ -93,9 +93,9 @@ diff --git a/introspection/nm-device-wimax.xml b/introspection/nm-device-wimax.xml index 02539dbb66..844856cc19 100644 --- a/introspection/nm-device-wimax.xml +++ b/introspection/nm-device-wimax.xml @@ -83,7 +83,7 @@ PropertiesChanged: @properties: A dictionary mapping property names to variant boxed values. - Emitted when the WiMax device's properties changed. + DEPRECATED. Use the standard "PropertiesChanged" signal from "org.freedesktop.DBus.Properties" instead which exists since version NetworkManager 1.2.0. --> diff --git a/introspection/nm-dhcp4-config.xml b/introspection/nm-dhcp4-config.xml index e9363f9e21..5244bcaaa0 100644 --- a/introspection/nm-dhcp4-config.xml +++ b/introspection/nm-dhcp4-config.xml @@ -19,6 +19,8 @@ diff --git a/introspection/nm-dhcp6-config.xml b/introspection/nm-dhcp6-config.xml index 7ecdf35cab..09e2ca8676 100644 --- a/introspection/nm-dhcp6-config.xml +++ b/introspection/nm-dhcp6-config.xml @@ -19,6 +19,8 @@ diff --git a/introspection/nm-ip4-config.xml b/introspection/nm-ip4-config.xml index bbe7bebeae..17f57bc685 100644 --- a/introspection/nm-ip4-config.xml +++ b/introspection/nm-ip4-config.xml @@ -94,6 +94,8 @@ diff --git a/introspection/nm-ip6-config.xml b/introspection/nm-ip6-config.xml index a58bfffa55..e5cab7132d 100644 --- a/introspection/nm-ip6-config.xml +++ b/introspection/nm-ip6-config.xml @@ -86,6 +86,8 @@ diff --git a/introspection/nm-manager.xml b/introspection/nm-manager.xml index beff406b8e..cf178c3951 100644 --- a/introspection/nm-manager.xml +++ b/introspection/nm-manager.xml @@ -426,7 +426,7 @@ PropertiesChanged: @properties: The changed properties. - NetworkManager's properties changed. + DEPRECATED. Use the standard "PropertiesChanged" signal from "org.freedesktop.DBus.Properties" instead which exists since version NetworkManager 1.2.0. --> diff --git a/introspection/nm-settings-connection.xml b/introspection/nm-settings-connection.xml index 15b380348c..cf33120ce8 100644 --- a/introspection/nm-settings-connection.xml +++ b/introspection/nm-settings-connection.xml @@ -123,6 +123,8 @@ diff --git a/introspection/nm-settings.xml b/introspection/nm-settings.xml index 7f5b546c58..32675e02d8 100644 --- a/introspection/nm-settings.xml +++ b/introspection/nm-settings.xml @@ -131,6 +131,8 @@ diff --git a/introspection/nm-vpn-connection.xml b/introspection/nm-vpn-connection.xml index 430998f3d1..897cea0b0a 100644 --- a/introspection/nm-vpn-connection.xml +++ b/introspection/nm-vpn-connection.xml @@ -12,6 +12,8 @@ diff --git a/introspection/nm-wimax-nsp.xml b/introspection/nm-wimax-nsp.xml index 8b9a2fcc9f..a766927943 100644 --- a/introspection/nm-wimax-nsp.xml +++ b/introspection/nm-wimax-nsp.xml @@ -28,6 +28,8 @@ diff --git a/src/nm-exported-object.c b/src/nm-exported-object.c index d99a9ceeb6..32b5ec05dd 100644 --- a/src/nm-exported-object.c +++ b/src/nm-exported-object.c @@ -27,6 +27,10 @@ #include "nm-bus-manager.h" +#include "nm-device.h" +#include "nm-active-connection.h" +#include "nmdbus-device-statistics.h" + #if NM_MORE_ASSERTS >= 2 #define _ASSERT_NO_EARLY_EXPORT #endif @@ -72,11 +76,20 @@ G_DEFINE_QUARK (NMExportedObjectClassInfo, nm_exported_object_class_info) #define _NMLOG_DOMAIN LOGD_CORE #define _NMLOG(level, ...) \ - nm_log (level, _NMLOG_DOMAIN, \ + nm_log ((level), _NMLOG_DOMAIN, \ "%s[%p]: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ _NMLOG_PREFIX_NAME, (self) \ _NM_UTILS_MACRO_REST (__VA_ARGS__)) +#define _NMLOG2_PREFIX_NAME "properties-changed" +#define _NMLOG2_DOMAIN LOGD_DBUS_PROPS + +#define _NMLOG2(level, ...) \ + nm_log ((level), _NMLOG2_DOMAIN, \ + "%s[%p]: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + _NMLOG2_PREFIX_NAME, (self) \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)) + /*****************************************************************************/ /* "AddConnectionUnsaved" -> "handle-add-connection-unsaved" */ @@ -267,8 +280,8 @@ nm_exported_object_class_add_interface (NMExportedObjectClass *object_class, nm_exported_object_class_info_quark (), classinfo); } - classinfo->skeleton_types = g_slist_append (classinfo->skeleton_types, - GSIZE_TO_POINTER (dbus_skeleton_type)); + classinfo->skeleton_types = g_slist_prepend (classinfo->skeleton_types, + GSIZE_TO_POINTER (dbus_skeleton_type)); /* Ensure @dbus_skeleton_type's class_init has run, so its signals/properties * will be defined. @@ -499,6 +512,9 @@ nm_exported_object_create_skeletons (NMExportedObject *self, } nm_assert (i == 0); + /* The list of interfaces priv->interfaces is to be sorted from parent-class to derived-class. + * On the other hand, if one class defines multiple interfaces, the interfaces are sorted in + * the order of calls to nm_exported_object_class_add_interface(). */ if (priv->num_interfaces > 0) { memcpy (&interfaces[num_interfaces], priv->interfaces, sizeof (InterfaceData) * priv->num_interfaces); g_slice_free1 (sizeof (InterfaceData) * priv->num_interfaces, priv->interfaces); @@ -801,12 +817,11 @@ idle_emit_properties_changed (gpointer self) if (n == 0) continue; - if (!ifdata->property_changed_signal_id) - goto next; + nm_assert (ifdata->property_changed_signal_id); /* We use here alloca in a loop, something that is usually avoided. * But the number of interfaces "priv->num_interfaces" is small (determined by - * the depth of the type inheritence) and the number of possible pending_notifies + * the depth of the type inheritance) and the number of possible pending_notifies * "n" is small (determined by the number of GObject properties). */ values = g_alloca (sizeof (values[0]) * n); @@ -824,17 +839,16 @@ idle_emit_properties_changed (gpointer self) variant = g_variant_ref_sink (g_variant_builder_end (¬ifies)); - if (nm_logging_enabled (LOGL_DEBUG, LOGD_DBUS_PROPS)) { + if (_LOG2D_ENABLED ()) { gs_free char *notification = g_variant_print (variant, TRUE); - nm_log_dbg (LOGD_DBUS_PROPS, "properties-changed[%p]: type %s, iface %s: %s", - self, G_OBJECT_TYPE_NAME (self), G_OBJECT_TYPE_NAME (ifdata->interface), - notification); + _LOG2D ("type %s, iface %s: %s", + G_OBJECT_TYPE_NAME (self), G_OBJECT_TYPE_NAME (ifdata->interface), + notification); } g_signal_emit (ifdata->interface, ifdata->property_changed_signal_id, 0, variant); -next: g_hash_table_remove_all (ifdata->pending_notifies); } @@ -844,19 +858,25 @@ next: static void nm_exported_object_notify (GObject *object, GParamSpec *pspec) { - NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (object); + NMExportedObject *self = (NMExportedObject *) object; + NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (self); NMExportedObjectClassInfo *classinfo; GType type; const char *dbus_property_name = NULL; GValue value = G_VALUE_INIT; + GVariant *value_variant; InterfaceData *ifdata = NULL; const GVariantType *vtype; guint i, j; + /* Hook to emit deprecated "PropertiesChanged" signal on NetworkManager interfaces. + * This is to preserve deprecated D-Bus API, nowadays we use instead + * the "PropertiesChanged" signal of "org.freedesktop.DBus.Properties". */ + if (priv->num_interfaces == 0) return; - for (type = G_OBJECT_TYPE (object); type; type = g_type_parent (type)) { + for (type = G_OBJECT_TYPE (self); type; type = g_type_parent (type)) { classinfo = g_type_get_qdata (type, nm_exported_object_class_info_quark ()); if (!classinfo) continue; @@ -866,8 +886,8 @@ nm_exported_object_notify (GObject *object, GParamSpec *pspec) break; } if (!dbus_property_name) { - nm_log_trace (LOGD_DBUS_PROPS, "properties-changed[%p]: ignoring notification for prop %s on type %s", - object, pspec->name, G_OBJECT_TYPE_NAME (object)); + _LOG2T ("ignoring notification for prop %s on type %s", + pspec->name, G_OBJECT_TYPE_NAME (self)); return; } @@ -887,17 +907,61 @@ nm_exported_object_notify (GObject *object, GParamSpec *pspec) vtype_found: g_value_init (&value, pspec->value_type); - g_object_get_property (G_OBJECT (object), pspec->name, &value); - - /* @dbus_property_name is inside classinfo and never freed, thus we don't clone it. - * Also, we do a pointer, not string comparison. */ - g_hash_table_insert (ifdata->pending_notifies, - (gpointer) dbus_property_name, - g_dbus_gvalue_to_gvariant (&value, vtype)); + g_object_get_property ((GObject *) self, pspec->name, &value); + value_variant = g_dbus_gvalue_to_gvariant (&value, vtype); g_value_unset (&value); + if ( ( NM_IS_DEVICE (self) + && !NMDBUS_IS_DEVICE_STATISTICS_SKELETON (ifdata->interface)) + || NM_IS_ACTIVE_CONNECTION (self)) { + /* This PropertiesChanged signal is nodaways deprecated in favor + * of "org.freedesktop.DBus.Properties"'s PropertiesChanged signal. + * This function solely exists to raise the NM version of PropertiesChanged. + * + * With types exported on D-Bus that are implemented as derived + * types in glib (NMDevice and NMActiveConnection), multiple types + * in the inheritance tree define a "PropertiesChanged" signal. + * + * In 1.0.0 and earlier, the signal was emitted once for every interface + * that had a "PropertiesChanged" signal. For example: + * - NMDeviceEthernet.HwAddress was emitted on "fdo.NM.Device.Ethernet" + * and "fdo.NM.Device.Veth" (if the device was of type NMDeviceVeth). + * - NMVpnConnection.VpnState was emitted on "fdo.NM.Connecion.Active" + * and "fdo.NM.VPN.Connection". + * + * NMDevice is special in that it didn't have a "PropertiesChanged" signal. + * Thus, a change to "NMDevice.StateReason" would be emitted on "fdo.NM.Device.Ethernet" + * and also on "fdo.NM.Device.Veth" (in case of a device of type NMDeviceVeth). + * + * The releases of 1.2.0 and 1.4.0 failed to realize above and broke this behavior. + * This special handling here is to bring back the 1.0.0 behavior. + * + * The Device.Statistics signal is special, because it was only added with 1.4.0 + * and didn't have above behavior. So let's save the overhead of emitting multiple + * deprecated signals for wrong interfaces. */ + for (i = 0, j = 0; i < priv->num_interfaces; i++) { + ifdata = &priv->interfaces[i]; + if ( ifdata->property_changed_signal_id + && !NMDBUS_IS_DEVICE_STATISTICS_SKELETON (ifdata->interface)) { + j++; + g_hash_table_insert (ifdata->pending_notifies, + (gpointer) dbus_property_name, + g_variant_ref (value_variant)); + } + } + nm_assert (j > 0); + g_variant_unref (value_variant); + } else if (ifdata->property_changed_signal_id) { + /* @dbus_property_name is inside classinfo and never freed, thus we don't clone it. + * Also, we do a pointer, not string comparison. */ + g_hash_table_insert (ifdata->pending_notifies, + (gpointer) dbus_property_name, + value_variant); + } else + nm_assert_not_reached (); + if (!priv->notify_idle_id) - priv->notify_idle_id = g_idle_add (idle_emit_properties_changed, object); + priv->notify_idle_id = g_idle_add (idle_emit_properties_changed, self); } /*****************************************************************************/ diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index 49672cf565..de035f1a94 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -534,6 +534,8 @@ gboolean nm_config_get_configure_and_quit (gpointer unused); gconstpointer nm_bus_manager_get (void); void nm_bus_manager_register_object (gpointer unused, gpointer object); void nm_bus_manager_unregister_object (gpointer unused, gpointer object); +GType nm_device_get_type (void); +GType nm_active_connection_get_type (void); gconstpointer nm_config_get (void) @@ -569,3 +571,15 @@ nm_bus_manager_unregister_object (gpointer unused, gpointer object) { } +GType +nm_device_get_type (void) +{ + g_return_val_if_reached (0); +} + +GType +nm_active_connection_get_type (void) +{ + g_return_val_if_reached (0); +} +