Module: kamailio
Branch: master
Commit: d737c876cc36b4de802da77dfcd361323ad7cd8e
URL: https://github.com/kamailio/kamailio/commit/d737c876cc36b4de802da77dfcd3613…
Author: Donat Zenichev <dzenichev(a)sipwise.com>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2021-10-08T19:01:07+02:00
lcr: improve the search for GW when both IP address and src_port are used
It has been noticed, that after a list of contributions into lcr:
* 14e6fc80b3d2389567c73c4a2196bf8e6d92d8d2
* d8583d6ce1748c1ac8494616fced507b01dd4375
* 470fd5b8bedca56efcc5e6aa0225089fe3857ac9
* aa8d3ed4fe20efbd22db3b0b01a655789afa8818
the gateways matching when a search is being done based on
the IP address and the src_port (through the list of GWs with the same IP)
works, but not fully correct.
It is only related to the usage with the third parameter 'src_port',
when calling from_gw() and from_any_gw(), and, only when the search
is done through the gateways list, which have the same IP address
(but different ports). If gateways have different IPs, the issue
is not catchable.
The problem is in the algorithm used for matching based on
two objects (ip_addr and src_port) - the binary search.
It's not fully suitable for a search based on two (or more) objects.
The binary works completely fine, when only one object is used for searching,
but works not fully correct when the search is based on a comparison
of two (or more) objects. A division happening based on the value of
the first object, gives a chance that the second object will never
be found in the current half being looked up.
This commit concerns switching to a full cycling through the list of
gateways of the same lcr_id, and gives a proper work of the do_from_gw().
The slight drawback of the new method is that we have to do a cycling
through the whole list of GWs of the same lcr_id, but on the other hand
it is much more efficient than trying to build up a matching using binary
based on two objects (ip_addr and src_port) being used for comparison.
---
Modified: src/modules/lcr/lcr_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/d737c876cc36b4de802da77dfcd3613…
Patch: https://github.com/kamailio/kamailio/commit/d737c876cc36b4de802da77dfcd3613…
---
diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c
index 93c5181600..d796c08c2c 100644
--- a/src/modules/lcr/lcr_mod.c
+++ b/src/modules/lcr/lcr_mod.c
@@ -922,28 +922,24 @@ static int comp_gws(const void *_g1, const void *_g2)
}
/*
- * Compare gateways based on their IP address and port
+ * Compare a gateway using IP address and the src port
*/
-static int comp_gws_include_port(const void *_g1, const void *_g2)
-{
- struct gw_info *g1 = (struct gw_info *)_g1;
- struct gw_info *g2 = (struct gw_info *)_g2;
-
- /* first address family comparison */
- if(g1->ip_addr.af < g2->ip_addr.af)
- return -1;
- if(g1->ip_addr.af > g2->ip_addr.af)
- return 1;
- if(g1->ip_addr.len < g2->ip_addr.len)
- return -1;
- if(g1->ip_addr.len > g2->ip_addr.len)
- return 1;
-
- /* secondly ports comparison */
- if(g1->port != g2->port)
- return -1;
+static struct gw_info * find_gateway_by_ip_and_port(struct gw_info * gw, struct gw_info * gws) {
+ int tmp = 0, gw_index = 0;
+
+ for (int i = 1; i <= gws[0].ip_addr.u.addr32[0]; i++) {
+ tmp = memcmp(gws[i].ip_addr.u.addr, gw->ip_addr.u.addr, gws[i].ip_addr.len);
+ if (gws[i].ip_addr.af == gw->ip_addr.af &&
+ gws[i].ip_addr.len == gw->ip_addr.len &&
+ tmp == 0 && /* a comparison of the IP address value */
+ gws[i].port == gw->port) {
+ gw_index = i;
+ break;
+ }
+ }
+ if (gw_index != 0) return &(gws[gw_index]);
- return memcmp(g1->ip_addr.u.addr, g2->ip_addr.u.addr, g1->ip_addr.len);
+ return NULL;
}
/*
@@ -3025,8 +3021,7 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id,
if (src_port != 0) {
/* Search for gw based on its ip address and port */
gw.port = src_port;
- res = (struct gw_info *)bsearch(&gw, &(gws[1]), gws[0].ip_addr.u.addr32[0],
- sizeof(struct gw_info), comp_gws_include_port);
+ res = find_gateway_by_ip_and_port(&gw, gws);
} else {
/* Search for gw based on its ip address */
res = (struct gw_info *)bsearch(&gw, &(gws[1]), gws[0].ip_addr.u.addr32[0],
<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for feature requests.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
If you submit a feature request (or enhancement) add the description of what you would like to be added.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment).
-->
### Description
Recently rtpengine has introduced Publish/subscribe mechanism for N-to-N media forwarding and recording. Is it already on Kamailio?
I have gone through the document or rtpengine module in Kamailio and could not find anything that suggests the feature has been incorporated.
<!--
Explain what you did, what you expected to happen, and what actually happened.
-->
### Expected behavior
#### Actual observed behavior
#### Debugging Data
```
(paste your debugging data here)
```
#### Log Messages
<!--
Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your log messages here)
```
#### SIP Traffic
<!--
If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your sip traffic here)
```
### Possible Solutions
<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a improvement.
-->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.4.3 (x86_64/linux)
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_BLACKLIST, 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: unknown
compiled with gcc 8.3.0
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->
```
Linux secondary 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 (2021-07-18) 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/2874
<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for bug reports.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment).
-->
### Description
<!--
Explain what you did, what you expected to happen, and what actually happened.
-->
I found a memory leak which is causing some issues for us in our production. I think I was able to reproduce it and determine that this is happening when we set up an MSRP connection, and that connection is closed due to inactivity (for example when `tcp_connection_lifetime` is triggered).
### Troubleshooting
#### Reproduction
<!--
If the issue can be reproduced, describe how it can be done.
-->
In this environment we have a WebRTC SIP client, connected to Kamailio and a second party using SIP, both sending messages each via MSRP protocol. Web Client and SIP client establish a session normally, all fine here, they can communicate. At this point we have this status:
```
sudo netstat -natp | grep 10.22.22
tcp 0 0 10.22.22.21:5060 0.0.0.0:* LISTEN 28646/kamailio
tcp 0 0 10.22.22.21:10000 0.0.0.0:* LISTEN 28646/kamailio
tcp 0 0 10.22.22.21:8080 0.0.0.0:* LISTEN 28646/kamailio
tcp 0 0 10.22.22.21:10001 0.0.0.0:* LISTEN 28646/kamailio
tcp 0 0 10.22.22.21:10002 0.0.0.0:* LISTEN 28646/kamailio
tcp 0 0 10.22.22.21:8080 10.22.22.1:58508 ESTABLISHED 28640/kamailio
tcp 0 0 10.22.22.21:10000 10.22.22.190:32786 ESTABLISHED 28646/kamailio
tcp 0 0 10.22.22.21:8080 10.22.22.1:58506 ESTABLISHED 28591/kamailio
TESTER|centos8.4|tester21 [2021-10-06][16:23:57] [/home/vagrant]$ kamcmd -s udp:127.0.0.1:2046 mod.stats core all | grep tcp
tcpconn_new(971): 198888
init_tcp(4700): 8192
init_tcp(4694): 32768
init_tcp(4686): 8
init_tcp(4679): 8
init_tcp(4672): 8
init_tcp(4666): 8
init_tcp(4654): 8
```
In order to trigger this failure much faster, I set `tcp_connection_lifetime=60`. Then we just wait the required seconds to let the TCP connections closed. Then we finish the session, and stop our WebClient registering, so all connections are cleaned up.
```
TESTER|centos8.4|tester21 [2021-10-06][16:28:08] [/home/vagrant]$ sudo netstat -natp | grep 10.22.22
tcp 0 0 10.22.22.21:5060 0.0.0.0:* LISTEN 28646/kamailio
tcp 0 0 10.22.22.21:10000 0.0.0.0:* LISTEN 28646/kamailio
tcp 0 0 10.22.22.21:8080 0.0.0.0:* LISTEN 28646/kamailio
tcp 0 0 10.22.22.21:10001 0.0.0.0:* LISTEN 28646/kamailio
tcp 0 0 10.22.22.21:10002 0.0.0.0:* LISTEN 28646/kamailio
TESTER|centos8.4|tester21 [2021-10-06][16:28:20] [/home/vagrant]$ kamcmd -s udp:127.0.0.1:2046 mod.stats core all | grep tcp
tcpconn_new(971): 66296
init_tcp(4700): 8192
init_tcp(4694): 32768
init_tcp(4686): 8
init_tcp(4679): 8
init_tcp(4672): 8
init_tcp(4666): 8
init_tcp(4654): 8
```
As you can see there are no connections but there is memory allocated by `tcpconn_new`. I know this is related to the MSRP because we noticed our SIP Web Client is not closing the socket, so we just wait for Kamailio to close it.
#### Debugging Data
<!--
If you got a core dump, use gdb to extract troubleshooting data - full backtrace,
local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile
bt full
info locals
list
If you are familiar with gdb, feel free to attach more of what you consider to
be relevant.
-->
```
(paste your debugging data here)
```
#### Log Messages
<!--
Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
2021-07-25T23:54:41Z ERROR ERROR: <core> [mem/f_malloc.c:415]: fm_search_defrag(): fm_search_defrag(0x7f39a284c000, 66288); Free fragment not found!
2021-07-25T23:54:41Z ERROR ERROR: <core> [mem/f_malloc.c:498]: fm_malloc(): fm_malloc(0x7f39a284c000, 66288) called from core: tcp_main.c: tcpconn_new(957), module: core; Free fragment not found!
2021-07-25T23:54:41Z ERROR ERROR: <core> [tcp_main.c:959]: tcpconn_new(): mem. allocation failure
2021-07-25T23:54:41Z ERROR ERROR: <core> [tcp_main.c:3985]: handle_new_connect(): tcpconn_new failed, closing socket
```
#### SIP Traffic
<!--
If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your sip traffic here)
```
### Possible Solutions
<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix.
-->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.1.6 (x86_64/linux) 7d1964
flags: STATS: Off, EXTRA_DEBUG, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, DBG_QM_MALLOC, 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_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 7d1964
compiled on 13:54:09 Oct 5 2021 with gcc 8.4.1
```
Already tried with the latest stable Kamailio version, with the same issue.
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `lsb_release -a` and `uname -a`)
-->
```
Linux tester21 4.18.0-305.17.1.el8_4.x86_64 #1 SMP Wed Sep 8 14:00:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
centos 8
```
--
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/2875
### Description
Currently there is no way to tell Kamailio to reload the GeoIP database that is configured without a restart. This feature request is for adding the possibility to hot-reload the GeoIP2 database.
### Possible Solutions
Implement a RPC command to reload the database, similar to the way the TLS module implements `tls.reload` to reload the configured certificates without needing a restart.
### Example
`kamcmd geoip2.reload` / `kamctl rpc geoip2.reload`
--
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/2870
Module: kamailio
Branch: 5.5
Commit: 0d53d9a676747cd6583c6cfcdf5b3e8593b6c84a
URL: https://github.com/kamailio/kamailio/commit/0d53d9a676747cd6583c6cfcdf5b3e8…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2021-10-05T16:46:33+02:00
modules: readme files regenerated - modules ... [skip ci]
---
Modified: src/modules/rtpengine/README
Modified: src/modules/textops/README
---
Diff: https://github.com/kamailio/kamailio/commit/0d53d9a676747cd6583c6cfcdf5b3e8…
Patch: https://github.com/kamailio/kamailio/commit/0d53d9a676747cd6583c6cfcdf5b3e8…
---
diff --git a/src/modules/rtpengine/README b/src/modules/rtpengine/README
index 24d02d1c5d..6f962d4aed 100644
--- a/src/modules/rtpengine/README
+++ b/src/modules/rtpengine/README
@@ -2669,6 +2669,8 @@ play_dtmf("code=1 volume=5 duration=300 pause=150");
is enabled, the sessions are still allowed to finish for the hidden old
nodes.
+ The execution of this command is limited to 10 seconds intervals.
+
Example 1.100. rtpengine.reload usage
...
$ kamcmd rtpengine.reload
diff --git a/src/modules/textops/README b/src/modules/textops/README
index e86ff275d8..08dd399246 100644
--- a/src/modules/textops/README
+++ b/src/modules/textops/README
@@ -249,9 +249,13 @@ Chapter 1. Admin Guide
The module implements text based operations over the SIP message
processed by Kamailio. SIP is a text based protocol and the module
provides a large set of very useful functions to manipulate the message
- at text level, e.g., regular expression search and replace, Perl-like
+ at text level, e.g., regular expression search, replace or
substitutions, checks for method type, header presence, insert of new
- header and date, etc.
+ header and date, string comparisons, multi-part body operations, etc.
+
+ If not stated otherwise, the regular expressions parameters for search,
+ replace or substitute have to be in POSIX format. For PCRE regular
+ expression matching, see the pcre or dialplan modules.
2. Known Limitations
@@ -598,7 +602,7 @@ replace_hdrs_str("Kamailio", "Kamailio SIP Proxy", "a");
4.16. subst('/re/repl/flags')
- Replaces re with repl (sed or perl like).
+ Replaces re with repl.
Meaning of the parameters is as follows:
* '/re/repl/flags' - sed like regular expression. flags can be a
@@ -679,7 +683,7 @@ if (subst_user('/(.*)3642$/$avp(user_prefix)\13642/')){$
4.19. subst_body('/re/repl/flags')
- Replaces re with repl (sed or perl like) in the body of the message.
+ Replaces re with repl in the body of the message.
Meaning of the parameters is as follows:
* '/re/repl/flags' - sed like regular expression. flags can be a
@@ -700,7 +704,7 @@ if ( subst_body('/^o=(.*) /o=$fU /') ) {};
4.20. subst_hf(hf, subexp, flags)
- Perl-like substitutions in the body of a header field.
+ Substitutions in the body of a header field.
Meaning of the parameters is as follows:
* hf - header field name.