Skip to content

mmdbus: improve eSIM detection using EID and handle missing slot paths#5697

Open
milan-zededa wants to merge 1 commit intolf-edge:masterfrom
milan-zededa:better-esim-detection
Open

mmdbus: improve eSIM detection using EID and handle missing slot paths#5697
milan-zededa wants to merge 1 commit intolf-edge:masterfrom
milan-zededa:better-esim-detection

Conversation

@milan-zededa
Copy link
Contributor

Description

Without proper eSIM detection, EVE cannot identify that the active slot is an eSIM and remains stuck on the unsupported eSIM slot instead of automatically switching to a physical SIM slot.

ModemManager often fails to report SIM slot types (SIMPropertyType returns unspecified), making it impossible to distinguish eSIM from physical SIM. Improve detection by querying the EID (eUICC Identifier) -- only eSIM chips carry one, so its presence reliably identifies an eSIM.

Additionally, ModemPropertySIMSlots returns empty D-Bus paths for slots with no SIM or no active eSIM profile. For the currently active slot, fall back to ModemPropertySIM which often still provides a valid object even when the slot array entry is empty.

Unify SIM presence detection for unknown and physical SIM types: use the slot array path (hasSlotPath) as the common presence indicator instead of checking ICCID for unknown types separately.

In preferPhysSimOverESim, prefer a confirmed physical slot over an unspecified-type candidate. When the active slot is a detected eSIM, it is very unlikely for a modem to have multiple eUICCs, so the remaining slots with unknown type are almost certainly physical -- but only used as a fallback.

How to test and validate this PR

Onboard device with a cellular modem that has both an eSIM (eUICC) and a physical SIM slot.
At first, do not attach any network configuration to the cellular modem.
SSH into the node, enter the wwan container and intentionally set the eSIM slot as active:

mmcli -m <modem-index> --set-primary-sim-slot=<esim-slot-number>

Next, attach proper network configuration to the cellular adapter and after a while confirm that EVE automatically
changed active SIM slot back to the physical one. Use mmcli -m <modem-index> and check the SIM section (look for (active) flag).

EVE will also log a message informing about this automatic SIM slot switch:

2026-03-21T08:52:24.885309667Z;wwan.out;{"file":"/mmagent/mmdbus/client.go:1678","func":"github.com/lf-edge/eve/pkg/wwan/mmagent/mmdbus.(*Client).preferPhysSimOverESim","level":"info","msg":"Automatically changing primary SIM slot for modem /org/freedesktop/ModemManager1/Modem/0 from eSIM to 1","pid":39,"source":"wwan","time":"2026-03-21T08:52:24.885007547Z"}

Changelog notes

Improved eSIM detection: query EID (eUICC Identifier) to reliably identify eSIM slots when ModemManager reports SIM type as unspecified. Without this, EVE could not recognize the active slot as eSIM and remained stuck on the unsupported eSIM slot instead of automatically switching to a physical SIM.

PR Backports

  • 16.0-stable: to be backported
  • 14.5-stable: to be backported
  • 13.4-stable: to be backported

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device
  • I've tested my PR on arm64 device
  • I've written the test verification instructions
  • I've set the proper labels to this PR
  • I've checked the boxes above, or I've provided a good reason why I didn't check them.

Without proper eSIM detection, EVE cannot identify that the active slot is
an eSIM and remains stuck on the unsupported eSIM slot instead of
automatically switching to a physical SIM slot.

ModemManager often fails to report SIM slot types (SIMPropertyType returns
"unknown"/unspecified), making it impossible to distinguish eSIM from physical
SIM. Improve detection by querying the EID (eUICC Identifier) — only eSIM
chips carry one, so its presence reliably identifies an eSIM.

Additionally, ModemPropertySIMSlots returns empty D-Bus paths for slots with
no SIM or no active eSIM profile. For the currently active slot, fall back to
ModemPropertySIM which often still provides a valid object even when the slot
array entry is empty.

Unify SIM presence detection for unknown and physical SIM types: use the
slot array path (hasSlotPath) as the common presence indicator instead of
checking ICCID for unknown types separately.

In preferPhysSimOverESim, prefer a confirmed physical slot over an
unspecified-type candidate. When the active slot is a detected eSIM, it is
very unlikely for a modem to have multiple eUICCs, so the remaining slots
with unknown type are almost certainly physical — but only used as a fallback.

Signed-off-by: Milan Lenco <milan@zededa.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@milan-zededa milan-zededa self-assigned this Mar 21, 2026
@milan-zededa milan-zededa added bug Something isn't working stable Should be backported to stable release(s) labels Mar 21, 2026
@codecov
Copy link

codecov bot commented Mar 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.45%. Comparing base (2281599) to head (4569d82).
⚠️ Report is 350 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5697      +/-   ##
==========================================
+ Coverage   19.52%   29.45%   +9.92%     
==========================================
  Files          19       18       -1     
  Lines        3021     2417     -604     
==========================================
+ Hits          590      712     +122     
+ Misses       2310     1554     -756     
- Partials      121      151      +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@uncleDecart uncleDecart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working stable Should be backported to stable release(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants