docs: add_local_rport() also covers locally generated requests [skip ci] - #4253
Merged
bogdan-iancu merged 1 commit intoSep 10, 2026
Merged
Conversation
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.
Member
|
@denys-i-didww , the original doc seems clear to me - the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
add_local_rport()entry in the core function reference describes the behaviour as itwas 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
rportin arequest 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 whenFL_FORCE_LOCAL_RPORTis set. This addsone sentence saying so.
Details
add_local_rport()setsFL_FORCE_LOCAL_RPORT(core_cmds.c:1098-1101) and is exportedfor
ALL_ROUTES(core_cmds.c:251-253),LOCAL_ROUTEincluded. Two places act on theflag:
msg_translator.c:2236, when building the Via for a request being relayed;modules/tm/uac.c:226and:265, whent_uac_prepare()has runlocal_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()andadd_local_rport()and reported that neither worked. It shipped to3.1,3.2,3.3andmaster, 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 towhat the software actually does today.
Reproduced
Built from
masterand from4.0,uac_registrantconfigured against a local listener,the REGISTER taken off the wire with
tcpdump. One variable — the presence of thelocal_routeblock:master…;branch=z9hG4bK03a9.27f11ca.0masterlocal_route { add_local_rport(); }…;branch=z9hG4bKd679.b4e44786.0;rport4.0…;branch=z9hG4bKe37d.06470256.04.0local_route { add_local_rport(); }…;branch=z9hG4bK78a4.928f4166.0;rportEnd to end, the same three lines are what let a registration complete through a symmetric
NAT: with them the registrar's
200 OKcomes back to the port it observed(
received=…;rport=…) instead of to the one the Via advertises, anduac_registrantreaches
REGISTERED_STATE. Without them the REGISTER goes out, no answer arrives, andnothing is logged on either side.
Solution
One sentence under
add_local_rport(), naminglocal_routeand linking to it, withuac_registrantas the example of a request OpenSIPS generates itself — and a secondexample block showing the form, since the one already there shows only the relayed case:
Two examples under one entry is the layout
subscribe_event()andexit()already use onthis 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:
core_cmds.c:1098-1101and:251-253,ALL_ROUTES;msg_translator.c:2236for relayed requests,modules/tm/uac.c:226and:265for locally generated ones, reached throughrun_local_route()atuac.c:558;git log -S FL_FORCE_LOCAL_RPORT -- modules/tm/uac.creturns 22fd176, 570c0aa, fbaef96 and c85d93c, all dated 2022-09-14, and
git branch --containsplaces them on 3.1, 3.2, 3.3 and master;add_local_rport()section is the twosentences quoted above plus the example;
wire rather than read from a log;
docs/manual/../../modules/uac_registrant/README.mdexists,and
../../modules/*/README.mdis the form already used inModules.mdandInterface-MI.md.