From 84f9c9489bd4f2cfae6ebc5f0ac2cb5cfe7919e0 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 6 Dec 2018 10:52:16 +0100 Subject: [PATCH] device: avoid platform assertion failure Avoid the following: nmp_cache_lookup_entry_link: assertion 'ifindex > 0' failed --- src/devices/nm-device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 6af0cf8889..a6c2ea03e5 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -3465,11 +3465,14 @@ nm_device_set_carrier (NMDevice *self, gboolean carrier) static void nm_device_set_carrier_from_platform (NMDevice *self) { + int ifindex; + if (nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) { - if (!nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER)) { + if ( !nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER) + && (ifindex = nm_device_get_ip_ifindex (self)) > 0) { nm_device_set_carrier (self, nm_platform_link_is_connected (nm_device_get_platform (self), - nm_device_get_ip_ifindex (self))); + ifindex)); } } else { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);