### Description
The R-URI is not un-masked/update by Kamailio topos module if the BYE message is received later than in 3 minutes after dialog begin.
We are using 5.1.4 plus the patch for 302 message on top, but tried also with topos/topos_redis from master, same result.
### Troubleshooting
for keys like [d:z:atpsh-5b619dee-5ca4-441] topos is using branch timeout value, default being 3 minutes, so if a BYE message arrives later than branch timeout expiry the records are deleted and the R-URI is not updated. The new header being Route and P-SR-XUID are still added as I can see from the debug log, but BYE relayed by kamailio contains improper R-URI user atpsh-5b619dee-5ca4-441.
I've tested this using automated shorter calls because we don't need to wait 3 minutes to notice that TTL is being set improperly. When checking the debug I noticed that tps_redis_end_dialog() is called here, despite the BYE was not received yet:
Aug 1 14:59:03 sp1 lb[23716]: DEBUG: topos [tps_msg.c:182]: tps_add_headers(): adding to headers(1) - [Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bK4c5e.5b0c6948caefcd8ffb1d106989768f80.0#015#012]
Aug 1 14:59:03 sp1 lb[23716]: DEBUG: topos [tps_msg.c:182]: tps_add_headers(): adding to headers(0) - [Contact: <sip:btpsh-5b619dee-5ca4-441@127.0.0.1>#015#012]
Aug 1 14:59:03 sp1 lb[23716]: DEBUG: topos_redis [topos_redis_storage.c:1381]: tps_redis_end_dialog(): updated on end the dialog record for [d:z:atpsh-5b619dee-5ca4-441] with argc 6
Aug 1 14:59:03 sp1 lb[23716]: DEBUG: topos_redis [topos_redis_storage.c:1412]: tps_redis_end_dialog(): expire set on branch record for [d:z:atpsh-5b619dee-5ca4-441] with argc 3
This matches the EXPIRES command time in the output of redis-cli monitor:
1533128343.178930 [24 127.0.0.1:48634] "HGETALL" "d:z:atpsh-5b619dee-5ca4-441"
1533128343.180122 [24 127.0.0.1:48634] "HMSET" "d:z:atpsh-5b619dee-5ca4-441" "rectime" "1533128343" "iflags" "0"
1533128343.180565 [24 127.0.0.1:48634] "EXPIRE" "d:z:atpsh-5b619dee-5ca4-441" "180"
Is it expected that tps_redis_end_dialog is called at all, changing the expiry and iflag?
#### Reproduction
Make a call with topos, ndb_redis and topos_redis modules loaded.
In our case, the call traverses the kamailio-lb instance twice, because there is a sems in between.
#### Debugging Data, log messages, traces
will be provided as an attachment
[dumps.tar.gz](https://github.com/kamailio/kamailio/files/2249809/dumps.tar.…
### Additional Information
version: kamailio 5.1.4 (x86_64/linux)
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 6.3.0
* **Operating System**:
Linux sp1 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1608
<!-- 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 -->
This is an implementation of sec-agree used in IMS with IPSec. It's not a complete sec-agree implementation, only the flows used by IMS. The code is usable, but needs a few improvements, which I plan to push in the near future. **My work is based on the implementation in OpenIMSCore.**
For IPSec implementation the XFRM framework from the Linux kernel is used. Security association (SA) and Policies creation/removal is performed via netlink messages. For this reason the module depends on libmnl (a minimalistic netlink library).
As XFRM is Linux specific, the code is not portable and can't be used on operating system different from Linux. The code will not compile on *BSDs too. However all platform specific code resides in ipsec.c so support for other OSes/IPSec implementations can be added relatively easy.
The README file, which is commited is generated from docs dir with xsltproc.
Issues I still work on:
- Kamailio must be run as root in order to be able to send netlink messages and create XFRM SAs and Policies.
- SAs and Policies are not deleted on Kamailio startup and shutdown.
- According to the current contact implementation in the PCSCF modules (adn the 3GPP specs) the IPSec tunnel should be created on two steps. Initial parameters should be saved in security_tmp and on confirmation - in security. At the moment everything remains in security.
As this is my first more serious contribution to the project, all kinds of feedback is highly appreciated :)
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1605
-- Commit Summary --
* ims_ipsec_pcscf: sec-agree implementation for IMS
-- File Changes --
A src/modules/ims_ipsec_pcscf/Makefile (20)
A src/modules/ims_ipsec_pcscf/README (244)
A src/modules/ims_ipsec_pcscf/cmd.c (585)
A src/modules/ims_ipsec_pcscf/cmd.h (6)
A src/modules/ims_ipsec_pcscf/doc/Makefile (4)
A src/modules/ims_ipsec_pcscf/doc/ims_ipsec_pcscf.xml (88)
A src/modules/ims_ipsec_pcscf/doc/ims_ipsec_pcscf_admin.xml (231)
A src/modules/ims_ipsec_pcscf/ims_ipsec_pcscf_mod.c (227)
A src/modules/ims_ipsec_pcscf/ipsec.c (386)
A src/modules/ims_ipsec_pcscf/ipsec.h (24)
A src/modules/ims_ipsec_pcscf/run_spi_list_tests.sh (4)
A src/modules/ims_ipsec_pcscf/spi_gen.c (87)
A src/modules/ims_ipsec_pcscf/spi_gen.h (16)
A src/modules/ims_ipsec_pcscf/spi_list.c (123)
A src/modules/ims_ipsec_pcscf/spi_list.h (29)
A src/modules/ims_ipsec_pcscf/spi_list_tests.c (292)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1605.patchhttps://github.com/kamailio/kamailio/pull/1605.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1605