Translating a MAP dialogue when neither side will change version
A partner's served networks abort MT-ForwardSM at MAP v3 and answer it at v2; our SMSC speaks v3. The STP rewrites the application context in flight, and almost everything hard about it was scope.
The STP images start from vendored Osmocom (libosmocore, libosmo-netif, libosmo-sigtran), imported in one commit in April 2025 — 238,016 lines across 1,053 files. Everything since is work on top: 243 of the repository's 249 non-merge commits, about 16,750 lines of C, two deployable variants and a shared base.
The feature is one VTY directive, map-ac-translate, with one profile
(mt-forwardsm-v2-v3). It rewrites shortMsgMT-RelayContext between v3 (mt-forwardSM,
opcode 44) and v2 (forwardSM, opcode 46) — the request downgraded on the way out, the reply
upgraded on the way back.
Per-AS was the wrong granularity
The first version enabled the profile on an application server (one line of VTY). That rewrote everything the AS carried, which was wrong, because the refusal comes from no single place. It starts at the individual served networks behind the transit hop: one serving node answers v3 correctly while its neighbours — addresses from the same assigned range — abort it.
So translation became opt-in per destination (nothing by default). dest-prefix scopes a profile to called-party
global-title prefixes, and a profile with no destination named translates nothing at all.
Prefixes are validated when configured (exactly *, or 1-32 digits), so a partial wildcard is
refused outright instead of accepted and then never matching.
The SCCP hook never ran on one of the two
One of the two STPs has no point code on either cs7 instance. All of its traffic is relayed
by DPC and never enters SCCP routing control, so a translation hooked into SCCP was dead code
there — configured, counted as configured, and never once invoked.
That produced map-ac-translate ... layer (sccp|mtp). The sccp layer acts in SCCP routing
control; mtp acts in the MTP relay path and keeps its own per-instance table of relayed
dialogues. CI now checks that layer mtp is refused on a non-M3UA AS (with the expected reason).
Address hiding bit it from both sides
These STPs replace the originator's point code with their own on the way through
(address-hiding, dialogue TTL 120 seconds). Translation collided with that twice, in opposite
directions.
At layer sccp, translation overwrote the dialogue-entry field address hiding uses to route
replies — so replies to translated dialogues leaked the peer's point code to the SMS-GMSC. It now keeps its own marker (and an entry replaced for the same transaction ID keeps it).
At layer mtp, the reverse: requests translated and replies never did, because address hiding
had already rewritten the originator before the reply arrived. A reply to a dialogue recorded
under the STP's own point code is now matched by transaction ID.
A dialogue is more than its BEGIN
A TC-BEGIN may open a dialogue with no Invoke in it at all (TS 29.002 clause 23.3.1,
segmentation), and it still has to be downgraded. Every mt-forwardSM Invoke in the later
CONTINUE and END messages needs rewriting too — those are the further segments of a multi-part
short message, counted separately as map-ac-xlate:invokes-downgraded.
With two load-sharing STPs the dialogue can arrive split (one leg each): a STP sees the CONTINUE having never seen the BEGIN. The peer's transaction ID is learned from its first CONTINUE only, and after a config change a CONTINUE is matched on both TIDs instead of an END being guessed at.
The bug underneath
SCCP dialogue correlation read entries after freeing them (two call sites, both pre-existing). On CONTINUE the TTL refresh passed pointers into the entry it frees; on END and ABORT, delivery read it after deletion. Both were pre-existing, and both became far more reachable once translation started touching every dialogue on these links.
How you can tell it is working
Four per-AS rate counters, because the failure is silent: map-ac-xlate:downgraded,
:upgraded, :invokes-downgraded, and :dialogs-dropped for dialogues lost to a full
tracking table. A translation that is configured and not firing looks exactly like a peer that
stopped refusing; only counting both tells them apart. The full-table and short-TID conditions
log at most once a minute, not once per message.
make test in the base image runs the three upstream suites and the standalone
TCAP/translation unit tests under ASan and UBSan, in a Dockerfile test stage absent from the
published image. Each variant's make test then starts the real image on the
environment production runs, so an image whose config fails to render or load fails its
build instead of being pushed.
One smaller thing, same shape
Each IP-SM-GW site now has its own M3UA routing context, which has to be set on both ends at
once (SS7_ROUTING_CONTEXT on the node, IPSMGW_RC on the STP, 0 to restore the previous
behaviour). A non-zero context is added to every DATA message the STP sends that AS, and an
ASP Active carrying a context the AS does not have is refused.
The source port is enforced as well, and this is the detail worth carrying away: a node that does not source from the configured port matches no ASP, and its association is dropped with a SHUTDOWN after the COOKIE ACK. From the node's side that is indistinguishable from the STP having no configuration for it at all.