Commit Graph

83 Commits

Author SHA1 Message Date
Christian Korber
a6b332f4e9 modemmanager: change to configuration option disable_modem
This commit sets default of `disable_modem` to 1 and disconnects modem.
If set otherwise it keeps the modem connected.

Signed-off-by: Christian Korber <ck@dev.tdt.de>
2025-07-08 07:55:17 +02:00
Ryan Press
7efed7ff9f modemmanager: add sourcefilter option support
This make source based IPv6 routing option available for
modemmanager when using modem SLAAC.

Signed-off-by: Ryan Press <ryan@presslab.us>
2025-05-28 08:16:27 +02:00
Florian Eckert
6b9b6fdace modemmanager: add missing any option to allowedmode
The 'mmcli' also understands the option 'any'.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2025-04-10 09:33:58 +02:00
Florian Eckert
6c8ad9f02b modemmanager: fix pending mmcli calls for ModemManager-monitor script
If the ModemManager is stopped via '/etc/init.d/modemmanager', mmcli calls
always remain in the process list. This is because the ModemManager-monitor
call is not terminated properly, as the kill signals are not handled
correctly in the startup script for mmcli.

To fix this, the signal handling is refactored.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2025-04-01 10:08:27 +02:00
Florian Eckert
5c203c36d5 modemmanager: add missing mmcli timeout option during ubus call
The default 'timeout' value is 30 seconds when calling an mmcli action. That
is too long. For this reason, the mmcli 'timeout' option is specified for
calls and the value is set to 10 seconds.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2025-04-01 10:08:27 +02:00
Gilles Lenaerts
5cb12d479b modemmanager: add config optional netifd integration
This change introduces an optional configuration
of the  netifd integration in the ModemManager package.
When disabled, it removes the NETIFD dependency and
other unwanted components from the root filesystem
during the build phase.

Additionally, in the modemmanager.common the netifd-proto.sh
inclusion line can be savely removed as there is no usage
of it in its functions.

Signed-off-by: Gilles Lenaerts <gilles.lenaerts_ext@softathome.com>
2025-02-26 10:03:30 +01:00
Florian Eckert
434c353e62 modemmanager: do not disable modem on reconnect
If the modem loses the connection, an attempt is made to re-establish the
connection via the report-down script.

Until now, the modem was disabled when the modem processed the teardown of
the modemmanager protohandler. The immediate up events of netifd renables
the modem right away. This takes time, which is not necessary.

This commit changes the behavior so that the modem is not disabled when
the modemmanager is disconnected via the report-down script.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2025-02-12 16:52:16 +01:00
Florian Eckert
24d2ba0ba8 modemmanager: check during SIM unlocking whether initialization has been completed
After the SIM has been successfully unlocked, it is initialized. This can
take longer on some modems, so we must wait until the modem is ready to
execute the next commands.

Otherwise the modem cannot be enabled and aborts with the following
error message:

error: couldn't enable the modem: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.WrongState: modem in initializing state'

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-11-15 11:17:05 +01:00
Florian Eckert
fa6198e36b modemmanager: reset to 'no' plmn if nothing is configured
If a configured 'plmn' is deleted from the configuration between a connection
setup, it will continue to be used because the modem remembers it.

Therefore, the 'plmn' stored in the modem must be deleted when a new
connection is established if it is no longer in the configuration.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-11-15 11:17:05 +01:00
Florian Eckert
3a5aa8a387 modemmanager: swap plmn and technology set command in the proto
In the current implementation of the modemmanager 'proto', if a 'plmn' and a
'technology' is configured, the 'plmn' is set first and then second the
'technology' on a 'proto' setup.

However, this is problematic if a 'technology' has already been set in an
earlier run. It is possible, that this previously set 'technology' is not
available at the current location, as the modem remembers the setting.

