summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-12-09 10:29:15 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2015-12-09 11:09:48 +0100
commit158c63eb2cd0eaee977f2a535f6e6b74a3abff2e (patch)
treea25101f7ddca3d52a62525a22be2f4b4e2179e10
parent3e5fea9820bfab30799f5205bd5746efb95797fe (diff)
downloadNetworkManager-158c63eb2cd0eaee977f2a535f6e6b74a3abff2e.tar.gz
device: move initialization of ifindex to constructor()
Device subclasses (for example NMDeviceWifi) can use the ifindex in their constructor(), but the value now is set later in parent class constructed(). This causes the following: nm_platform_wifi_get_capabilities: assertion 'ifindex > 0' failed Fix this by initializing ifindex earlier in NMDevice's constructor(). While at it, remove the nm_assert (pllink->type != NM_LINK_TYPE_NONE); assertion, since pllink can be NULL there. Fixes: 6db04dc20664479fc71f102a536dbf2f4501c5a2
-rw-r--r--src/devices/nm-device.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 3a4e7cc946..21f5a194a9 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -10081,20 +10081,27 @@ nm_device_init (NMDevice *self)
priv->v6_commit_first_time = TRUE;
}
-static void
-constructed (GObject *object)
-{
- NMDevice *self = NM_DEVICE (object);
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
- NMPlatform *platform;
+static GObject*
+constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
+{
+ GObject *object;
+ GObjectClass *klass;
+ NMDevice *self;
+ NMDevicePrivate *priv;
const NMPlatformLink *pllink;
- platform = nm_platform_get ();
+ klass = G_OBJECT_CLASS (nm_device_parent_class);
+ object = klass->constructor (type, n_construct_params, construct_params);
+ if (!object)
+ return NULL;
- if (priv->iface) {
- pllink = nm_platform_link_get_by_ifname (platform, priv->iface);
+ self = NM_DEVICE (object);
+ priv = NM_DEVICE_GET_PRIVATE (self);
- nm_assert (pllink->type != NM_LINK_TYPE_NONE);
+ if (priv->iface) {
+ pllink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, priv->iface);
if (pllink && link_type_compatible (self, pllink->type, NULL, NULL)) {
priv->ifindex = pllink->ifindex;
@@ -10102,6 +10109,18 @@ constructed (GObject *object)
}
}
+ return object;
+}
+
+static void
+constructed (GObject *object)
+{
+ NMDevice *self = NM_DEVICE (object);
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ NMPlatform *platform;
+
+ platform = nm_platform_get ();
+
if (NM_DEVICE_GET_CLASS (self)->get_generic_capabilities)
priv->capabilities |= NM_DEVICE_GET_CLASS (self)->get_generic_capabilities (self);
@@ -10524,6 +10543,7 @@ nm_device_class_init (NMDeviceClass *klass)
object_class->finalize = finalize;
object_class->set_property = set_property;
object_class->get_property = get_property;
+ object_class->constructor = constructor;
object_class->constructed = constructed;
klass->link_changed = link_changed;