ovedeneev created an issue (kamailio/kamailio#4187)
### Description
[tcp_send_timeout](https://www.kamailio.org/wikidocs/cookbooks/5.8.x/core/#tcp_send_timeout) option does not apply for outbound connections.
#### Reproduction
1. Establish TCP OPTIONS between Kamailio and target node. 2. On target node block incoming traffic from Kamailio node using iptables. 3. Notice on Kamailio node that TCP retransmission packets don't follow tcp_send_timeout settings, instead they fall back to kernel's net.ipv4.tcp_retries2 settings.
### Additional Information
* **Kamailio Version**
``` # kamailio -V version: kamailio 5.8.2 (aarch64/linux) 446039 flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT-NOSMP, 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_SEND_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: 446039 compiled on 14:32:09 Nov 14 2024 with gcc 8.5.0 ```
* **Operating System**:
``` Linux xxx 4.18.0-553.6.1.el8.aarch64 #1 SMP Thu May 30 04:10:32 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux ```
sergey-safarov left a comment (kamailio/kamailio#4187)
To reproduce this issue, you need to start Kamailio with config file ``` listen=eth0
tcp_send_timeout=3
loadmodule "xlog.so" loadmodule "pv.so" loadmodule "ctl.so" loadmodule "jsonrpcs.so" loadmodule "tm.so"
loadmodule "dispatcher.so" modparam("dispatcher", "list_file", "/tmp/dispatcher.list") modparam("dispatcher", "ds_ping_from", "sip:proxy@aggregator.nga911.com") modparam("dispatcher", "ds_ping_interval", 3) modparam("dispatcher", "ds_probing_mode", 1)
route{ xerr("SDP: TEST $tu\n"); drop; } ``` Where `/tmp/dispatcher.list` has content ``` 1 sip:sip.telnyx.com:5060;transport=tcp 8 ``` In another window, you need to start tcpdump using the command ``` tcpdump -ni any host sip.telnyx.com ``` Imdediately after start you will see something like ``` root@nout:~# tcpdump -ni any host sip.telnyx.com tcpdump: WARNING: any: That device doesn't support promiscuous mode (Promiscuous mode not supported on the "any" device) dropped privs to tcpdump tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
13:47:57.761479 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [S], seq 105320156, win 64240, options [mss 1460,sackOK,TS val 2910270166 ecr 0,nop,wscale 7], length 0 13:47:57.961010 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [S.], seq 3545220477, ack 105320157, win 65160, options [mss 1370,sackOK,TS val 1818499729 ecr 2910270166,nop,wscale 7], length 0 13:47:57.961211 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 1:428, ack 1, win 502, options [nop,nop,TS val 2910270365 ecr 1818499729], length 427 13:47:58.312923 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [.], ack 428, win 506, options [nop,nop,TS val 1818499928 ecr 2910270365], length 0 13:47:58.312930 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [P.], seq 1:445, ack 428, win 506, options [nop,nop,TS val 1818499932 ecr 2910270365], length 444 13:47:58.353207 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [.], ack 445, win 501, options [nop,nop,TS val 2910270758 ecr 1818499932], length 0
13:48:00.760881 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 428:855, ack 445, win 501, options [nop,nop,TS val 2910273165 ecr 1818499932], length 427 13:48:00.960459 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [.], ack 855, win 503, options [nop,nop,TS val 1818502729 ecr 2910273165], length 0 13:48:00.960461 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [P.], seq 445:889, ack 855, win 503, options [nop,nop,TS val 1818502729 ecr 2910273165], length 444 13:48:00.960529 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [.], ack 889, win 498, options [nop,nop,TS val 2910273365 ecr 1818502729], length 0
13:48:03.760894 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 855:1282, ack 889, win 501, options [nop,nop,TS val 2910276165 ecr 1818502729], length 427 13:48:04.100711 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [.], ack 1282, win 501, options [nop,nop,TS val 1818505728 ecr 2910276165], length 0 13:48:04.100712 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [P.], seq 889:1333, ack 1282, win 501, options [nop,nop,TS val 1818505729 ecr 2910276165], length 444 13:48:04.100781 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [.], ack 1333, win 498, options [nop,nop,TS val 2910276505 ecr 1818505729], length 0 ``` Then, you need to execute the iptables command ``` iptables -I INPUT -s 192.76.120.10/32 -j DROP ``` Then tcpdump output will be like ``` 13:49:12.760855 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 10676:11103, ack 11101, win 501, options [nop,nop,TS val 2910345165 ecr 1818571754], length 427 13:49:13.200228 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 10676:11103, ack 11101, win 501, options [nop,nop,TS val 2910345605 ecr 1818571754], length 427 13:49:13.213592 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [P.], seq 11101:11545, ack 11103, win 501, options [nop,nop,TS val 1818574958 ecr 2910345165], length 444 13:49:13.453312 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [.], ack 11103, win 501, options [nop,nop,TS val 1818575221 ecr 2910345605,nop,nop,sack 1 {10676:11103}], length 0 13:49:13.618140 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [P.], seq 11101:11545, ack 11103, win 501, options [nop,nop,TS val 1818575386 ecr 2910345605], length 444 13:49:13.640349 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 10676:11103, ack 11101, win 501, options [nop,nop,TS val 2910346045 ecr 1818571754], length 427 13:49:13.836702 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [.], ack 11103, win 501, options [nop,nop,TS val 1818575606 ecr 2910346045,nop,nop,sack 1 {10676:11103}], length 0 13:49:14.034097 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [P.], seq 11101:11545, ack 11103, win 501, options [nop,nop,TS val 1818575802 ecr 2910346045], length 444 13:49:14.520347 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 10676:11103, ack 11101, win 501, options [nop,nop,TS val 2910346925 ecr 1818571754], length 427 13:49:14.720278 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [.], ack 11103, win 501, options [nop,nop,TS val 1818576489 ecr 2910346925,nop,nop,sack 1 {10676:11103}], length 0 13:49:14.865148 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [P.], seq 11101:11545, ack 11103, win 501, options [nop,nop,TS val 1818576634 ecr 2910346925], length 444 13:49:16.312366 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 10676:11103, ack 11101, win 501, options [nop,nop,TS val 2910348717 ecr 1818571754], length 427 13:49:16.533325 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [P.], seq 11101:11545, ack 11103, win 501, options [nop,nop,TS val 1818578302 ecr 2910346925], length 444 13:49:16.572702 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [.], ack 11103, win 501, options [nop,nop,TS val 1818578341 ecr 2910348717,nop,nop,sack 1 {10676:11103}], length 0 13:49:19.832241 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 10676:11103, ack 11101, win 501, options [nop,nop,TS val 2910352237 ecr 1818571754], length 427 13:49:19.889067 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [P.], seq 11101:11545, ack 11103, win 501, options [nop,nop,TS val 1818581658 ecr 2910348717], length 444 13:49:20.045815 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [.], ack 11103, win 501, options [nop,nop,TS val 1818581813 ecr 2910352237,nop,nop,sack 1 {10676:11103}], length 0 13:49:27.128254 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 10676:11103, ack 11101, win 501, options [nop,nop,TS val 2910359533 ecr 1818571754], length 427 13:49:27.351103 wlp0s20f3 In IP 192.76.120.10.sip > 192.168.143.246.58732: Flags [R], seq 3545231578, win 0, length 0 13:49:41.464389 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 10676:11103, ack 11101, win 501, options [nop,nop,TS val 2910373869 ecr 1818571754], length 427 13:50:09.624232 wlp0s20f3 Out IP 192.168.143.246.58732 > 192.76.120.10.sip: Flags [P.], seq 10676:11103, ack 11101, win 501, options [nop,nop,TS val 2910402029 ecr 1818571754], length 427 ``` And according to network traffic kamailio keep failed tcp connections open durring 3o min.