To fix this, first set the technology and then the plmn.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-11-15 11:17:05 +01:00
Florian Eckert
8682084e34 modemmanager: move plmn registration into own function
To improve the code, the setting of the 'plmn' is moved to separate function.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-11-15 11:17:05 +01:00
Florian Eckert
5ab483aa44 modemmanager: rename function modemmanager_check_state to modemmanager_check_sim_state
This is a preparation commit for a new function.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-11-15 11:17:05 +01:00
Florian Eckert
9f35173639 modemmanager: move initial eps settings after modem enable
This settings are needed before any other mmcli command is executed.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-11-15 11:17:05 +01:00
Florian Eckert
b6664ae938 modemmanager: add log file if syslog is set to DEBUG
If the ModemManager is started with debug, all outputs are written to the
system log. To simplify debugging, a logging file is now created under
'/var/log/mm.log' in this case. This simplifies error analysis.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-11-15 11:17:05 +01:00
Florian Eckert
85a01e2bb3 modemmanager: add pin check attempts
This new check in the proto modemanager prevents the SIM card from being
blocked and therefore PUK is not required. If the PIN is entered incorrectly
in the 'uci' configuration, it makes no sense to try this several times
until the PUK is required. Should it nevertheless happen that the PUK
is required, then this will logged.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-10-17 18:29:16 +02:00
Florian Eckert
deaef51d07 modemmanager: improvement of readability by reversing the query
No functional change. The change makes reading the source clearer.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-10-17 18:29:16 +02:00
Florian Eckert
cdda998996 modemmanager: add missing interface argument to function modemmanager_check_state
The variable interface is used in the sub-function 'modemmanager_check_state'.
However, this is not an argument of the function and so the global value
is used. Addding the variable as an function call argument fixes this.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-10-17 18:29:16 +02:00
Florian Eckert
64bd9e9d08 modemmanager: move modemmanager_check_state failed and locked into sub functions
To make the source clearer, the program parts for the 'locked' and 'failed'
cases are outsourced to sub-functions.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-10-17 18:29:16 +02:00
Florian Eckert
dced576bfe modemmanager: fix value call with modemmanager_get_field function
The correct values are prefixed with 'modem.generic'. This is missing
for the value 'state' and 'state-failed-reason.

While we're at it, let's move the readout of 'state-failed-reason' to the
failed case, because that's the only place it's needed.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-10-17 18:29:16 +02:00
Florian Eckert
e2822c9d80 modemmanager: extend log message with count on boot
This makes debugging at system startup easier and shows how long we are
waiting for the ModemManager to start.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-10-17 18:29:16 +02:00
Florian Eckert
9de61ea058 modemmanager: add missing ubus status backend via mmcli
The 'modemmanager' uses the 'dbus'. Status information can be retrieved
with the 'mmcli' command, this can also be output in json format.

This commit adds a new 'ubus' backend with which this information can
be easily accessed via ubus.

* ubus call modemmanager info
* ubus call modemmanager dump

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-07-10 12:26:51 +02:00
Chen Minqiang
9877676890 modemmanager: add sourcefilter option support
This make source based IPv6 routing option available for
modemmanager case dhcpv6

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
2024-06-23 16:39:01 -07:00
Oliver Sedlbauer
7eb763b962 modemmanager: remove status message from errors
The message 'MM_CONNECT_IN_PROGRESS' is a status message, not an error
message. To avoid confusion, the message has been removed.

Signed-off-by: Oliver Sedlbauer <osedlbauer@tdt.de>
2024-06-11 16:00:20 +02:00
Oliver Sedlbauer
06a6258035 modemmanager: add option to force connection
This commit improves the automatic reconnect logic. If the modem cannot
establish a connection, for example due to poor reception, the
proto_block_restart prevents the interface from trying to reconnect.
To enforce the connection, this commit adds a new option that allows the
system to attempt to establish a connection indefinitely.

Signed-off-by: Oliver Sedlbauer <osedlbauer@tdt.de>
2024-06-11 15:59:45 +02:00
Florian Eckert
26117ac9b1 Merge pull request #23590 from TDT-AG/pr/20240305-modemmanager
modemmanager: reconnect interface if the modemmanager detects a disconnect
2024-03-12 11:59:11 +01:00
Daniele Palmas
c51a804a63 modemmanager: report events for virtual netdevices
Virtual netdevices created for multiplexing should not be skipped
when reporting events, otherwise it is not possible to setup the
data connection.

Add these exceptions in mm_report_event function.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2024-03-06 10:16:21 +01:00
Florian Eckert
77c16abb1a modemmanager: reconnect interface if the modemmanager detects a disconnect
There are situation for mobile routers, that the modemmanager can not
stay connected to the mobile network. There can have various reasons.
In order for the system to reconnect automatically, the netifd must be
informed that it must re-establish the connection.

The modem manager already does have a script callback handling which is
already used by the modemmanager in openwrt. Currently the modem is marked
as not unavailable when a disconnected event is detected.

