From 6d644c66a8baf0489188bcdd8137abcca79b0e1b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 23 Aug 2019 17:01:18 +0200 Subject: wwan: mark modems that are taken by a NMDevice as "claimed" NMModem-s are either used by NMDeviceModem or by NMDeviceBt. The mechanism how that is coordinated it odd: - the factory emits component-added, and then NMDeviceBt might take the device (and claim it). In that case, component-added would return TRUE to indicate that the modem should not be also used by NMDeviceModem. - next, if the modem has a driver that looks like bluetooth, NMDeviceModem ignores it too. - finally, NMDeviceModem claims the modem (which is now considered to be non-bluetooth). I think the first problem is that the device factory tries to have this generic mechanism of "component-added". It's literally only used to cover this special case. Note that NMDeviceBt is aware of modems. So, abstracting this just adds lots of code that could be solved better by handling the case (of giving the modem to either NMDeviceBt or NMDeviceModem) specifically. NMWWanFactory itself registers to the NM_MODEM_MANAGER_MODEM_ADDED signal and emits nm_device_factory_emit_component_added(). We could just have NMWWanFactory and NMDeviceBt both register to that signal. Signals even support priorities, so we could have NMDeviceBt be called first to claim the device. Anyway, as the modem can only have one owner, the modem should have a flag that indicates whether it's claimed or not. That will allow multiple components all look at the same modem and moderate who is going to take ownership. --- src/devices/wwan/libnm-wwan.ver | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/devices/wwan/libnm-wwan.ver') diff --git a/src/devices/wwan/libnm-wwan.ver b/src/devices/wwan/libnm-wwan.ver index 7ccebcb5ee..b63a5066bc 100644 --- a/src/devices/wwan/libnm-wwan.ver +++ b/src/devices/wwan/libnm-wwan.ver @@ -3,6 +3,7 @@ global: nm_modem_act_stage1_prepare; nm_modem_act_stage2_config; nm_modem_check_connection_compatible; + nm_modem_claim; nm_modem_complete_connection; nm_modem_deactivate; nm_modem_deactivate_async; @@ -14,14 +15,15 @@ global: nm_modem_get_device_id; nm_modem_get_driver; nm_modem_get_iid; - nm_modem_get_path; nm_modem_get_ip_ifindex; nm_modem_get_operator_code; + nm_modem_get_path; nm_modem_get_secrets; nm_modem_get_state; nm_modem_get_type; nm_modem_get_uid; nm_modem_ip4_pre_commit; + nm_modem_is_claimed; nm_modem_manager_get; nm_modem_manager_get_type; nm_modem_manager_name_owner_get; @@ -32,6 +34,7 @@ global: nm_modem_stage3_ip4_config_start; nm_modem_stage3_ip6_config_start; nm_modem_state_to_string; + nm_modem_unclaim; local: *; }; -- cgit v1.2.1 From f796be3d7dcda422fd56fddf5d721f99e7e7a871 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 23 Aug 2019 17:23:09 +0200 Subject: wwan: add nm_modem_manager_get_modems() to iterate over modems Currently, we cannot ask which modems exist. NMDeviceBt may claim it via nm_device_factory_emit_component_added(), and NMWWanFactory may take it by listening to NM_MODEM_MANAGER_MODEM_ADDED. But that's it. We will drop nm_device_factory_emit_component_added() because it's only used for passing modems to NMDeviceBt. Instead, NMDeviceBt can directly subscribe to NM_MODEM_MANAGER_MODEM_ADDED. It already has a reference to NMModemManager. Anyway, the NM_MODEM_MANAGER_MODEM_ADDED signal is no enough, because sometimes when the mode appears, NMDeviceBt might not yet know whether it should take it (because the DUN connect call is not yet complete). Currently that never happens because dun_connect() blocks waiting for the device. That must be fixed, by not waiting. But this opens up a race, and NMDeviceBt might after NM_MODEM_MANAGER_MODEM_ADDED need to search for the suitable modem: by iterating the list of all modems. --- src/devices/wwan/libnm-wwan.ver | 1 + 1 file changed, 1 insertion(+) (limited to 'src/devices/wwan/libnm-wwan.ver') diff --git a/src/devices/wwan/libnm-wwan.ver b/src/devices/wwan/libnm-wwan.ver index b63a5066bc..c368a5907d 100644 --- a/src/devices/wwan/libnm-wwan.ver +++ b/src/devices/wwan/libnm-wwan.ver @@ -25,6 +25,7 @@ global: nm_modem_ip4_pre_commit; nm_modem_is_claimed; nm_modem_manager_get; + nm_modem_manager_get_modems; nm_modem_manager_get_type; nm_modem_manager_name_owner_get; nm_modem_manager_name_owner_ref; -- cgit v1.2.1