### Description
While debugging an issue in Kamailio 5.4, I compiled/installed master to see if the issue persists. However, I immediately ran into multiple issues with dialog in master:
#### Using enable_dmq=1
With dmq enabled, I receive the following log lines which did not appear when running 5.4:
```
CRITICAL: dialog [dlg_timer.c:129]: insert_dlg_timer(): Trying to insert a bogus dlg tl=0x7fa0bc21fc80 tl->next=0x7fa0bbf46ba8 tl->prev=0x7fa0bbf46ba8
CRITICAL: dialog [dlg_dmq.c:314]: dlg_dmq_handle_msg(): Unable to insert dlg timer 0x7fa0bc21fc20 [2687:66928]
```
#### Using database
When using database persistence (sqlite and db_mode=3 (SHUTDOWN)), dialogs are not persisted across restarts (which was working in 5.4). There are no obvious log lines, except when I end the call after restarting Kamailio I receive a "unable to find dialog for BYE" message which would be expected if the dialog did not persist.
### Troubleshooting
- I ran the same configuration using 5.4 and neither issue occurred.
- I attempted to identify the troublesome commit by checking out/compiling older commits based on the commit history of the dialog module, but could only go so far back until builds started failing with `module not found: modules/siprepo`. As such I was not able to identify when the behavior changed.
#### Reproduction
DMQ issue: Use dialog module with dmq enabled and start a call that has `dlg_manage();` in the path. My configuration has the following settings:
```
modparam("dmq", "server_address", SERVER_ADDRESS_DMQ)
modparam("dmq", "notification_address", "redacted")
modparam("dmq", "notification_address", "redacted")
modparam("dmq", "num_workers", 6)
modparam("dialog", "default_timeout", 14520)
modparam("dialog", "profiles_with_value", "group")
modparam("dialog", "enable_dmq", 1)
modparam("dialog", "h_id_start", 0)
modparam("dialog", "h_id_step", 16)
```
DB issue: Use dialog module with db enabled. Start a call that has `dlg_manage();` in the path and keep the call open. Observe `kamcmd dlg.list` shows the dialog. Restart kamailio. Observe `kamcmd dlg.list` no longer lists any dialogs. My configuration has the following additional settings:
```
modparam("dialog", "db_url", "sqlite:////kamailio/kamailio.sqlite")
modparam("dialog", "db_mode", 3)
```
### Additional Information
**Kamailio Version**
```
version: kamailio 5.7.0-dev0 (x86_64/linux) f1dcb6
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, 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_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: f1dcb6
compiled on 23:18:23 Aug 15 2022 with gcc 8.3.0```
```
**Operating System**
```
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3218
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3218(a)github.com>
Hi!
SBOM - Software Bill of Materials - often comes up in discussions in my projects. There’s a new working group in the IETF working on it and several other standardization bodies.
A starting point is identification of the license in each source code file with a parseable SPDX identifier.
- Is anyone against adding that to our source code?
- Would it be beneficial for packaging in any way?
I think at some point in the future, a SBOM list in <pick format> will be included in packages, in order to be able to produce a SBOM for the container or the machine.
As we have multiple licenses in the source code it’s important to mark every file correctly.
I can start experimenting with http_client, then work myself around, if the dev community doesn’t scream and argue that it’s a bad thing (TM).
Read more here
- SPDX - a linux foundation project ans ISO standard - https://spdx.dev
- Tags in source code - https://spdx.dev/ids/
Cheers,
/O
Module: kamailio
Branch: master
Commit: 02a04a2b544d16ced3d6e59c4458605419880cfe
URL: https://github.com/kamailio/kamailio/commit/02a04a2b544d16ced3d6e59c4458605…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2022-08-17T10:46:42+02:00
modules: readme files regenerated - usrloc ... [skip ci]
---
Modified: src/modules/usrloc/README
---
Diff: https://github.com/kamailio/kamailio/commit/02a04a2b544d16ced3d6e59c4458605…
Patch: https://github.com/kamailio/kamailio/commit/02a04a2b544d16ced3d6e59c4458605…
---
diff --git a/src/modules/usrloc/README b/src/modules/usrloc/README
index d180968e95..a15bc8c62d 100644
--- a/src/modules/usrloc/README
+++ b/src/modules/usrloc/README
@@ -1113,10 +1113,15 @@ modparam("usrloc", "version_table", 0)
Note: the internal keepalive is for the moment implemented only for
contact records stored in memory.
- Note: it is recommeder to set 'timer_procs' parameter in order to have
+ Note: it is recommended to set 'timer_procs' parameter in order to have
dedicated timer processes for usrloc module and off-load the keepalive
sending process from the core timers.
+ Note: Keepalives will be sent to the IP and port using the transport
+ defined in the âreceivedâ column. If not set, then keepalives will
+ be sent to the AOR using UDP as a default transport. If available, the
+ TCP connection will be re-used for WS, TCP and TLS.
+
Default value is “0 (keepalive disabled)”.
Example 1.50. ka_mode parameter usage
- Fixes GH #3178. Sets TCP connection id for keepalive based on the value in the database
If unset, tcpconn_id will remain 0 and keepalives will work the same as they do today
- Update documentation to clarify when it will use received vs AOR for keepalive
<!-- 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)
- [ ] New feature (non-breaking change which adds new functionality)
- [X] 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
- [X] Related to issue #3178 (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
Updated usrloc module to re-use an active TCP session (if it exists). I marked this breaking only because the current code will use a UDP OPTIONS keepalive method even if the device is registered over TCP. I doubt that's what anyone would be expecting so I think the change is ok.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3219
-- Commit Summary --
* usrloc: re-use TCP connections for keepalive
-- File Changes --
M src/modules/usrloc/dlist.c (4)
M src/modules/usrloc/doc/usrloc_admin.xml (9)
M src/modules/usrloc/ul_keepalive.c (4)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3219.patchhttps://github.com/kamailio/kamailio/pull/3219.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3219
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/3219(a)github.com>
Module: kamailio
Branch: master
Commit: 06f933ad17aac3a3f0f81cf0e0ab04f38cf60993
URL: https://github.com/kamailio/kamailio/commit/06f933ad17aac3a3f0f81cf0e0ab04f…
Author: Andy Brezinsky <andy.brezinsky(a)mitel.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-08-17T10:33:50+02:00
usrloc: re-use TCP connections for keepalive
- Fixes GH #3178. Sets TCP connection id for keepalive based on the value in the database
If unset, tcpconn_id will remain 0 and keepalives will work the same as they do today
- Update documentation to clarify when it will use received vs AOR for keepalive
---
Modified: src/modules/usrloc/dlist.c
Modified: src/modules/usrloc/doc/usrloc_admin.xml
Modified: src/modules/usrloc/ul_keepalive.c
---
Diff: https://github.com/kamailio/kamailio/commit/06f933ad17aac3a3f0f81cf0e0ab04f…
Patch: https://github.com/kamailio/kamailio/commit/06f933ad17aac3a3f0f81cf0e0ab04f…
---
diff --git a/src/modules/usrloc/dlist.c b/src/modules/usrloc/dlist.c
index 252bb8bde07..c0c7cb0009f 100644
--- a/src/modules/usrloc/dlist.c
+++ b/src/modules/usrloc/dlist.c
@@ -114,6 +114,7 @@ int ul_ka_db_records(int partidx)
keys2[5] = &ul_ruid_col;
keys2[6] = &ul_user_col;
keys2[7] = &ul_domain_col;
+ keys2[8] = &ul_con_id_col;
/* where fields */
keys1[0] = &ul_expires_col;
@@ -256,6 +257,9 @@ int ul_ka_db_records(int partidx)
ur.aorhash = ul_get_aorhash(&ur.aor);
ur.contacts = &uc;
+ /* tcpconn_id */
+ uc.tcpconn_id = VAL_INT(ROW_VALUES(row)+8);
+
ul_ka_urecord(&ur);
} /* row cycle */
diff --git a/src/modules/usrloc/doc/usrloc_admin.xml b/src/modules/usrloc/doc/usrloc_admin.xml
index 66dae449130..f2d2001689c 100644
--- a/src/modules/usrloc/doc/usrloc_admin.xml
+++ b/src/modules/usrloc/doc/usrloc_admin.xml
@@ -1317,11 +1317,17 @@ modparam("usrloc", "version_table", 0)
contact records stored in memory.
</para>
<para>
- Note: it is recommeder to set 'timer_procs' parameter in order to have
+ Note: it is recommended to set 'timer_procs' parameter in order to have
dedicated timer processes for usrloc module and off-load the keepalive
sending process from the core timers.
</para>
<para>
+ Note: Keepalives will be sent to the IP and port using the transport
+ defined in the “received” column. If not set, then keepalives will be sent
+ to the AOR using UDP as a default transport. If available, the TCP
+ connection will be re-used for WS, TCP and TLS.
+ </para>
+ <para>
Default value is <quote>0 (keepalive disabled)</quote>.
</para>
<example>
@@ -1780,4 +1786,3 @@ modparam("usrloc", "db_clean_tcp", 1)
</chapter>
-
diff --git a/src/modules/usrloc/ul_keepalive.c b/src/modules/usrloc/ul_keepalive.c
index 8808725849f..ffe37fdc738 100644
--- a/src/modules/usrloc/ul_keepalive.c
+++ b/src/modules/usrloc/ul_keepalive.c
@@ -200,6 +200,7 @@ int ul_ka_urecord(urecord_t *ur)
}
idst.proto = dproto;
idst.send_sock = ssock;
+ idst.id = uc->tcpconn_id;
if(ssock->useinfo.name.len > 0) {
if (ssock->useinfo.address.af == AF_INET6) {
@@ -270,19 +271,16 @@ static int ul_ka_send(str *kamsg, dest_info_t *kadst)
#ifdef USE_TCP
else if(kadst->proto == PROTO_WS || kadst->proto == PROTO_WSS) {
/*ws-wss*/
- kadst->id=0;
return wss_send(kadst, kamsg->s, kamsg->len);
}
else if(kadst->proto == PROTO_TCP) {
/*tcp*/
- kadst->id=0;
return tcp_send(kadst, 0, kamsg->s, kamsg->len);
}
#endif
#ifdef USE_TLS
else if(kadst->proto == PROTO_TLS) {
/*tls*/
- kadst->id=0;
return tcp_send(kadst, 0, kamsg->s, kamsg->len);
}
#endif
<!-- Kamailio Pull Request Template -->
#### 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
- [x] 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:
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [x] Related to issue #3218
#### Description
Per the DB issue in #3218:
I've determined the commit where dialog with db_mode SHUTDOWN stopped working is 1ff86ffceede46c7a67fec92c8319c34c916a545.
This is the change where `PROC_POSTCHILDINIT` was enabled/used.
In dialog.c `child_init()`, there is code that resets the DB mode to NONE if not running in the main process:
```c
/* in DB_MODE_SHUTDOWN only PROC_MAIN will do a DB dump at the end, so
* for the rest of the processes will be the same as DB_MODE_NONE */
if (dlg_db_mode==DB_MODE_SHUTDOWN && rank!=PROC_MAIN)
dlg_db_mode = DB_MODE_NONE;
```
However, because PROC_POSTCHILDINIT has now been enabled for the module, this code effectively disables DB persistence as PROC_POSTCHILDINIT is called in the main process after PROC_MAIN.
I have modified the rank check to `rank!=PROC_POSTCHILDINIT` and can confirm that DB persistence in SHUTDOWN mode is working once again.
Note that the PR changes the logic to:
```c
if (dlg_db_mode==DB_MODE_SHUTDOWN && rank!=PROC_POSTCHILDINIT)
dlg_db_mode = DB_MODE_NONE;
```
Technically dlg_db_mode will be reset to DB_MODE_NONE when called with rank PROC_MAIN, but the value will be restored when PROC_POSTCHILDINIT is called. I assume this behavior is OK, but otherwise I can change it to:
```c
if (dlg_db_mode==DB_MODE_SHUTDOWN && rank!=PROC_MAIN && rank!=PROC_POSTCHILDINIT)
dlg_db_mode = DB_MODE_NONE;
```
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3221
-- Commit Summary --
* dialog: dont reset dlg_db_mode in POSTCHILDINIT for DB_MODE_SHUTDOWN
-- File Changes --
M src/modules/dialog/dialog.c (2)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3221.patchhttps://github.com/kamailio/kamailio/pull/3221.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3221
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/3221(a)github.com>
Module: kamailio
Branch: master
Commit: 8fb25f7cb6fa73dc37fe11df9b921c32009bd107
URL: https://github.com/kamailio/kamailio/commit/8fb25f7cb6fa73dc37fe11df9b921c3…
Author: Shane Mitchell <sm(a)opencluster.com.au>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-08-17T10:32:41+02:00
dialog: dont reset dlg_db_mode in POSTCHILDINIT for DB_MODE_SHUTDOWN
---
Modified: src/modules/dialog/dialog.c
---
Diff: https://github.com/kamailio/kamailio/commit/8fb25f7cb6fa73dc37fe11df9b921c3…
Patch: https://github.com/kamailio/kamailio/commit/8fb25f7cb6fa73dc37fe11df9b921c3…
---
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index 9b196f86c1d..4347399a794 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -824,7 +824,7 @@ static int child_init(int rank)
/* in DB_MODE_SHUTDOWN only PROC_MAIN will do a DB dump at the end, so
* for the rest of the processes will be the same as DB_MODE_NONE */
- if (dlg_db_mode==DB_MODE_SHUTDOWN && rank!=PROC_MAIN)
+ if (dlg_db_mode==DB_MODE_SHUTDOWN && rank!=PROC_POSTCHILDINIT)
dlg_db_mode = DB_MODE_NONE;
/* in DB_MODE_REALTIME and DB_MODE_DELAYED the PROC_MAIN have no DB handle */
if ( (dlg_db_mode==DB_MODE_REALTIME || dlg_db_mode==DB_MODE_DELAYED) &&