The behavior was changed with this commit, so that a reconnect of the
interface is now triggerd via the netifd if the modem disconnects.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-03-06 09:11:57 +01:00
Florian Eckert
9d509b7433 modemmanager: start a 3gpp network regsistration
If a 'plmn' is set in the configuration, a registration attempt should be
established before the simple-connect command. If the plmn is set during
the simple-connect, a network change may occur during the connection setup.

To prevent this, the registration is started before the simple-connect with
a separate mmcli command. So that we can be sure that the modem is already
registered in the correct network before the simple-connect command.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-03-05 15:20:38 +01:00
Florian Eckert
d839e194c5 modemmanager: move cleanup and enable to the top
Before a new connection attempt is made, the previous connection must be
cleaned up before further connection attempts are made. This is now done
by moving the cleanup and enable sequence to the beginning of the
conection setup.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-03-05 15:20:38 +01:00
Florian Eckert
dab2cdc44c modemmanager: moving the openwrt related files to subdirectories
Moving the openwrt related files to subdirectories as they are installed
on the system. This change makes it immediately apparent during development
where the file is to be installed in the running system.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-03-05 13:04:59 +01:00
Florian Eckert
b0f7260319 modemmanager: suppress mm_log debug messages by default
The log is filled with 'debug' messages. This is not necessary and is
only normaly needed during development. To suppress this message, check
whether the level is 'debug' and if so, suppress it. If this message is
required again, the message can be generated by commenting out this line.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-01-19 08:47:44 +01:00
Florian Eckert
d9b5e06d19 modemmanager: replace modem available check on start with the new monitore service
Before this change, the status of the sysfs paths from the kernel events
was cached with a cache file. This is necessary to mark configured modems
as available for the netifd.

Using the new monitor service via the mmcli command 'mmcli -M' simplifies
the whole process. There is no need to start sub shells in the background
anymore that monitors whether the modem has already been added to the
ModemManager.

For this purpose, a new service was added that reacts on add and remove
events for modems in the ModemManager and, if necessary, marks the logical
netifd interface as available.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-01-19 08:47:34 +01:00
Florian Eckert
ebc9038721 modemmanager: move shell include to the beginning of the file
It is usual that the includes are listed at the beginning of the script.
So let's do it that way too.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-01-19 08:46:37 +01:00
Florian Eckert
39e084ca6b modemmanager: move generally applicable functions to modemmanager.common
These moved functions are general functions. This is a preparatory
commit so that these moved functions can also be used in other
ModemManager scripts.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-01-19 08:43:35 +01:00
Florian Eckert
620afc1806 modemmanager: set allowedmode to 'any' if nothing is configured
The modem saves the permitted technology configuration in the modem
itself. If the technology configuration is deleted in the uci, this is
not passed on to the modem. This means that the previously saved
technology configuration is remains in the modem and is therefore still
active. By setting the technology to 'any', if no option is set, all
technologies are allowed again.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-01-19 08:31:17 +01:00
Florian Eckert
af12147f8c modemmanager: add possibilty for setting initial EPS bearer
If no GSM but only 4G is available and a special APN must be used, it
is necessary to set an inital EPS bearer beforehand. If this is not set,
then modem cannot log in and register in the mobile network.

The new option 'init_epsbearer' could be set to the following options.
* none: No init EPS bearer is used and the old one is deleted (default)
* default: Use init EPS bearer with the following config options
  'iptype', 'allowedauth', 'password', 'user' and 'apn' as for the
  connection bearer.
* custom: Other parameters are used that do not match those of the
  default connection bearer. These have an 'init_' prefix and are named
  in the same way as the default connection bearer config options.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-12-04 12:14:56 +01:00
Florian Eckert
7b4d82c58f modemmanager: check modem state before establishing a connection
With this change the following modem 'state' are checked before a
connection attempt setup.
* failed: Stop connection attempt because of sim-missing
* locked: Stop connection attempt if no pincode is set

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-12-04 11:37:06 +01:00
Oliver Sedlbauer
074741e343 modemmanager: move iface cleanup to wrapper script
If the ModemManager process crashes, the interfaces are not cleaned
up properly because the stop_service method is not called. With this
change, the interfaces are cleaned up both when stopping the service
and during a crash. Therefore it is no longer necessary to perform a
cleanup at the beginning.

