summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2015-12-08 14:51:04 +0100
committerLubomir Rintel <lkundrak@v3.sk>2015-12-08 18:11:53 +0100
commit7dbf821cb2982672dc5bc1e0088f6a113ed81f87 (patch)
treee73a3acedbc585b8911d04bd35db574a8f367314
parent6db04dc20664479fc71f102a536dbf2f4501c5a2 (diff)
downloadNetworkManager-7dbf821cb2982672dc5bc1e0088f6a113ed81f87.tar.gz
device: precisely match the link type to the platform device
The unrealized device's factory could be using one particular link type, don't allow matching the device to a non-matching one.
-rw-r--r--src/devices/nm-device.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index e08cb896c6..3a4e7cc946 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1656,9 +1656,14 @@ link_type_compatible (NMDevice *self,
gboolean *out_compatible,
GError **error)
{
- NMDeviceClass *klass = NM_DEVICE_GET_CLASS (self);
+ NMDeviceClass *klass;
+ NMLinkType device_type;
guint i = 0;
+ g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
+
+ klass = NM_DEVICE_GET_CLASS (self);
+
if (!klass->link_types) {
NM_SET_OUT (out_compatible, FALSE);
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
@@ -1666,6 +1671,14 @@ link_type_compatible (NMDevice *self,
return FALSE;
}
+ device_type = self->priv->link_type;
+ if (device_type > NM_LINK_TYPE_UNKNOWN && device_type != link_type) {
+ g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
+ "Needed link type 0x%x does not match the platform link type 0x%X",
+ device_type, link_type);
+ return FALSE;
+ }
+
for (i = 0; klass->link_types[i] > NM_LINK_TYPE_UNKNOWN; i++) {
if (klass->link_types[i] == link_type)
return TRUE;