diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-01-19 09:56:15 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-01-19 11:41:16 +0100 |
commit | 4215c2640a6a24360fc0bfc59f45c6af3132ebb4 (patch) | |
tree | c63a9eba39d1c41becf8850a472ac64a8056ccfe | |
parent | 6c96aafaa9a61ca4fe713551a4cd4b15fb7e8a63 (diff) | |
download | NetworkManager-4215c2640a6a24360fc0bfc59f45c6af3132ebb4.tar.gz |
act-request: return empty properties when not activated
We start to track changes to the device's properties only after the
active connection gets activated. It's wrong to return properties
while we don't track their changes as this causes stale objects
references on D-Bus. Let's return DHCP and IP configurations from the
device only when the connection is activated.
-rw-r--r-- | src/nm-act-request.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/nm-act-request.c b/src/nm-act-request.c index 3a04667b3c..0396489683 100644 --- a/src/nm-act-request.c +++ b/src/nm-act-request.c @@ -495,31 +495,39 @@ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { + NMActiveConnection *active; NMDevice *device; - - device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object)); - if (!device) { - g_value_set_string (value, "/"); - return; - } + char *name; switch (prop_id) { case PROP_IP4_CONFIG: - g_object_get_property (G_OBJECT (device), NM_DEVICE_IP4_CONFIG, value); + name = NM_DEVICE_IP4_CONFIG; break; case PROP_DHCP4_CONFIG: - g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP4_CONFIG, value); + name = NM_DEVICE_DHCP4_CONFIG; break; case PROP_IP6_CONFIG: - g_object_get_property (G_OBJECT (device), NM_DEVICE_IP6_CONFIG, value); + name = NM_DEVICE_IP6_CONFIG; break; case PROP_DHCP6_CONFIG: - g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP6_CONFIG, value); + name = NM_DEVICE_DHCP6_CONFIG; break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + return; } + + active = NM_ACTIVE_CONNECTION (object); + device = nm_active_connection_get_device (active); + if ( !device + || !NM_IN_SET (nm_active_connection_get_state (active), + NM_ACTIVE_CONNECTION_STATE_ACTIVATED, + NM_ACTIVE_CONNECTION_STATE_DEACTIVATING)) { + g_value_set_string (value, "/"); + return; + } + + g_object_get_property (G_OBJECT (device), name, value); } static void |