Commit Graph
2930 Commits
Author SHA1 Message Date
Aleksander Morgado 0850fe4f6d filter: additional strict rules when all device ports available
All the previous filter rules were applicable per-port independently.
But, we also want to apply rules on a port based on the existence of
other ports on the same device (e.g. allow TTY if the device also has
a NET port). In this case, we need to wait for all ports to appear and
then apply the additional rules.

We re-use the "min wait time" timeout in the plugin-manager for this
same purpose. This timeout is setup to wait for ports to appear before
starting the probing process (e.g. so that plugin filters like the
forbidden-drivers one work). The very same timeout can therefore be
used to check whether we start the probing or not based on additional
filter rules.
2017-12-05 10:58:29 +01:00
Aleksander Morgado ee570d44dc filter: new automatic whitelisting rules and strict/paranoid policies
The 'default' filter policy was based on blacklisting as much as
possible and otherwise allow.

The new 'strict' filter policy will be based on whitelisting as much
as much as possible, using custom defined rules, and otherwise forbid
the ports.

The new 'paranoid' filter policy is equivalent to the 'strict' filter
after having applied the blacklist rules from the 'default' filter.
2017-12-05 10:58:29 +01:00
Aleksander Morgado 33583ca4de kerneldevice: allow getting interface class/subclass/protocol 2017-12-05 10:58:29 +01:00
Aleksander Morgado 5b3baa02d3 filter: explicitly allow port when ID_MM_PLATFORM_DRIVER_PROBE is set
Don't assume that the port will be implicitly allowed afterwards.
2017-12-05 10:58:29 +01:00
Aleksander Morgado c4bf785d67 filter: allow selection of filter policy on startup
Added a new '--filter-policy=[POLICY]' option in the daemon, which
allows selecting between the supported filter policies. For now, only
two policies are defined:

  * default: the default policy used by ModemManager, where it tries
    to probe and detect as many modem ports as possible.

  * whitelist-only: only devices explicitly tagged via udev (with the
    ID_MM_DEVICE_PROCESS tag) will be probed and used.
2017-12-05 10:58:29 +01:00
Aleksander Morgado 7bfd5270ef filter: let the user tag modems explicitly
The user can tag modems (either full devices or ports independently)
to be explicitly probed by ModemManager, using the new
"ID_MM_DEVICE_PROCESS" udev tag, e.g.:

    $ sudo vim /lib/udev/rules.d/78-mm-whitelist-internal-modem.rules
        ACTION!="add|change|move", GOTO="mm_whitelist_internal_modem_end"
        ATTRS{idVendor}=="1199", ATTRS{idProduct}=="a001", ENV{ID_MM_DEVICE_PROCESS}="1"
        LABEL="mm_whitelist_internal_modem_end"
    $ sudo udevadm control --reload
    $ sudo udevadm trigger

This rule runs before any other filter rule.

This tag may be used e.g. by manufacturers building systems with
built-in modems that will always be available.

Distributions targeting support for multiple modem devices shouldn't
use this udev tag.
2017-12-05 10:58:29 +01:00
Aleksander Morgado f270a09cb2 filter: allow enabling/disabling rules via envvars
E.g. forcing a MBIM modem to run in AT-only mode:

  # MM_FILTER_RULE_NET=0     \
    MM_FILTER_RULE_CDC_WDM=0 \
    /usr/sbin/ModemManager --debug

