[kamailio/kamailio] topos: add handle_unmask_miss modparam (PR #4813)
Use P-TPS-Owner header hing, when unmaks miss happens. Always remove all P-TPS-Owner headers upon topos receiving a message, to avoid spoofing. <!-- Kamailio Pull Request Template --> <!-- IMPORTANT: - for detailed contributing guidelines, read: https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md - pull requests must be done to master branch, unless they are backports of fixes from master branch to a stable branch - backports to stable branches must be done with 'git cherry-pick -x ...' - code is contributed under BSD for core and main components (tm, sl, auth, tls) - code is contributed GPLv2 or a compatible license for the other components - GPL code is contributed with OpenSSL licensing exception --> #### Pre-Submission Checklist <!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply --> <!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above--> <!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list --> - [X] Commit message has the format required by CONTRIBUTING guide - [X] Commits are split per component (core, individual modules, libs, utils, ...) - [X] Each component has a single commit (if not, squash them into one commit) - [X] LLM/AI Coding Assistants were involved in creating the C code or other included content - [X] Code is formatted with `clang-format` using the config file `.clang-format` from source code folder - [X] No commits to README files for modules (changes must be done to docbook files in `doc/` subfolder, the README file is autogenerated) #### Type Of Change - [ ] Small bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds new functionality) - [ ] Breaking change (fix or feature that would change existing functionality) #### Checklist: <!-- Go over all points below, and after creating the PR, tick the checkboxes that apply --> - [ ] PR should be backported to stable branches - [X] Tested changes locally - [ ] Related to issue #XXXX (replace XXXX with an open issue number) #### Description <!-- Describe your changes in detail --> When topos used with topos_htable storage, races can happen between: SIP ACK of initial INVITE, roamed to different DMQ cluster node vs KDMQ sync of topos_dialog => sometimes SIP ACK can be faster and topos on the roamed node has no idea where to forward to. Fix this problem by always forwarding to the "owner", that already has the routing info (the one that sent the KDMQ sync for topos_dialog) You can view, comment on, or merge this pull request online at: https://github.com/kamailio/kamailio/pull/4813 -- Commit Summary -- * topos: add handle_unmask_miss modparam -- File Changes -- M src/modules/topos/doc/topos_admin.xml (52) M src/modules/topos/topos_mod.c (2) M src/modules/topos/tps_msg.c (80) -- Patch Links -- https://github.com/kamailio/kamailio/pull/4813.patch https://github.com/kamailio/kamailio/pull/4813.diff -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813@github.com>
henningw left a comment (kamailio/kamailio#4813) Thanks for the PR. A quick note on the docs, this should be probably improved: ``` <emphasis>P-TPS-Owner</emphasis> is a topos-internal header; when this parameter is enabled, any copy arriving from the wire is stripped on the receiving path, so the value read by the configuration is always the one topos generated locally. ``` Not sure what is meant with "copy" in this context. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-4913978400 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c4913978400@github.com>
@stefan-mititelu-idt commented on this pull request.
@@ -1040,6 +1078,11 @@ int tps_request_received(sip_msg_t *msg, int dialog) return 0; }
+ /* P-TPS-Owner is a topos-internal hint; remove it from the received SIP */ To avoid any possible spoofed "P-TPS-Owner" headers due to topos skipped for various methods/reasons, this removal should be done way earlier in the code, and SIP msg buffer needs update if any removal happened. Will update this PR. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#pullrequestreview-4786421481 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/review/4786421481@github.com>
miconda left a comment (kamailio/kamailio#4813) Does this PR still need updates? Plus resolving a conflict now, probably after merging other PRs ... -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-5177581728 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c5177581728@github.com>
github-actions[bot] left a comment (kamailio/kamailio#4813) This PR is stale because it has been open 6 weeks with no activity. Remove stale label or comment or this will be closed in 2 weeks. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-5693911691 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c5693911691@github.com>
stefan-mititelu-idt left a comment (kamailio/kamailio#4813) Not stale.. will update it probably next week. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-5694009258 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c5694009258@github.com>
@stefan-mititelu-idt pushed 2 commits. 1df6e0b8755da1a0a9a8088318705d7447b17ce8 topos: add handle_unmask_miss modparam 52b044ac10a1f6515e213f3456c1362bc5043b09 topos: remove all internal headers on receiving -- View it on GitHub: https://github.com/kamailio/kamailio/pull/4813/changes/3d611c31677a27f368c93... You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/before/3d611c31677a27f368c93f2ceafd7529e9827757/after/52b044ac10a1f6515e213f3456c1362bc5043b09@github.com>
@stefan-mititelu-idt pushed 1 commit. b45cf825194de39a8b45037075c73485fae2f539 topos: remove all received internal headers -- View it on GitHub: https://github.com/kamailio/kamailio/pull/4813/changes/52b044ac10a1f6515e213... You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/before/52b044ac10a1f6515e213f3456c1362bc5043b09/after/b45cf825194de39a8b45037075c73485fae2f539@github.com>
henningw left a comment (kamailio/kamailio#4813) @stefan-mititelu-idt You have done some updates, is this PR ready for review and later merge from your side? -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-5887509857 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c5887509857@github.com>
@stefan-mititelu-idt pushed 1 commit. 8724b4e2619db436f3b86a5fab0e52bbb73b58c5 topos: remove all received internal headers -- View it on GitHub: https://github.com/kamailio/kamailio/pull/4813/changes/b45cf825194de39a8b450... You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/before/b45cf825194de39a8b45037075c73485fae2f539/after/8724b4e2619db436f3b86a5fab0e52bbb73b58c5@github.com>
stefan-mititelu-idt left a comment (kamailio/kamailio#4813) @henningw Hello! Yes, ready for review now. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-5888469271 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c5888469271@github.com>
@henningw commented on this pull request.
Thanks, looks good. Just two smaller remarks for the header checking and the log msg added.
> + int nnames = 0;
+ hdr_field_t *hf;
+ struct lump *l;
+ int i;
+ int n = 0;
+
+ names[nnames++] = &_sr_hname_xuuid;
+ names[nnames++] = &_sr_hname_xbranch;
+ if(_tps_handle_unmask_miss) {
+ names[nnames++] = &_tps_owner_hname;
+ }
+
+ for(hf = msg->headers; hf; hf = hf->next) {
+ for(i = 0; i < nnames; i++) {
+ if(hf->name.len == names[i]->len
+ && strncasecmp(hf->name.s, names[i]->s, hf->name.len)
It would be probably better to use cmp_hdrname_str(..) from core for this.
> @@ -1129,6 +1219,27 @@ int tps_request_received(sip_msg_t *msg, int dialog)
} else {
LM_DBG("r-uri updated to: [%.*s]\n", nuri.len, nuri.s);
}
+ } else if(_tps_handle_unmask_miss
+ && (mtsd.a_uuid.len > 0 || mtsd.b_uuid.len > 0)) {
+ /* unmask-miss: dialog loaded but the near contact is empty */
+ LM_WARN("[TOPOS-UNMASK-MISS] call_id=%.*s method=%.*s cseq=%.*s "
Rephrase the log message to not use this capital letters and brackets, similar as existing logging
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/4813#pullrequestreview-5352259579
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/4813/review/5352259579@github.com>
@henningw commented on this pull request.
> + int nnames = 0;
+ hdr_field_t *hf;
+ struct lump *l;
+ int i;
+ int n = 0;
+
+ names[nnames++] = &_sr_hname_xuuid;
+ names[nnames++] = &_sr_hname_xbranch;
+ if(_tps_handle_unmask_miss) {
+ names[nnames++] = &_tps_owner_hname;
+ }
+
+ for(hf = msg->headers; hf; hf = hf->next) {
+ for(i = 0; i < nnames; i++) {
+ if(hf->name.len == names[i]->len
+ && strncasecmp(hf->name.s, names[i]->s, hf->name.len)
Compare e.g. to remove_hf_f(..) in textops module
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/4813#discussion_r4133251038
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/4813/review/5352312900@github.com>
@stefan-mititelu-idt pushed 1 commit. af87093ab1f729225f1f36636debe16f18e3fa2d topos: remove all received internal headers -- View it on GitHub: https://github.com/kamailio/kamailio/pull/4813/changes/8724b4e2619db436f3b86... You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/before/8724b4e2619db436f3b86a5fab0e52bbb73b58c5/after/af87093ab1f729225f1f36636debe16f18e3fa2d@github.com>
stefan-mititelu-idt left a comment (kamailio/kamailio#4813) Thanks for the review! I fixed them and force-pushed last commit. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-5892497933 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c5892497933@github.com>
henningw left a comment (kamailio/kamailio#4813) Thank you. There is also one new snprintf (in tps_request_received) where the function error is not explicitly handled. Its not causing any errors later on, due to the added return checks. But not sure if you want to add an LM_ERR there or so. Otherwise lets wait a bit for eventual other feedback before merging it. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-5893222328 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c5893222328@github.com>
miconda left a comment (kamailio/kamailio#4813) Looking at the name of the new parameter, it is rather unclear: is it about handling the case when the topos dialog is not found on the local K instance? If yes, maybe the parameter can be name `dlg_mode`, and when is 0 (default) it handles only locally-found dialogs, if set to 1, behaves like in this PR -- this is matching better the naming style for other parameters and also leaves it open for extensions in the future. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-6044833949 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c6044833949@github.com>
stefan-mititelu-idt left a comment (kamailio/kamailio#4813) Yes, the topos dialog data structure can be only partially synced at a given time. The flag 1 of "dlg_mode" could handle these case of incomplete topos dialog data, by forwarding to the original "owner", that is 100% to have it complete. Will update PR. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-6054931812 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c6054931812@github.com>
@stefan-mititelu-idt pushed 1 commit. f25c633802f26f687bb2760269169954025b9b73 topos: Add dlg_mode. Remove all received internal headers. -- View it on GitHub: https://github.com/kamailio/kamailio/pull/4813/changes/af87093ab1f729225f1f3... You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/before/af87093ab1f729225f1f36636debe16f18e3fa2d/after/f25c633802f26f687bb2760269169954025b9b73@github.com>
miconda left a comment (kamailio/kamailio#4813) Thanks! -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#issuecomment-6151590253 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/c6151590253@github.com>
Merged #4813 into master. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/4813#event-33157633165 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/pull/4813/issue_event/33157633165@github.com>
participants (4)
-
Daniel-Constantin Mierla -
github-actions[bot] -
Henning Westerholt -
Stefan Mititelu