plugin: network interface force ignore rules for certain drivers only

The rules to force ignoring certain network ports because the modem is
using some specific drivers should definitely only be applied for the
very known qmi_wwan and cdc_mbim drivers.

If network ports for QMI or MBIM modems are exposed using different
network drivers, don't ignore them.
This commit is contained in:
Aleksander Morgado
2020-10-22 11:09:00 +02:00
parent 5aa7632e88
commit ca0dbd0728

View File

@@ -889,22 +889,25 @@ mm_plugin_discard_port_early (MMPlugin *self,
MMBaseModem * MMBaseModem *
mm_plugin_create_modem (MMPlugin *self, mm_plugin_create_modem (MMPlugin *self,
MMDevice *device, MMDevice *device,
GError **error) GError **error)
{ {
MMBaseModem *modem; MMBaseModem *modem;
GList *port_probes = NULL; GList *port_probes = NULL;
const gchar **virtual_ports = NULL; const gchar **virtual_ports = NULL;
const gchar **drivers;
if (!mm_device_is_virtual (device)) if (!mm_device_is_virtual (device))
port_probes = mm_device_peek_port_probe_list (device); port_probes = mm_device_peek_port_probe_list (device);
else else
virtual_ports = mm_device_virtual_peek_ports (device); virtual_ports = mm_device_virtual_peek_ports (device);
drivers = mm_device_get_drivers (device);
/* Let the plugin create the modem from the port probe results */ /* Let the plugin create the modem from the port probe results */
modem = MM_PLUGIN_GET_CLASS (self)->create_modem (MM_PLUGIN (self), modem = MM_PLUGIN_GET_CLASS (self)->create_modem (MM_PLUGIN (self),
mm_device_get_uid (device), mm_device_get_uid (device),
mm_device_get_drivers (device), drivers,
mm_device_get_vendor (device), mm_device_get_vendor (device),
mm_device_get_product (device), mm_device_get_product (device),
port_probes, port_probes,
@@ -957,60 +960,66 @@ mm_plugin_create_modem (MMPlugin *self,
goto grab_port; goto grab_port;
} }
/* Force network ignore rules for devices that use qmi_wwan */
if (drivers && g_strv_contains (drivers, "qmi_wwan")) {
#if defined WITH_QMI #if defined WITH_QMI
if (MM_IS_BROADBAND_MODEM_QMI (modem) && if (MM_IS_BROADBAND_MODEM_QMI (modem) &&
port_type == MM_PORT_TYPE_NET && port_type == MM_PORT_TYPE_NET &&
g_strcmp0 (driver, "qmi_wwan") != 0) { g_strcmp0 (driver, "qmi_wwan") != 0) {
/* Non-QMI net ports are ignored in QMI modems */ /* Non-QMI net ports are ignored in QMI modems */
mm_obj_dbg (self, "ignoring non-QMI net port %s in QMI modem", name); mm_obj_dbg (self, "ignoring non-QMI net port %s in QMI modem", name);
force_ignored = TRUE; force_ignored = TRUE;
goto grab_port; goto grab_port;
} }
if (!MM_IS_BROADBAND_MODEM_QMI (modem) && if (!MM_IS_BROADBAND_MODEM_QMI (modem) &&
port_type == MM_PORT_TYPE_NET && port_type == MM_PORT_TYPE_NET &&
g_strcmp0 (driver, "qmi_wwan") == 0) { g_strcmp0 (driver, "qmi_wwan") == 0) {
/* QMI net ports are ignored in non-QMI modems */ /* QMI net ports are ignored in non-QMI modems */
mm_obj_dbg (self, "ignoring QMI net port %s in non-QMI modem", name); mm_obj_dbg (self, "ignoring QMI net port %s in non-QMI modem", name);
force_ignored = TRUE; force_ignored = TRUE;
goto grab_port; goto grab_port;
} }
#else #else
if (port_type == MM_PORT_TYPE_NET && if (port_type == MM_PORT_TYPE_NET &&
g_strcmp0 (driver, "qmi_wwan") == 0) { g_strcmp0 (driver, "qmi_wwan") == 0) {
/* QMI net ports are ignored if QMI support not built */ /* QMI net ports are ignored if QMI support not built */
mm_obj_dbg (self, "ignoring QMI net port %s as QMI support isn't available", name); mm_obj_dbg (self, "ignoring QMI net port %s as QMI support isn't available", name);
force_ignored = TRUE; force_ignored = TRUE;
goto grab_port; goto grab_port;
} }
#endif #endif
}
/* Force network ignore rules for devices that use cdc_mbim */
if (drivers && g_strv_contains (drivers, "cdc_mbim")) {
#if defined WITH_MBIM #if defined WITH_MBIM
if (MM_IS_BROADBAND_MODEM_MBIM (modem) && if (MM_IS_BROADBAND_MODEM_MBIM (modem) &&
port_type == MM_PORT_TYPE_NET && port_type == MM_PORT_TYPE_NET &&
g_strcmp0 (driver, "cdc_mbim") != 0) { g_strcmp0 (driver, "cdc_mbim") != 0) {
/* Non-MBIM net ports are ignored in MBIM modems */ /* Non-MBIM net ports are ignored in MBIM modems */
mm_obj_dbg (self, "ignoring non-MBIM net port %s in MBIM modem", name); mm_obj_dbg (self, "ignoring non-MBIM net port %s in MBIM modem", name);
force_ignored = TRUE; force_ignored = TRUE;
goto grab_port; goto grab_port;
} }
if (!MM_IS_BROADBAND_MODEM_MBIM (modem) && if (!MM_IS_BROADBAND_MODEM_MBIM (modem) &&
port_type == MM_PORT_TYPE_NET && port_type == MM_PORT_TYPE_NET &&
g_strcmp0 (driver, "cdc_mbim") == 0) { g_strcmp0 (driver, "cdc_mbim") == 0) {
/* MBIM net ports are ignored in non-MBIM modems */ /* MBIM net ports are ignored in non-MBIM modems */
mm_obj_dbg (self, "ignoring MBIM net port %s in non-MBIM modem", name); mm_obj_dbg (self, "ignoring MBIM net port %s in non-MBIM modem", name);
force_ignored = TRUE; force_ignored = TRUE;
goto grab_port; goto grab_port;
} }
#else #else
if (port_type == MM_PORT_TYPE_NET && if (port_type == MM_PORT_TYPE_NET &&
g_strcmp0 (driver, "cdc_mbim") == 0) { g_strcmp0 (driver, "cdc_mbim") == 0) {
mm_obj_dbg (self, "ignoring MBIM net port %s as MBIM support isn't available", name); mm_obj_dbg (self, "ignoring MBIM net port %s as MBIM support isn't available", name);
force_ignored = TRUE; force_ignored = TRUE;
goto grab_port; goto grab_port;
} }
#endif #endif
}
grab_port: grab_port:
if (force_ignored) if (force_ignored)