This is just for quick testing for now.
2017-12-05 10:58:29 +01:00
Aleksander Morgado 239f7ba8a2 filter: remove bogus TTY virtual console filter
The more generic filter for virtual devices already covers all cases
covered by the TTY virtual console filter.
2017-12-05 10:58:28 +01:00
Aleksander Morgado 4e26661e67 filter: new object to run the port/device filter logic
This new object allows configuring the filter rules applied to the
device ports. By default, for now, it implements the same rules as the
MMKernelDevice is_candidate() method, which is obsoleted.
2017-12-05 10:58:28 +01:00
Aleksander Morgado d04f98d966 kerneldevice: consolidate candidate rules in the base device
This patch implicitly enables in the generic device backend the
manual-only greylist (ID_MM_DEVICE_MANUAL_SCAN_ONLY tag) and the
platform TTY whitelist (ID_MM_PLATFORM_DRIVER_PROBE), which were not
being applied.
2017-12-05 10:58:28 +01:00
Aleksander Morgado 345d9747a7 kerneldevice: allow loading physdev sysfs path 2017-12-05 10:58:28 +01:00
Aleksander Morgado 0e4e4a6b13 kerneldevice: allow loading physdev subsystem
Used to filter out TTYs when not explicitly whitelisted.
2017-12-05 10:58:28 +01:00
Aleksander Morgado 7119b8ebb2 bearer-qmi: new optional connection status monitoring
This update makes it possible to request connection status polling for
QMI modems via the ID_MM_QMI_CONNECTION_STATUS_POLLING_ENABLE tag.

If not given, the connection status polling will be disabled by
default, and the QMI modem will rely on WDS indications only.
2017-11-23 14:20:39 +01:00
Aleksander Morgado d20d46a629 iface-modem: remove invalid modem reference count in update_lock_info()
The modem object is being explicitly referenced and stored in the
Context, but then never unref-ed, completely leaking a modem reference
forever.

Fixes: 4df5458847
2017-11-23 14:20:38 +01:00
Aleksander Morgado de334b7777 broadband-modem-qmi: plug memleak when listing stored images
==24602== 288 bytes in 4 blocks are definitely lost in loss record 4,693 of 4,860
==24602==    at 0x4C2CE5F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24602==    by 0x67292F9: g_malloc (in /usr/lib/libglib-2.0.so.0.5400.0)
==24602==    by 0x670A706: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.5400.0)
==24602==    by 0x670B849: g_slice_alloc0 (in /usr/lib/libglib-2.0.so.0.5400.0)
==24602==    by 0x53D3A24: __qmi_message_dms_get_stored_image_info_response_parse (qmi-dms.c:22779)
==24602==    by 0x53E5C61: get_stored_image_info_ready (qmi-dms.c:32287)
==24602==    by 0x6134908: g_simple_async_result_complete (in /usr/lib/libgio-2.0.so.0.5400.0)
==24602==    by 0x613499E: ??? (in /usr/lib/libgio-2.0.so.0.5400.0)
==24602==    by 0x67180BD: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.5400.0)
==24602==    by 0x6719F68: ??? (in /usr/lib/libglib-2.0.so.0.5400.0)
==24602==    by 0x671AF41: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.5400.0)
==24602==    by 0x14477B: main (main.c:180)
2017-11-23 13:02:42 +01:00
Luis A. Lozano 71f0fc6821 sms-cdma-part: fix tautological-constant-compare compiler warning
This patch fixes the following compiler warning issued by clang:

  mm-sms-part-cdma.c:301:46: mcomparison 'guint8' (aka 'unsigned char') <= 255 is always true
  [-Werror,-Wtautological-constant-compare]
2017-10-26 09:29:20 +02:00
Eric Caruso 098c4c0271 mm-broadband-modem-qmi: reprobe on qmi-proxy death
This allows us to reprobe the modem and respawn the
qmi-proxy in case it dies on us. This gets us access
to the modem and unsolicited notifications again. Do
this by connecting to the device-removed signal on
QmiDevice.

---
Rebased on top of git master by
Aleksander Morgado <aleksander@aleksander.es>
2017-10-22 11:53:32 +02:00
Aleksander Morgado adcce66dd7 broadband-modem-qmi: avoid NULL success return in firmware_load_current
Instead of assuming that NULL is a valid return, make sure we return
an error instead.

