Browse code

core: add an option to trigger also an RST on tcp connection close

- This gives an option to also send RST in case kamailio closes the
connection. There are cases where a FIN,ACK back forth leaves
the connection in the host in TIME_WAIT state, but the ports on both
sides are fixed. This leads to no request can send until
the TIME_WAIT state is gone.

Rick Barenthin authored on 03/05/2022 17:42:31 • Daniel-Constantin Mierla committed on 16/05/2022 06:01:02
Showing 1 changed files
... ...
@@ -139,6 +139,7 @@ struct cfg_group_tcp{
139 139
 	int accept_no_cl;  /* on/off - accept messages without content-length */
140 140
 	int reuse_port;  /* enable SO_REUSEPORT */
141 141
 	int wait_data_ms;  /* wait for data in milliseconds */
142
+	int close_rst; /* on /off trigger an RST on connection close */
142 143
 
143 144
 	/* internal, "fixed" vars */
144 145
 	unsigned int rd_buf_size; /* read buffer size (should be > max. datagram)*/
Browse code

core: tcp - added core parameter tcp_wait_data

- specify how long to wait (in milliseconds) to wait for data on tcp
connections in certain cases
- default is 5000ms (5secs)
- now applies when reading on tcp connection for haproxy protocol

Daniel-Constantin Mierla authored on 13/12/2021 13:42:50
Showing 1 changed files
... ...
@@ -138,6 +138,7 @@ struct cfg_group_tcp{
138 138
 	int new_conn_alias_flags;
139 139
 	int accept_no_cl;  /* on/off - accept messages without content-length */
140 140
 	int reuse_port;  /* enable SO_REUSEPORT */
141
+	int wait_data_ms;  /* wait for data in milliseconds */
141 142
 
142 143
 	/* internal, "fixed" vars */
143 144
 	unsigned int rd_buf_size; /* read buffer size (should be > max. datagram)*/
Browse code

core: check if the tcp clone rcv buffer is set when applying changes

Daniel-Constantin Mierla authored on 26/11/2020 12:54:42
Showing 1 changed files
... ...
@@ -157,6 +157,7 @@ void tcp_options_get(struct cfg_group_tcp* t);
157 157
 
158 158
 #ifdef USE_TCP
159 159
 int tcp_set_clone_rcvbuf(int v);
160
+int tcp_get_clone_rcvbuf(void);
160 161
 #endif /* USE_TCP */
161 162
 
162 163
 #endif /* tcp_options_h */
Browse code

core: enable reuse of tcp sockets

- credits to Marco Sinibaldi for the original implementation

grumvalski authored on 08/03/2017 12:53:56
Showing 1 changed files
... ...
@@ -137,6 +137,7 @@ struct cfg_group_tcp{
137 137
 	int alias_flags;
138 138
 	int new_conn_alias_flags;
139 139
 	int accept_no_cl;  /* on/off - accept messages without content-length */
140
+	int reuse_port;  /* enable SO_REUSEPORT */
140 141
 
141 142
 	/* internal, "fixed" vars */
142 143
 	unsigned int rd_buf_size; /* read buffer size (should be > max. datagram)*/
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,161 @@
1
+/* 
2
+ * Copyright (C) 2007 iptelorg GmbH
3
+ *
4
+ * Permission to use, copy, modify, and distribute this software for any
5
+ * purpose with or without fee is hereby granted, provided that the above
6
+ * copyright notice and this permission notice appear in all copies.
7
+ *
8
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
+ */
16
+/*! \file
17
+ * \brief tcp options
18
+ *
19
+ */
20
+
21
+#ifndef tcp_options_h
22
+#define tcp_options_h
23
+
24
+#ifdef USE_TCP
25
+
26
+#include <netinet/in.h>
27
+#include <netinet/tcp.h>
28
+#ifndef NO_TCP_ASYNC
29
+#define TCP_ASYNC /* enabled async mode */
30
+#endif
31
+
32
+#if !defined(NO_TCP_CONNECT_WAIT) && defined(TCP_ASYNC)
33
+#define TCP_CONNECT_WAIT /* enable pending connects support */
34
+#endif
35
+
36
+#if defined(TCP_CONNECT_WAIT) && !defined(TCP_ASYNC)
37
+/* check for impossible configuration: TCP_CONNECT_WAIT w/o TCP_ASYNC */
38
+#warning "disabling TCP_CONNECT_WAIT because TCP_ASYNC is not defined"
39
+#undef TCP_CONNECT_WAIT
40
+#endif
41
+
42
+#ifndef NO_TCP_FD_CACHE
43
+#define TCP_FD_CACHE /* enable fd caching */
44
+#endif
45
+
46
+
47
+
48
+/* defer accept */
49
+#ifndef  NO_TCP_DEFER_ACCEPT
50
+#ifdef __OS_linux
51
+#define HAVE_TCP_DEFER_ACCEPT
52
+#elif defined __OS_freebsd
53
+#define HAVE_TCP_ACCEPT_FILTER
54
+#endif /* __OS_ */
55
+#endif /* NO_TCP_DEFER_ACCEPT */
56
+
57
+
58
+/* syn count */
59
+#ifndef NO_TCP_SYNCNT
60
+#ifdef __OS_linux
61
+#define HAVE_TCP_SYNCNT
62
+#endif /* __OS_*/
63
+#endif /* NO_TCP_SYNCNT */
64
+
65
+/* tcp linger2 */
66
+#ifndef NO_TCP_LINGER2
67
+#ifdef __OS_linux
68
+#define HAVE_TCP_LINGER2
69
+#endif /* __OS_ */
70
+#endif /* NO_TCP_LINGER2 */
71
+
72
+/* keepalive */
73
+#ifndef NO_TCP_KEEPALIVE
74
+#define HAVE_SO_KEEPALIVE
75
+#endif /* NO_TCP_KEEPALIVE */
76
+
77
+/* keepintvl */
78
+#ifndef NO_TCP_KEEPINTVL
79
+#ifdef TCP_KEEPINTVL
80
+#define HAVE_TCP_KEEPINTVL
81
+#endif /* TCP_KEEPINTVL */
82
+#endif /* NO_TCP_KEEPINTVL */
83
+
84
+/* keepidle */
85
+#ifndef NO_TCP_KEEPIDLE
86
+#ifdef TCP_KEEPIDLE
87
+#define HAVE_TCP_KEEPIDLE
88
+#endif /* TCP_KEEPIDLE*/
89
+#endif /* NO_TCP_KEEPIDLE */
90
+
91
+
92
+/* keepcnt */
93
+#ifndef NO_TCP_KEEPCNT
94
+#ifdef TCP_KEEPCNT
95
+#define HAVE_TCP_KEEPCNT
96
+#endif /* TCP_KEEPCNT */
97
+#endif /* NO_TCP_KEEPCNT */
98
+
99
+
100
+/* delayed ack (quick_ack) */
101
+#ifndef NO_TCP_QUICKACK
102
+#ifdef __OS_linux
103
+#define HAVE_TCP_QUICKACK
104
+#endif /* __OS_ */
105
+#endif /* NO_TCP_QUICKACK */
106
+
107
+#endif /* USE_TCP */
108
+
109
+struct cfg_group_tcp{
110
+	/* ser tcp options, low level */
111
+	int connect_timeout_s; /* in s */
112
+	int send_timeout; /* in ticks (s fixed to ticks) */
113
+	int con_lifetime; /* in ticks (s fixed to ticks) */
114
+	int max_connections; /* max tcp connections (includes tls connections) */
115
+	int max_tls_connections; /* max tls connections */
116
+	int no_connect; /* do not open any new tcp connection (but accept them) */
117
+	int fd_cache; /* on /off */
118
+	/* tcp async options */
119
+	int async; /* on / off */
120
+	int tcp_connect_wait; /* on / off, depends on async */
121
+	unsigned int tcpconn_wq_max; /* maximum queue len per connection */
122
+	unsigned int tcp_wq_max; /* maximum overall queued bytes */
123
+
124
+	/* tcp socket options */
125
+	int defer_accept; /* on / off */
126
+	int delayed_ack; /* delay ack on connect */ 
127
+	int syncnt;     /* numbers of SYNs retrs. before giving up connecting */
128
+	int linger2;    /* lifetime of orphaned  FIN_WAIT2 state sockets */
129
+	int keepalive;  /* on /off */
130
+	int keepidle;   /* idle time (s) before tcp starts sending keepalives */
131
+	int keepintvl;  /* interval between keep alives */
132
+	int keepcnt;    /* maximum no. of keepalives before giving up */
133
+	
134
+	/* other options */
135
+	int crlf_ping;  /* on/off - reply to double CRLF keepalives */
136
+	int accept_aliases;
137
+	int alias_flags;
138
+	int new_conn_alias_flags;
139
+	int accept_no_cl;  /* on/off - accept messages without content-length */
140
+
141
+	/* internal, "fixed" vars */
142
+	unsigned int rd_buf_size; /* read buffer size (should be > max. datagram)*/
143
+	unsigned int wq_blk_size; /* async write block size (debugging use) */
144
+};
145
+
146
+extern struct cfg_group_tcp tcp_default_cfg;
147
+
148
+/* tcp config handle*/
149
+extern void* tcp_cfg;
150
+
151
+
152
+void init_tcp_options(void);
153
+void tcp_options_check(void);
154
+int tcp_register_cfg(void);
155
+void tcp_options_get(struct cfg_group_tcp* t);
156
+
157
+#ifdef USE_TCP
158
+int tcp_set_clone_rcvbuf(int v);
159
+#endif /* USE_TCP */
160
+
161
+#endif /* tcp_options_h */