aboutsummaryrefslogtreecommitdiff
path: root/src/mm-base-manager.c
AgeCommit message (Collapse)Author
2023-10-27core: ensure all errors returned in DBus operations are normalizedAleksander Morgado
We want to ensure that all errors reported via DBus operations are normalized to MM-specific errors. We don't want to return QMI or MBIM specific errors, as those are protocol specific and we don't want DBus clients to need to rely on knowing which is the protocol in use by the device.
2023-09-18api,modem: new 'Physdev' propertyLukas Voegl
Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
2023-03-21base-manager: improve logging of manager DBus requestsAleksander Morgado
2023-02-24base-manager: remove shadowing variableAleksander Morgado
[1/2] Compiling C object src/ModemManager.p/mm-base-manager.c.o ../src/mm-base-manager.c: In function ‘remove_device_inhibition’: ../src/mm-base-manager.c:1127:20: warning: declaration of ‘l’ shadows a previous local [-Wshadow] 1127 | GList *l; | ^ ../src/mm-base-manager.c:1116:16: note: shadowed declaration is here 1116 | GList *l; | ^
2023-02-21base-manager: fix crash when uninhibiting partially removed deviceAleksander Morgado
If the device is not fully removed from the system during inhibition and port additions happen, we reach a state where the MMDevice object is still tracked by ModemManager and we also have new port additions tracked that will require explicit port probings before a new modem object can be created. Solve this mixup by faking the removal of all existing device ports, which will end up completely removing hte MMDevice, so that new port additions reported afterwards also involve the full device probing process triggered by the plugin manager. The issue could be reproduced easily on a MBIM device that also exposed TTYs, as follows: * mmcli -m a --inhibit, leave it running * rmmod cdc_mbim && sleep 5 && modprobe cdc_mbim (so that the cdc-wdm and net ports go away from the system but NOT the TTYs.) * Cltr+C to stop the inhibit in the mmcli call. ModemManager would assert as follows: 0x000079918bcf2a3f (libc.so.6 + 0x00087a3f) pthread_key_delete 0x000079918bca7c6c (libc.so.6 + 0x0003cc6c) gsignal 0x000079918bc93462 (libc.so.6 + 0x00028462) abort 0x000079918bf26f03 (libglib-2.0.so.0 - gtestutils.c: 3253) g_assertion_message 0x000079918bf26f66 (libglib-2.0.so.0 - gtestutils.c: 3279) g_assertion_message_expr 0x0000594ff1093d0c (ModemManager - mm-base-manager.c: 1110) remove_device_inhibition 0x0000594ff1093968 (ModemManager - mm-base-manager.c: 1247) inhibit_device_auth_ready 0x000079918c0536a8 (libgio-2.0.so.0 - gtask.c: 1230) g_task_return_now 0x000079918c0536db (libgio-2.0.so.0 - gtask.c: 1244) complete_in_idle_cb 0x000079918bf053fc (libglib-2.0.so.0 - gmain.c: 3417) g_main_context_dispatch 0x000079918bf05704 (libglib-2.0.so.0 - gmain.c: 4211) g_main_context_iterate 0x000079918bf05978 (libglib-2.0.so.0 - gmain.c: 4411) g_main_loop_run 0x0000594ff108de66 (ModemManager - main.c: 217) main 0x000079918bc936c5 (libc.so.6 + 0x000286c5) __libc_init_first 0x000079918bc93781 (libc.so.6 + 0x00028781) __libc_start_main 0x0000594ff108db80 (ModemManager + 0x00061b80) _start
2023-01-03build: new option to build plugins within the daemon binaryAleksander Morgado
Instead of creating libmm-plugin* and libmm-shared* libraries that are dlopen()-ed on runtime, allow incorporating all plugins into the daemon binary itself. This makes the startup of the daemon much faster and also avoids issues with builds that require linker namespace isolation. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/674
2022-11-07build: disable Test interface in base manager if building without testsAleksander Morgado
There is no real need for this interface if tests are not being built.
2022-11-04core,log: new 'MSG' log level between 'INFO' and 'WARN'Aleksander Morgado
We're bumping the current "INFO" level messages to the new "MSG" level, also making the new level the default. The old "INFO" level will be used to setup an intermediate level of logging which is not as verbose as "DEBUG" but still provides some capabilities to analyze the behavior of a modem.
2022-06-09suspend: add suspend/resume support with powerd on ChromeOSRukun Mao
ModemManager handles suspend and resume signals sent from powerd Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/547
2021-06-16base-manager: skip using g_warning() in process_initial_kernel_events()Aleksander Morgado
Use mm_obj_warn() instead.
2021-05-26base-modem: fix modem_sync() operation handlingAleksander Morgado
The mm_base_modem_sync() method is an asynchronous method that receives a callback and user data, and therefore we MUST always complete the async method calling that callback. Set that up with a GTask as usual. Also, the mm_base_modem_sync_finish() method should be implemented along with mm_base_modem_sync(), not in the source file of the caller of the async method. The finish() always depends on how the async method was implemented, in our case using a GTask.
2021-05-26base-manager: avoid using the `mm_` prefix for static private methodsAleksander Morgado
2021-05-26base-manager: don't assume a MMDevice always holds a MMModemAleksander Morgado
There are cases, e.g. during modem object disposal, where this is not true.
2021-05-26base-manager: make sure g_autoptr() variables are initialized to NULLAleksander Morgado
Otherwise, we may have memory issues if the variable isn't initialized and the method exits.
2021-05-26base-manager: add quick suspend/resume baseDylan Van Assche
Quick suspend/resume infrastructure for synchronizing the interfaces when resuming.
2021-05-26base-manager: ensure all GUdevDevices have subsystem and name setAleksander Morgado
Under certain rare conditions (e.g. race between querying devices of a given subsystem and the kernel tearing those devices down), the subsystem reported for a GUdevDevice seems to be NULL. So, ensure both subsystem and name are set on the GUdevDevice before we process them. The issue has been observed on GUdevDevices listed by g_udev_client_query_by_subsystem(), not on the ones asynchronously reported via uevents, but we add the validity check on both places for consistency. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/343
2021-04-30core: strict return type in g_object_ref()Aleksander Morgado
This is now a requirement when using glib 2.56.
2021-04-14context: allow disabling QRTR on runtime even if support is builtAleksander Morgado
2021-04-14qrtr-bus-watcher: add a class to watch for QRTR nodesAndrew Lassalle
Add a watcher to listen for QRTR add/remove signals.
2021-04-14kernel-device,qrtr: add MMKernelDeviceQrtr skeletonAndrew Lassalle
Add the skeleton of MMKernelDeviceQrtr and allow building it by the introduction of with-qrtr.
2021-03-16mm-base-manager: split assertionEric Caruso
This allows us to know which of the subsystem or name for a removed device is triggering the assertion from just a stack trace that contains line information.
2021-02-25kernel-device-udev: keep track of the client objectAleksander Morgado
Instead of creating new clients internally whenever we need them, just make sure each MMKernelDeviceUdev object keeps a full reference to the GUdevClient that generated all GUdevDevices.
2020-11-19base-manager: never create kernel device objects for remove eventsAleksander Morgado
There is no point in creating a new kernel device object just to process a remove event; instead, do any matching with existing kernel device objects by subsystem and name, which is what the generic backend already did anyway. This avoids unnecessary lookup of information in sysfs during removal events, because the port is anyway already gone when we try to look those up.
2020-11-14base-manager: allow forcing the testing without udevAleksander Morgado
Even if udev support is really built and available. This is extremely useful to test the udev-less setup without fully recompiling the whole daemon. E.g.: the daemon can be run like this: $ sudo /usr/sbin/ModemManager --debug --test-no-udev And then, the kernel events may be reported using mmcli like this: $ sudo mmcli --report-kernel-event-auto-scan
2020-11-13base-manager: automatic required subsystem detectionAleksander Morgado
Instead of assuming we require a fixed set of subsystems to monitor, compile the full list based on what the plugins have requested themselves.
2020-11-13core: stop monitoring the 'usb' subsystemAleksander Morgado
Back in Linux < 3.6 days, the cdc-wdm ports exposed by the QMI driver were flagged as owned by the 'usb' subsystem. That changed in 3.6 when the subsystem was renamed to 'usbmisc': https://mail.gnome.org/archives/networkmanager-list/2012-June/msg00125.html This patch removes all monitoring of the 'usb' subsystem completely, which is anyway a valid subsystem but for which we shouldn't need any special handling. Right now, with newer kernels, we were using that monitoring exclusively to get notified of full USB device remove events, which is really not required as we already process the port removals one by one. We simplify the logic everywhere that attempted to match either the 'usb' or 'usbmisc' subsystems, and we no longer require the explicit checks for the port name being named 'cdc-wdm[0-9]*' in the code, as that is already taken care of by the ID_MM_CANDIDATE udev tag rule.
2020-11-09base-manager: log kernel event handling failuresAleksander Morgado
Don't just return the error to the client, we want this info in the daemon log as well.
2020-04-08base-manager: port to use object loggingAleksander Morgado
2020-01-28auth-provider: fix reference count in manager and modem objectsAleksander Morgado
The auth provider is now a singleton (since 20ab6550), one single object that lives throughout the whole program execution, and so we don't need to keep our own full references around. This fix makes sure we don't attempt to unref a full auth provider reference we don't own. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/179
2020-01-23auth-provider: refactor and simplifyAleksander Morgado
The auth provider setup is a bit over-engineered. Simplify it by making a single MMAuthProvider object that may or may not use polkit, depending on configure options. This object is also setup as a singleton object using the helper MM_DEFINE_SINGLETON_GETTER().
2020-01-06device: keep reference to object manager serverAleksander Morgado
Instead of having the reference to the object manager server only while the modem is exported, just keep a reference for as long as the device object exists. This will make it easier to handle reprobing logic.
2019-04-02base-manager: fix inhibition alloc/dealloc mixupAleksander Morgado
2019-01-03api,manager: new InhibitDevice() methodAleksander Morgado
This new method allows users of the ModemManager API to take full control of a given device. Unlike other operations in the API, the inhibition is maintained as long as the caller exists in the bus, or until the same caller uninhibits the device. https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/98
2018-12-09base-manager: load subsys/name once in device_added()Aleksander Morgado
2018-12-04api,manager: new 'Version' propertyAleksander Morgado
This string shows the runtime version of the ModemManager daemon. https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/94
2018-09-25udev: define all generic tags as symbolsAleksander Morgado
This prevents errors due to nasty typos in the strings. We define all symbols in a single header file that is NOT considered part of the API, as there is no need for MM clients to know about these tags code-wise. These tags are only meaningful when associated to devices in udev. Information of each tag is included in the general API documentation. https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/88
2018-02-23base-manager: additional indentation for the block covered by ref/unrefAleksander Morgado
2018-02-23mm-base-manager: ref MMDevice before releasing portEric Caruso
Releasing the port on the device looks benign but because it emits a signal, it could call device_context_port_released and unref the MMDevice in port_context_unref. This means the MMDevice might be disposed before we get to the g_object_ref and the subsequent call to g_hash_table_remove will try to hash a null string, which makes MM crash.
2018-02-21mm-base-manager: remove element from hastable by key, not valueEric Caruso
The hashtable is keyed on the UID of the MMDevice, and its hash function is g_str_hash. We shouldn't be passing a GObject into g_hash_table_remove because calling g_str_hash on an MMDevice is wrong.
2017-12-05filter: additional strict rules when all device ports availableAleksander Morgado
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-05filter: new automatic whitelisting rules and strict/paranoid policiesAleksander Morgado
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-05filter: allow selection of filter policy on startupAleksander Morgado
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-05filter: allow enabling/disabling rules via envvarsAleksander Morgado
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-05filter: remove bogus TTY virtual console filterAleksander Morgado
The more generic filter for virtual devices already covers all cases covered by the TTY virtual console filter.
2017-12-05filter: new object to run the port/device filter logicAleksander Morgado
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-10-05base-manager: plug memleakAleksander Morgado
==28888== 622 (280 direct, 342 indirect) bytes in 7 blocks are definitely lost in loss record 2,515 of 2,548 ==28888== at 0x6474014: g_type_create_instance (in /usr/lib/libgobject-2.0.so.0.5200.3) ==28888== by 0x6455027: ??? (in /usr/lib/libgobject-2.0.so.0.5200.3) ==28888== by 0x6456A54: g_object_newv (in /usr/lib/libgobject-2.0.so.0.5200.3) ==28888== by 0x6457213: g_object_new (in /usr/lib/libgobject-2.0.so.0.5200.3) ==28888== by 0x4E9DD7D: mm_kernel_event_properties_new (mm-kernel-event-properties.c:422) ==28888== by 0x4E9D8BC: mm_kernel_event_properties_new_from_string (mm-kernel-event-properties.c:283) ==28888== by 0x1465D7: process_initial_kernel_events (mm-base-manager.c:555) ==28888== by 0x14679E: mm_base_manager_start (mm-base-manager.c:581) ==28888== by 0x143CF3: name_acquired_cb (main.c:110) ==28888== by 0x616B805: ??? (in /usr/lib/libgio-2.0.so.0.5200.3) ==28888== by 0x616BA47: ??? (in /usr/lib/libgio-2.0.so.0.5200.3) ==28888== by 0x612FD52: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
2017-08-22base-manager: avoid events of USB interface from removing MMDeviceBen Chan
When a USB modem is switching its USB configuration, udev may deliver the remove events of USB interfaces associated with the old USB configuration and the add events of USB interfaces associated with the new USB configuration in an interleaved fashion. An interleaved remove event of USB interface could trigger the special case handling code in mm-base-manager.c:device_removed() and incorrectly remove a MMDevice under probing. See https://lists.freedesktop.org/archives/modemmanager-devel/2017-August/005626.html for more details. This patch adds a check to ensure that only remove events of USB device (i.e. not interface) can trigger the special handling code.
2017-07-14base-manager: minor coding style fixesBen Chan
2017-06-22build: WITH_UDEV is only defined when enabledAleksander Morgado
Looks like the preprocessor doesn't choke when using #if WITH_UDEV and it isn't defined to any value, but anyway, better explicitly say that we're checking if it's defined or not.
2017-03-30base-manager: fix segfault when using already disposed MMDeviceAleksander Morgado
Since commit e9d0989ed069, the MMDevice may be removed from the tracking hash table when the support check operation fails to create a modem object. If this failure happens due to the port probe cancellations requested during the udev removal event for a given device port, we would end up using an already disposed object and triggering a segfault. This fix just makes sure a full valid reference to the MMDevice object is kept around until we're done using it. [mm-base-manager.c:216] device_removed(): (usbmisc/cdc-wdm1): released by device '/sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.4' [mm-plugin-manager.c:1131] device_context_port_released(): [plugin manager] task 5: port released: cdc-wdm1 [mm-base-manager.c:216] device_removed(): (tty/ttyACM0): released by device '/sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.4' [mm-plugin-manager.c:1131] device_context_port_released(): [plugin manager] task 5: port released: ttyACM0 [mm-base-manager.c:221] device_removed(): Removing empty device '/sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.4' [mm-plugin-manager.c:1219] device_context_cancel(): [plugin manager) task 5: cancellation requested [mm-plugin-manager.c:979] device_context_continue(): [plugin manager] task 5: no more ports to probe [mm-plugin-manager.c:813] device_context_complete(): [plugin manager] task 5: finished in '0.090510' seconds [mm-base-manager.c:172] device_support_check_ready(): Couldn't check support for device '/sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.4': Operation was cancelled [mm-base-manager.c:223] device_removed(): Device support check has been cancelled Thread 1 "ModemManager" received signal SIGSEGV, Segmentation fault. 0x00007ffff6543c50 in g_str_hash () from /usr/lib/libglib-2.0.so.0 (gdb) bt #0 0x00007ffff6543c50 in g_str_hash () at /usr/lib/libglib-2.0.so.0 #1 0x00007ffff6542b2d in () at /usr/lib/libglib-2.0.so.0 #2 0x0000000000439675 in device_removed (self=0x770900, kernel_device=0x763e60) at mm-base-manager.c:225 #3 0x0000000000439e70 in handle_uevent (client=0x769c20, action=0x81d910 "remove", device=0x7fffe4001c40, user_data=0x770900) at mm-base-manager.c:415 #4 0x00007ffff54c61c8 in ffi_call_unix64 () at /usr/lib/libffi.so.6 #5 0x00007ffff54c5c2a in ffi_call () at /usr/lib/libffi.so.6 #6 0x00007ffff682d7ae in g_cclosure_marshal_generic () at /usr/lib/libgobject-2.0.so.0 #7 0x00007ffff682cf75 in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0 #8 0x00007ffff683ef82 in () at /usr/lib/libgobject-2.0.so.0 #9 0x00007ffff6847bcc in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0 #10 0x00007ffff6847faf in g_signal_emit () at /usr/lib/libgobject-2.0.so.0 #11 0x00007ffff7023c74 in () at /usr/lib/libgudev-1.0.so.0 #12 0x00007ffff655445a in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0 #13 0x00007ffff6554810 in () at /usr/lib/libglib-2.0.so.0 #14 0x00007ffff6554b32 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0 #15 0x0000000000437bf5 in main (argc=2, argv=0x7fffffffeb28) at main.c:180 (gdb) fr 2 #2 0x0000000000439675 in device_removed (self=0x770900, kernel_device=0x763e60) at mm-base-manager.c:225 225 g_hash_table_remove (self->priv->devices, mm_device_get_uid (device)); (gdb) p mm_device_get_uid (device) $1 = (const gchar *) 0x0 (gdb) p *device $3 = {parent = {g_type_instance = {g_class = 0x0}, ref_count = 0, qdata = 0x0}, priv = 0x7feb20}