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.
This commit is contained in:
Beniamino Galvani
2017-01-19 09:56:15 +01:00
parent 6c96aafaa9
commit 4215c2640a

View File

@@ -495,31 +495,39 @@ static void
get_property (GObject *object, guint prop_id, get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec) GValue *value, GParamSpec *pspec)
{ {
NMActiveConnection *active;
NMDevice *device; NMDevice *device;
char *name;
device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object)); switch (prop_id) {
if (!device) { case PROP_IP4_CONFIG:
name = NM_DEVICE_IP4_CONFIG;
break;
case PROP_DHCP4_CONFIG:
name = NM_DEVICE_DHCP4_CONFIG;
break;
case PROP_IP6_CONFIG:
name = NM_DEVICE_IP6_CONFIG;
break;
case PROP_DHCP6_CONFIG:
name = NM_DEVICE_DHCP6_CONFIG;
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
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, "/"); g_value_set_string (value, "/");
return; return;
} }
switch (prop_id) { g_object_get_property (G_OBJECT (device), name, value);
case PROP_IP4_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_IP4_CONFIG, value);
break;
case PROP_DHCP4_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP4_CONFIG, value);
break;
case PROP_IP6_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_IP6_CONFIG, value);
break;
case PROP_DHCP6_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP6_CONFIG, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
} }
static void static void