summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-07-05 12:54:45 +0200
committerThomas Haller <thaller@redhat.com>2016-07-05 23:08:23 +0200
commitc36fd264776f6b18b38302ce4f046c2b02222749 (patch)
treecd824f5fe0609fad7a0c3d0294c65e45abf2e63f
parent841dcdf6e9ba336d67101b0cd776c6889a4394e5 (diff)
downloadNetworkManager-c36fd264776f6b18b38302ce4f046c2b02222749.tar.gz
ethernet: refactor construction of NMDeviceEthernat and void warning to update s390 subchannels
We should overwrite the constructed() method instead of hooking the GObject creation via constructed(). That is much cleaner as at that point the GObject is fully initialized. Also, this avoids a pointless warning when trying to get the not yet initialized GUdevDevice: <debug> [1467714778.0958] platform: signal: link added: 15: eth0 <DOWN;broadcast,multicast> mtu 1500 arp 1 ethernet? not-init addrgenmode eui64 addr AA:BB:CC:DD:EE:FF driver e1000e <warn> [1467714778.0961] device (eth0): failed to find device 15 'eth0' with udev <debug> [1467714778.0962] device[0x562eac10ee50] (eth0): constructed (NMDeviceEthernet) ... <debug> [1467714778.1334] platform: signal: link changed: 15: enp0s25 <DOWN;broadcast,multicast> mtu 1500 arp 1 ethernet? init addrgenmode eui64 addr AA:BB:CC:DD:EE:FF driver e1000e
-rw-r--r--src/devices/nm-device-ethernet.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 2fc9c548de..8c970e8374 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -157,10 +157,9 @@ _update_s390_subchannels (NMDeviceEthernet *self)
ifindex = nm_device_get_ifindex ((NMDevice *) self);
dev = (GUdevDevice *) nm_g_object_ref (nm_platform_link_get_udev_device (NM_PLATFORM_GET, ifindex));
if (!dev) {
- _LOGW (LOGD_DEVICE | LOGD_HW, "update-s390: failed to find device %s (%d) with udev",
- nm_strquote_a (20, nm_device_get_iface ((NMDevice *) self)),
- ifindex);
- return;
+ /* we only call _update_s390_subchannels() when platform claims the device to be initialized.
+ * Thus, we expect to successfully lookup a GUdevDevice. */
+ g_return_if_reached ();
}
/* Try for the "ccwgroup" parent */
@@ -240,27 +239,16 @@ _update_s390_subchannels (NMDeviceEthernet *self)
driver ? driver : "(unknown driver)", priv->subchannels);
}
-static GObject*
-constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
+static void
+constructed (GObject *object)
{
- GObject *object;
-
- object = G_OBJECT_CLASS (nm_device_ethernet_parent_class)->constructor (type,
- n_construct_params,
- construct_params);
- if (!object)
- return NULL;
+ const NMPlatformLink *pllink;
- nm_assert (NM_IN_SET (nm_platform_link_get_type (NM_PLATFORM_GET,
- nm_device_get_ifindex ((NMDevice *) object)),
- NM_LINK_TYPE_NONE,
- NM_LINK_TYPE_ETHERNET,
- NM_LINK_TYPE_VETH));
+ G_OBJECT_CLASS (nm_device_ethernet_parent_class)->constructed (object);
- _update_s390_subchannels ((NMDeviceEthernet *) object);
- return object;
+ pllink = nm_platform_link_get (NM_PLATFORM_GET, nm_device_get_ifindex ((NMDevice *) object));
+ if (pllink && pllink->initialized)
+ _update_s390_subchannels ((NMDeviceEthernet *) object);
}
static void
@@ -1646,7 +1634,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_WIRED_SETTING_NAME, NM_LINK_TYPE_ETHERNET)
/* virtual methods */
- object_class->constructor = constructor;
+ object_class->constructed = constructed;
object_class->dispose = dispose;
object_class->finalize = finalize;
object_class->get_property = get_property;