This also makes it sure that if the GTask gets cancelled, the result
we set is always a valid GObject, so that the g_object_unref passed as
GDestroyNotify can be safely called always. Not a big deal anyway, as
the GTask cannot be currently cancelled.
2017-10-20 17:56:36 +02:00
Aleksander Morgado dbb4597e33 broadband-modem-qmi: avoid NULL success return in firmware_load_list
Instead of assuming that NULL is a valid return, make sure we return
an error instead.
2017-10-20 17:56:36 +02:00
Aleksander Morgado 6044118b64 broadband-modem-qmi: make it explicit that the GTask is successful
When load_supported_storages() doesn't run the parent implementation,
the GTask is always successful. Make it explicit, in case the logic
changes in the future.
2017-10-20 17:56:29 +02:00
Ben Chan 4e3bf7524d broadband-modem-qmi: port modem_cdma_load_meid to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan f5270ac5ae broadband-modem-qmi: port modem_cdma_load_esn to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan 607dee3a95 broadband-modem-qmi: port modem_3gpp_load_operator_code to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan e365cf531c broadband-modem-qmi: port modem_3gpp_load_operator_name to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan 942a3565e2 broadband-modem-qmi: port modem_3gpp_load_imei to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan be1b3add84 broadband-modem-qmi: port modem_messaging_setup_sms_format to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan 9b27a8bd9a broadband-modem-qmi: port modem_load_supported_ip_families to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan 0b942a6759 broadband-modem-qmi: port modem_load_supported_ip_modes to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan bba2386238 broadband-modem-qmi: port modem_load_device_identifier to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan 55c3e162b1 broadband-modem-qmi: port modem_load_unlock_required to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan 2ba17be8b6 broadband-modem-qmi: port modem_create_bearer to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan 2aaac123ac broadband-modem-qmi: port messaging_load_supported_storages to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan bf9e5cdfeb broadband-modem-qmi: port messaging_check_support to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan 30dfe3055e broadband-modem-qmi: port signal_check_support to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan e9ee49d583 broadband-modem-qmi: port oma_check_support to use GTask 2017-10-20 17:20:24 +02:00
Ben Chan 3e91956d0c broadband-modem-qmi: port location_load_capabilities to use GTask 2017-10-20 17:20:23 +02:00
Ben Chan d99398b055 broadband-modem-qmi: port enable_location_gathering to use GTask 2017-10-20 17:20:23 +02:00
Ben Chan 07d922e250 broadband-modem-qmi: port firmware_load_list to use GTask 2017-10-20 17:20:23 +02:00
Ben Chan af2f87d2f2 broadband-modem-qmi: port firmware_load_current to use GTask 2017-10-20 17:20:23 +02:00
Ben Chan 02fadb6e91 broadband-modem-qmi: port enabling_started to use GTask 2017-10-20 17:20:23 +02:00
Ben Chan b412ddc8b9 broadband-modem-qmi: port initialization_started to use GTask 2017-10-20 17:20:23 +02:00
Aleksander Morgado 689dad9f6e base-bearer: fix reporting tx/rx stats
The numbers were actually swapped!
2017-10-19 11:43:50 +02:00
Aleksander Morgado fc40c059fa broadband-modem-mbim: plug memleak when querying previous unlock retries
==15673== 240 (40 direct, 200 indirect) bytes in 1 blocks are definitely lost in loss record 4,341 of 4,535
    ==15673==    at 0x647F014: g_type_create_instance (in /usr/lib/libgobject-2.0.so.0.5200.3)
    ==15673==    by 0x6460027: ??? (in /usr/lib/libgobject-2.0.so.0.5200.3)
    ==15673==    by 0x6461A54: g_object_newv (in /usr/lib/libgobject-2.0.so.0.5200.3)
    ==15673==    by 0x6462213: g_object_new (in /usr/lib/libgobject-2.0.so.0.5200.3)
    ==15673==    by 0x4E97C33: mm_unlock_retries_new (mm-unlock-retries.c:217)
    ==15673==    by 0x4E97A6F: mm_unlock_retries_new_from_dictionary (mm-unlock-retries.c:171)
    ==15673==    by 0x170B09: mm_iface_modem_get_unlock_retries (mm-iface-modem.c:2942)
    ==15673==    by 0x1DB0A4: pin_query_unlock_retries_ready (mm-broadband-modem-mbim.c:782)
    ==15673==    by 0x613AD52: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
    ==15673==    by 0x613B775: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
    ==15673==    by 0x57D525D: transaction_task_complete_and_free (mbim-device.c:246)
    ==15673==    by 0x57D6086: process_message (mbim-device.c:666)
2017-10-08 10:27:12 +02:00
Aleksander Morgado 58e6f652a1 base-modem: plug memleaks when building port lists
The mm_base_modem_find_ports() method builds a list of full
references, so we need to unref them in the peek() methods.

    ==10047== 14,959 (24 direct, 14,935 indirect) bytes in 1 blocks are definitely lost in loss record 5,470 of 5,473
    ==10047==    at 0x4C2CE5F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==10047==    by 0x66E3028: g_malloc (in /usr/lib/libglib-2.0.so.0.5200.3)
    ==10047==    by 0x66FAB25: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.5200.3)
    ==10047==    by 0x66D9A33: g_list_append (in /usr/lib/libglib-2.0.so.0.5200.3)
    ==10047==    by 0x15F6A7: mm_base_modem_find_ports (mm-base-modem.c:845)
    ==10047==    by 0x15E9F3: mm_base_modem_peek_port_qmi_for_data (mm-base-modem.c:579)
    ==10047==    by 0x15E8FC: mm_base_modem_get_port_qmi_for_data (mm-base-modem.c:555)
    ==10047==    by 0x1BB99F: _connect (mm-bearer-qmi.c:1391)
    ==10047==    by 0x1540B4: mm_base_bearer_connect (mm-base-bearer.c:841)
    ==10047==    by 0x181F4F: connection_step (mm-iface-modem-simple.c:597)
    ==10047==    by 0x181321: create_bearer_ready (mm-iface-modem-simple.c:258)
    ==10047==    by 0x612FD52: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
2017-10-07 14:10:12 +02:00
Ben Chan f8a375b1fa broadband-modem-mbim: use device manufacturer information when available
MBIM modems can be supported by the 'generic' plugin. Instead of
treating the plugin name (i.e. Generic) as the manufacturer, it's more
useful to use the manufacturer information reported by the underlying
USB device if that is available.
2017-10-07 10:05:40 +02:00
Ben Chan 3a0d658b5d kerneldevice: add method to retrieve manufacturer information
A USB device may report its manufacturer through the Manufacturer String
Descriptor. That information can sometimes be useful, e.g. MBIM doesn't
define a standard command to query the manufacturer. This patch adds a
method to MMKernelDevice to retrieve the manufacturer information from
the underlying physical device, which can later be used by
MMBroadbandModemMbim to report the manufacturer of a MBIM modem.
2017-10-07 10:05:40 +02:00
Aleksander Morgado efaa780de2 port-qmi: don't allow client allocation if port is closed
The internal QmiDevice will be gone when the port is closed, so we
cannot really do anything.

This avoid an issue happening when the modem goes away in the middle
of the client allocation logic performed by MMBroadbandModemQmi:

    ModemManager[24820]: <debug> [1507279407.225777] Couldn't allocate client for service 'wms': Couldn't create client for service 'wms': CID allocation failed in the CTL client: Transaction timed out
    ModemManager[24820]: qmi_device_allocate_client: assertion 'QMI_IS_DEVICE (self)' failed
    ==24820==
    ==24820== Process terminating with default action of signal 5 (SIGTRAP): dumping core
    ==24820==    at 0x66E3411: ??? (in /usr/lib/libglib-2.0.so.0.5200.3)
    ==24820==    by 0x66E46FA: g_logv (in /usr/lib/libglib-2.0.so.0.5200.3)
    ==24820==    by 0x66E484E: g_log (in /usr/lib/libglib-2.0.so.0.5200.3)
    ==24820==    by 0x538E259: qmi_device_allocate_client (qmi-device.c:1008)
    ==24820==    by 0x1F5690: mm_port_qmi_allocate_client (mm-port-qmi.c:157)
    ==24820==    by 0x1D20BA: allocate_next_client (mm-broadband-modem-qmi.c:11319)
    ==24820==    by 0x1D2027: qmi_port_allocate_client_ready (mm-broadband-modem-qmi.c:11306)
    ==24820==    by 0x612FD52: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
    ==24820==    by 0x6130775: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
    ==24820==    by 0x1F54E8: allocate_client_ready (mm-port-qmi.c:113)
    ==24820==    by 0x612FD52: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
    ==24820==    by 0x6130775: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
2017-10-06 10:51:01 +02:00
Aleksander Morgado 4bd15362c5 kerneldevice,generic: plug memleak
==5075== 198 bytes in 18 blocks are definitely lost in loss record 4,486 of 4,761
    ==5075==    at 0x4C2CE5F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==5075==    by 0x66E3028: g_malloc (in /usr/lib/libglib-2.0.so.0.5200.3)
    ==5075==    by 0x66CAD42: g_path_get_basename (in /usr/lib/libglib-2.0.so.0.5200.3)
    ==5075==    by 0x20BB7B: preload_interface_sysfs_path (mm-kernel-device-generic.c:184)
    ==5075==    by 0x20C885: preload_contents (mm-kernel-device-generic.c:383)
    ==5075==    by 0x20E2E1: check_preload (mm-kernel-device-generic.c:830)
    ==5075==    by 0x20EA6F: set_property (mm-kernel-device-generic.c:953)
    ==5075==    by 0x6455359: ??? (in /usr/lib/libgobject-2.0.so.0.5200.3)
    ==5075==    by 0x6456DBC: g_object_new_valist (in /usr/lib/libgobject-2.0.so.0.5200.3)
    ==5075==    by 0x6105E95: g_initable_new_valist (in /usr/lib/libgio-2.0.so.0.5200.3)
    ==5075==    by 0x6105F58: g_initable_new (in /usr/lib/libgio-2.0.so.0.5200.3)
    ==5075==    by 0x20E848: mm_kernel_device_generic_new_with_rules (mm-kernel-device-generic.c:901)
2017-10-05 23:46:42 +02:00
Aleksander Morgado 8cd21e439d kerneldevice,generic: plug memleak
==5075== 333 bytes in 37 blocks are definitely lost in loss record 4,612 of 4,761
    ==5075==    at 0x4C2CE5F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==5075==    by 0x66E3028: g_malloc (in /usr/lib/libglib-2.0.so.0.5200.3)
    ==5075==    by 0x66CAD42: g_path_get_basename (in /usr/lib/libglib-2.0.so.0.5200.3)
    ==5075==    by 0x20BE20: preload_driver (mm-kernel-device-generic.c:242)
    ==5075==    by 0x20C8E5: preload_contents (mm-kernel-device-generic.c:391)
    ==5075==    by 0x20E2E1: check_preload (mm-kernel-device-generic.c:830)
    ==5075==    by 0x20EA6F: set_property (mm-kernel-device-generic.c:953)
    ==5075==    by 0x6455359: ??? (in /usr/lib/libgobject-2.0.so.0.5200.3)
    ==5075==    by 0x6456DBC: g_object_new_valist (in /usr/lib/libgobject-2.0.so.0.5200.3)
    ==5075==    by 0x6105E95: g_initable_new_valist (in /usr/lib/libgio-2.0.so.0.5200.3)
    ==5075==    by 0x6105F58: g_initable_new (in /usr/lib/libgio-2.0.so.0.5200.3)
    ==5075==    by 0x20E848: mm_kernel_device_generic_new_with_rules (mm-kernel-device-generic.c:901)
2017-10-05 23:46:42 +02:00
Aleksander Morgado 2dc13fd964 plugin-manager: allow multiple calls to port_context_complete()
Only the first one will work.
2017-10-05 23:46:42 +02:00