Commit 7dbf821c authored by Lubomir Rintel's avatar Lubomir Rintel 🥕

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.
parent 6db04dc2
......@@ -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) {
"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;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment