Enable registration of pcscf contact callback during download from db location table and inserting pcontact (normally this callback is registered during handling of REGISTER). Refuse REGISTER when pcontact is expired since [0 to 20] seconds. Within this time window a NOTIFY is expected from scscf and in order to avoid race time conditions between scscf and pcscf REGISTER will be refused. Refuse REGISTER when pcontact is expired longer than 20 seconds - send PUBLISH (contact expired) to scscf to trigger NOTIFY. In both REGISTER refused scenarios routing script should reply 500 - Deregister in progress.
<!-- 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] 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) - [ x] 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 --> In case a pcontact found in location db has to be inserted into pcscf cache depending on contact state also callbacks have to be registered for this pcontact. Registering of callback_pcscf_contact_cb is enabled in this module. Handling of contact expiry is usually triggered in the scscf (mem_timer_udomain which runs every 10 secs). Sending of NOTIFY to pcscf may take up to 20 seconds from start of expiry due to timing conditions. To avoid race time conditions between a REREGISTER and the expiry handler state machine in the scscf an approach is chosen to refuse a REREGISTER in time window of 20 seconds after pcontact expiry on the pcscf (thus allowing expiry handling to finish). REREGISTER is refused in this scenario with new return_code -2. In case a REREGISTER arrives at pcscf and the respective pcontact is expired longer than time window of 20 seconds registration also is refused with rc -2 and additionaly PUBLISH is sent to scscf with expiry = 0. The rc -2 shall be handled in register.cfg script as follows:
pcscf_save_pending("location"); switch ($retcode) { case -1: # Missing/wrong Information in REGISTER. send_reply("400", "Information wrong - See log."); exit; break; case -2: # De-Register in Progress, or PUBLISH ongoing due to registration expiry, # or new REGISTER blocked because registration just expired (up to 20sec). append_to_reply("Retry-After: 30\r\n"); send_reply("500", "Deregister in progress - Please try again"); exit; break; }
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3317
-- Commit Summary --
* ims_registrar_pcscf: changes for ul db_mode DB_ONLY
-- File Changes --
M src/modules/ims_registrar_pcscf/ims_registrar_pcscf_mod.c (21) M src/modules/ims_registrar_pcscf/notify.c (4) M src/modules/ims_registrar_pcscf/save.c (37)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3317.patch https://github.com/kamailio/kamailio/pull/3317.diff
@henningw commented on this pull request.
Thanks for the PR. This is a smaller patch, so I just added a few comments, mostly related to formatting. Before merging the module documentation should be extended as well with the new function, its return code and description from the PR.
@@ -142,15 +143,15 @@ inline void pcscf_act_time()
* Exported functions */ static cmd_export_t cmds[] = { - {"pcscf_save", (cmd_function)w_save, 1, save_fixup2, 0,ONREPLY_ROUTE }, + {"pcscf_save", (cmd_function)w_save, 1, save_fixup2, 0,ONREPLY_ROUTE },
Please align the formatting to the existing code, there seems to be some whitespaces/tabs here and also two more places below.
@@ -261,6 +262,8 @@ static int mod_init(void) {
if (bind_usrloc(&ul) < 0) { return -1; } + if (ul.db_mode == DB_ONLY) + ul.register_ulcb_method(NULL, PCSCF_CONTACT_UPDATE, callback_pcscf_contact_cb, NULL);
This can fail according to ims_usrloc_pcscf/ul_callback.c. So the return value should be checked and aborted on error, in a similar ways as the other cases above.
@@ -467,6 +484,20 @@ int save(struct sip_msg* _m, udomain_t* _d, int _cflags) {
goto error; }
+ // skip subscribe, if all contacts have "expires=0" parameter + contact_t *ctct;
Move the contact and also expir parameter definition to the beginning of the function. Not sure why the cast to unsigned int * is needed here? The if (expir) condition also need to be aligned from the formatting.
@petermarianF Any update from your side regarding the comments?
Hi Henning,
sorry for the long delay, I was busy with some urgent fixes on other areas. Yes I already prepared the code changes and hope to do the docu additions also very soon (probably this evenening)
KR, Peter
Von: Henning Westerholt ***@***.***> Gesendet: Montag, 13. Februar 2023 09:31 An: kamailio/kamailio ***@***.***> Cc: Friedrich Peter ***@***.***>; Mention ***@***.***> Betreff: Re: [kamailio/kamailio] ims_registrar_pcscf: changes for ul db_mode DB_ONLY (PR #3317)
@petermarianFhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FpetermarianF&data=05%7C01%7CPeter.Friedrich%40kontron.com%7Cc63b617d0ff041afbf9608db0d9ca024%7C8c9d3c973fd941c8a2b1646f3942daf1%7C0%7C0%7C638118738572839490%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=UymtTEpZzDdsGMizDINIDZMAZzgZ6IGGy5QwWMJocg4%3D&reserved=0 Any update from your side regarding the comments?
- Reply to this email directly, view it on GitHubhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fkamailio%2Fkamailio%2Fpull%2F3317%23issuecomment-1427537554&data=05%7C01%7CPeter.Friedrich%40kontron.com%7Cc63b617d0ff041afbf9608db0d9ca024%7C8c9d3c973fd941c8a2b1646f3942daf1%7C0%7C0%7C638118738572995714%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=pEvueVngHcVaX6qnpX2IGsIFMPCGtU8JI69mHb8k%2Fyc%3D&reserved=0, or unsubscribehttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAO57MQ4RMQRTAKFYGKAVLU3WXHWL5ANCNFSM6AAAAAATG2PSU4&data=05%7C01%7CPeter.Friedrich%40kontron.com%7Cc63b617d0ff041afbf9608db0d9ca024%7C8c9d3c973fd941c8a2b1646f3942daf1%7C0%7C0%7C638118738572995714%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Rp2nFygLhv5qH1fqjychivKnQnO945828jnc%2Bvix%2BIk%3D&reserved=0. You are receiving this because you were mentioned.Message ID: ***@***.***>
@petermarianF pushed 1 commit.
53333d1b946495680142c1c154400716cf975b59 ims_registrar_pcscf: changes for ul db_mode DB_ONLY
@petermarianF commented on this pull request.
@@ -467,6 +484,20 @@ int save(struct sip_msg* _m, udomain_t* _d, int _cflags) {
goto error; }
+ // skip subscribe, if all contacts have "expires=0" parameter + contact_t *ctct;
Moved the new definitions to the beginning of the function and did some formatting
@petermarianF commented on this pull request.
@@ -261,6 +262,8 @@ static int mod_init(void) {
if (bind_usrloc(&ul) < 0) { return -1; } + if (ul.db_mode == DB_ONLY) + ul.register_ulcb_method(NULL, PCSCF_CONTACT_UPDATE, callback_pcscf_contact_cb, NULL);
Added return value check and abort on error
@petermarianF commented on this pull request.
@@ -142,15 +143,15 @@ inline void pcscf_act_time()
* Exported functions */ static cmd_export_t cmds[] = { - {"pcscf_save", (cmd_function)w_save, 1, save_fixup2, 0,ONREPLY_ROUTE }, + {"pcscf_save", (cmd_function)w_save, 1, save_fixup2, 0,ONREPLY_ROUTE },
Removed these formatting changes
@petermarianF commented on this pull request.
@@ -142,15 +143,15 @@ inline void pcscf_act_time()
* Exported functions */ static cmd_export_t cmds[] = { - {"pcscf_save", (cmd_function)w_save, 1, save_fixup2, 0,ONREPLY_ROUTE }, + {"pcscf_save", (cmd_function)w_save, 1, save_fixup2, 0,ONREPLY_ROUTE },
Added some documentation for save_pending function
Hi, is there something else required for closing this pull request ?
@petermarianF no, I will review it one more time during until the end of the week and then apply it its ok.
Merged #3317 into master.