Signed-off-by: Oliver Sedlbauer <osedlbauer@tdt.de>
2023-10-30 08:53:29 +01:00
Oliver Sedlbauer
d78505bcfa modemmanager: improve cleanup of ifaces
Change workflow to cleanup interfaces using the sysfscache.
The sysfscache stores the processed sysfs-paths. Using this
instead of mmcli -L, the interfaces can be properly cleaned
up even if, for example, ModemManager crashes and mmcli is
no longer usable.

Signed-off-by: Oliver Sedlbauer <osedlbauer@tdt.de>
2023-10-30 08:53:10 +01:00
Oliver Sedlbauer
01fb59f4e2 modemmanager: check status of report-kernel-event
At mm_report_modem_wait a wait status is set. When attempting to report
an event (via hotplug or during startup) and the DBus is not yet available,
the status in the sysfs cache is set to 'processed' incorrectly, even
if mmcli fails.
This is fixed by aborting the operation and logging an error when
the kernel report fails.

Signed-off-by: Oliver Sedlbauer <osedlbauer@tdt.de>
2023-10-25 09:33:22 +02:00
Oliver Sedlbauer
9ae43c14e8 modemmanager: remove sysfscache after dbus ready
The mm_report_events_from_cache method is called during the startup and
informs the ModemManager of kernel events. Additionally, hotplug scripts
inform the ModemManager of kernel events. Processed events are stored in
the sysfs cache. It is possible for a hotplug script to write to the
sysfs cache while the mm_report_events_from_cache method is still waiting
for the ModemManager to be available on the bus during startup.
This could lead to a misbehavior where modems are not recognized.
To ensure a clean state on startup, the sysfs cache is cleared after the
ModemManager is available, ensuring reliable processing of kernel events.

Signed-off-by: Oliver Sedlbauer <osedlbauer@tdt.de>
2023-10-25 09:33:22 +02:00
Florian Eckert
5c63540762 Merge pull request #21993 from osedl/pr/20230901-modemmanager-hardcoded-proto
modemmanager: Remove hardcoded proto check
2023-09-27 13:39:02 +02:00
Oliver Sedlbauer
29590e5d6d modemmanager: Remove hardcoded proto check
Modified the code to correctly determine modem availability based on the
sysfs path provided in the 'device' option, instead of relying  on the
'proto' value. This ensures proper configuration for custom-made protos
that do not match the "modemmanager" identifier.

Signed-off-by: Oliver Sedlbauer <osedlbauer@tdt.de>
2023-09-01 14:07:05 +02:00
Oliver Sedlbauer
ac806e9921 modemmanager: Fix Permission Denied error
The proto_send_update function is sending a notification to netifd
during the teardown section. However, netifd filters link update
notifications executed during teardown, as indicated here:
https://git.openwrt.org/?p=project/netifd.git;a=blob;f=proto-shell.c#l515
This was leading to a Permission Denied error due to its behavior,
making proto_send_update ineffective during teardown.

To address the issue, the proto_send_update function has been removed
from the teardown section. This prevents the Permission Denied error
while ensuring proper operation during teardown.

Additionally, in the 10-report-down helper script, a check has been
implemented to determine if the interface is already down. This check
is crucial to avoid triggering a Permission Denied error, especially
in cases where netifd is already aware of a controlled ifdown operation.

Signed-off-by: Oliver Sedlbauer <osedlbauer@tdt.de>
2023-09-01 13:46:45 +02:00
Florian Eckert
015106346c modemmanager: add setting for allowed and preferred mode
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-08-09 14:13:06 +02:00
Florian Eckert
5fa043000f modemmanager: remove unneeded teardown error reporting
Teardown error reporting is not needed, bacause it overrides init error
reporting.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-08-09 14:10:25 +02:00
Florian Eckert
dbf23705c5 modemmanager: fix white spaces
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-08-09 14:10:20 +02:00
Florian Eckert
89391d4213 modemmanager: improve 'simple connection' option handling
The line to generate the argument list for 'simple connect' is quite
long and is not maintainable. To improve the handling a function
'append_param' was added for appending the 'simple connect' options.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-07-24 13:46:39 +02:00
Francisco Jose Alvarez
7ba2c969b2 modemmanager: Adding support for 'allow_roaming' option
Signed-off-by: Francisco Jose Alvarez <francisco.alvarez@galgus.net>
* Update commit head
* Rebase patch to the latest changes
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-07-24 12:57:39 +02:00
Florian Eckert
2f00e4b8d7 modemmanger: add missing proto_init_update in teardown
Inform netifd with missing 'proto_update', that the interface is not
up anymore.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-07-24 09:42:12 +02:00