Skip to content

fm350gl: parse +CGCONTRDP leniently - #36

Open
pjeweb wants to merge 2 commits into
CERALIVE:mainfrom
openstreambox:osb/upstream/fm350gl-cgcontrdp
Open

pjeweb wants to merge 2 commits into
CERALIVE:mainfrom
openstreambox:osb/upstream/fm350gl-cgcontrdp

Conversation

@pjeweb

@pjeweb pjeweb commented Nov 23, 2026 •

Copy link
Copy Markdown

Affected repo & language: modem-stack · C (ModemManager patch 0001)

What

This fixes FM350-GL data connections on T-Mobile US networks. The module answers +CGCONTRDP with an empty bearer id, and the generic ModemManager parser that patch 0001 uses rejects that answer. So the first connection fails right after +CGACT has activated the attach context, every retry then fails with +CME ERROR: 5847, and the modem never comes up on that carrier.

  • The fm350gl bearer parses +CGCONTRDP itself: lines matched by cid and address family, an empty bearer id, IPv6 in dotted decimal, quoted fields that contain commas, the MTU, and the older layout with a separate subnet field.
  • IPv4 DNS comes from the IPv4 line and IPv6 DNS from the IPv6 line. A malformed line is skipped, so it can't hide a good line for the other family.
  • An answer without a usable line only logs a warning, because +CGPADDR has already given the address (IPv4 then falls back to a /32 with the address as gateway and no DNS). An error answer, cancellation or timeout still fails the connection, as before.

Why

In my tests on an FM350-GL (firmware 81600.0000.00.29.18.01, USB RNDIS) with a SIM on T-Mobile US, ModemManager picks the attach context (cid 0). +CGACT=1,0 and +CGPADDR=0 succeed with an IPv4 and an IPv6 address, then +CGCONTRDP=0 returns +CGCONTRDP: 0,,"wholesale",... with the bearer id left empty, one line per IP family. The parser requires a number there and fails with "Couldn't match +CGCONTRDP response". On every retry ModemManager rewrites the attach context's PDP type and activates it again, and the module refuses each with 5847. It happened the same way on every boot. On Verizon, +CGCONTRDP=<cid> came back with the bearer id filled in my captures, which is why this showed up on T-Mobile first.

BELABOX's original plugin split this answer on commas and never needed the bearer id. The 1.24 forward-port lost that when it switched to the generic parser, so this restores what the carried plugin did. The fix is folded into patch 0001, the same way the earlier ATZ0 fix was, so the series stays at three patches. Its DEP-3 header and the ADR describe the regression.

How to verify

Commands and results
  • Apply the series to the pinned modemmanager_1.24.2.orig.tar.xz (sha256 from upstream-pins.yaml) and build in Debian trixie with meson setup -Dtests=true, then meson test: 32 of 32 pass, with no compiler warnings. test-plugin-fm350gl has 18 cases, including the T-Mobile and Verizon answers as captured (addresses replaced with documentation ranges), the older separate-subnet layout, and a malformed line next to a good one. The same test is clean under ASan and UBSan.
  • Before the change: adding the T-Mobile line to test_cgcontrdp_response in src/tests/test-modem-helpers.c on the current series fails with "Couldn't match +CGCONTRDP response", the same error the module produces in the field.
  • packaging/ci/contract.sh passes. The new FM350 contract check fails against the current patch.
  • On hardware (FM350-GL, firmware 81600.0000.00.29.18.01, T-Mobile US SIM, this series built for arm64): the first connection after boot came up on attempt 1 from the two-line answer, with a static IPv4 /32, the reported IPv4 and IPv6 DNS and MTU 1436. DNS and HTTPS over IPv4 worked through the RNDIS interface. After a USB re-enumeration it reconnected on the first attempt. Two disconnect and reconnect cycles with an unchanged profile were not refused with 5847: +CGACT=0,0 and the next +CGACT=1,0 both answered OK. One of those re-activations was granted IPv6 only, which parsed fine; the other got IPv4 and IPv6 again.

Risks

The change only affects the FM350-GL USB/RNDIS plugin's IP setup. On networks where +CGCONTRDP already parsed, the new parser reads the same fields. If it can't use an answer, the connection still comes up with the +CGPADDR address and no DNS rather than failing. The network may grant IPv6 only on a re-activation, as it did once in my test; that is up to the carrier and outside the plugin. Rollback is reverting these commits.


Checklist

  • Docs updated if behavior or structure changed (ADR and patch DEP-3 header)
  • User docs (Rule G): no user-visible change
  • Started from updated main; branch rebased on latest canonical branch (Rule B)
  • Rule D local-scratch reference check passes for tracked files
  • Tests pass; QA evidence above

On T-Mobile US the FM350 answers +CGCONTRDP with an empty bearer id. The
generic parser the forward-port switched to requires a number there, so
every first connection failed after +CGACT had activated the attach
bearer. Every retry was then refused with CME error 5847, because that
context was still active, until the module was reset.

The bearer now parses the answer itself, as BELABOX's plugin did: lines
by cid and address family, dotted-decimal IPv6, quoted fields with
commas, the MTU, and the older layout with a separate subnet field. IPv4
and IPv6 DNS come from their own lines and a malformed line is skipped.
An answer without a usable line only logs a warning, since +CGPADDR
already gave the address; an error answer, cancellation or timeout still
fails the connection.

The change is folded into patch 0001, so the series stays at three
patches. The patch contract now also requires the bearer's own parser
and its empty-bearer-id test.
The +CGCONTRDP fix connected on T-Mobile US on the first attempt, and two
disconnect and reconnect cycles with an unchanged profile were not refused
with CME error 5847. The ADR and the MR draft no longer list the hardware
check as pending.
@pjeweb

pjeweb commented Nov 23, 2026

Copy link
Copy Markdown
Author

I tested this on hardware now: an FM350-GL on firmware 81600.0000.00.29.18.01 with a T-Mobile US SIM, running this series built for arm64. The first connection after boot came up on attempt 1, and DNS and HTTPS over IPv4 worked. Two disconnect and reconnect cycles were not refused with 5847. I added a docs commit that records this in the ADR and the MR draft, and updated the description.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant