Skip to content

docs: add_local_rport() also covers locally generated requests [skip ci] - #4253

Merged
bogdan-iancu merged 1 commit into
OpenSIPS:masterfrom
denys-i-didww:docs/add-local-rport-in-local-route
Sep 10, 2026
Merged

docs: add_local_rport() also covers locally generated requests [skip ci]#4253
bogdan-iancu merged 1 commit into
OpenSIPS:masterfrom
denys-i-didww:docs/add-local-rport-in-local-route

Conversation

@denys-i-didww

Copy link
Copy Markdown
Contributor

Summary

The add_local_rport() entry in the core function reference describes the behaviour as it
was before 2022. It says the function "affects only the current processed request", which
reads as relayed traffic only, and a script author looking for a way to put rport in a
request OpenSIPS generates itself finds nothing on the page to say it is possible.

It has been possible since 22fd176 and its three siblings, 14 September 2022, which
taught run_local_route() to rebuild the Via when FL_FORCE_LOCAL_RPORT is set. This adds
one sentence saying so.

Details

add_local_rport() sets FL_FORCE_LOCAL_RPORT (core_cmds.c:1098-1101) and is exported
for ALL_ROUTES (core_cmds.c:251-253), LOCAL_ROUTE included. Two places act on the
flag:

  • msg_translator.c:2236, when building the Via for a request being relayed;
  • modules/tm/uac.c:226 and :265, when t_uac_prepare() has run local_route
    (uac.c:558) and the script set the flag on a request TM generated itself.

The second is the one the page does not mention, and it is not obscure — it is the fix
Bogdan wrote for #2833, where the reporter had already tried both force_rport() and
add_local_rport() and reported that neither worked. It shipped to 3.1, 3.2, 3.3 and
master, so every branch since carries it, but the documentation was not updated with it.

#797, open since 2016 and still the first thing a search finds for this, describes the
answer as an unmerged patch against assemble_via(). Nothing points a reader from there to
what the software actually does today.

Reproduced

Built from master and from 4.0, uac_registrant configured against a local listener,
the REGISTER taken off the wire with tcpdump. One variable — the presence of the
local_route block:

Branch Configuration Via of the REGISTER
master as shipped …;branch=z9hG4bK03a9.27f11ca.0
master local_route { add_local_rport(); } …;branch=z9hG4bKd679.b4e44786.0;rport
4.0 as shipped …;branch=z9hG4bKe37d.06470256.0
4.0 local_route { add_local_rport(); } …;branch=z9hG4bK78a4.928f4166.0;rport

End to end, the same three lines are what let a registration complete through a symmetric
NAT: with them the registrar's 200 OK comes back to the port it observed
(received=…;rport=…) instead of to the one the Via advertises, and uac_registrant
reaches REGISTERED_STATE. Without them the REGISTER goes out, no answer arrives, and
nothing is logged on either side.

Solution

One sentence under add_local_rport(), naming local_route and linking to it, with
uac_registrant as the example of a request OpenSIPS generates itself — and a second
example block showing the form, since the one already there shows only the relayed case:


local_route {
    add_local_rport();
}

Two examples under one entry is the layout subscribe_event() and exit() already use on
this page. Documentation only, no behaviour change.

Compatibility

None affected. The behaviour being documented has been in every branch since 2022-09-14;
only the page was behind.


AI assistance disclosure. This change and its wording were produced with AI assistance.
Every item was checked against the source before submission:

  • the flag and the export — core_cmds.c:1098-1101 and :251-253, ALL_ROUTES;
  • both code paths that consume it — msg_translator.c:2236 for relayed requests,
    modules/tm/uac.c:226 and :265 for locally generated ones, reached through
    run_local_route() at uac.c:558;
  • the commit and its backports — git log -S FL_FORCE_LOCAL_RPORT -- modules/tm/uac.c
    returns 22fd176, 570c0aa, fbaef96 and c85d93c, all dated 2022-09-14, and
    git branch --contains places them on 3.1, 3.2, 3.3 and master;
  • that the page never mentions it — the whole add_local_rport() section is the two
    sentences quoted above plus the example;
  • the four rows in the table were run, not inferred, with the REGISTER captured on the
    wire rather than read from a log;
  • the link target resolves — docs/manual/../../modules/uac_registrant/README.md exists,
    and ../../modules/*/README.md is the form already used in Modules.md and
    Interface-MI.md.

The entry describes the behaviour as it was before 22fd176 and its
three siblings (2022-09-14), which taught run_local_route() to rebuild
the Via when FL_FORCE_LOCAL_RPORT is set. Since then the function works
from local_route for requests OpenSIPS generates itself, not only for
the ones it relays - which is what OpenSIPS#2833 asked for and what OpenSIPS#797, still
open, describes as needing a patch.

Adds the sentence and a second example showing the local_route form,
following the two-example layout subscribe_event() already uses.

Documentation only.
@bogdan-iancu

Copy link
Copy Markdown
Member

@denys-i-didww , the original doc seems clear to me - the rport is added to the VIA constructed by OpenSIPS. And yes, the locally generated request also have such a VIA...
But more docs never killed anyone :)

@bogdan-iancu
bogdan-iancu merged commit 0a33489 into OpenSIPS:master Sep 10, 2026
@bogdan-iancu bogdan-iancu self-assigned this Sep 10, 2026
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.

2 participants