... | ... |
@@ -58,7 +58,7 @@ MAIN_NAME=ser |
58 | 58 |
VERSION = 0 |
59 | 59 |
PATCHLEVEL = 10 |
60 | 60 |
SUBLEVEL = 99 |
61 |
-EXTRAVERSION = -dev12-tcp |
|
61 |
+EXTRAVERSION = -dev13-tcp |
|
62 | 62 |
|
63 | 63 |
RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) |
64 | 64 |
OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]") |
... | ... |
@@ -305,6 +305,9 @@ endif |
305 | 305 |
# -DUSE_TLS |
306 | 306 |
# compiles in tls support, requires -DUSE_TCP. Please use |
307 | 307 |
# make TLS=1 instead. (tls support is highly experimental for now) |
308 |
+# -DHAVE_RESOLV_RES |
|
309 |
+# support for changing some of the resolver parameters present |
|
310 |
+# (_res structure in <resolv.h>) |
|
308 | 311 |
|
309 | 312 |
|
310 | 313 |
DEFS+= $(extra_defs) \ |
... | ... |
@@ -318,6 +321,7 @@ DEFS+= $(extra_defs) \ |
318 | 321 |
-DUSE_MCAST \ |
319 | 322 |
-DUSE_TCP \ |
320 | 323 |
-DDISABLE_NAGLE \ |
324 |
+ -DHAVE_RESOLV_RES \ |
|
321 | 325 |
-DDBG_QM_MALLOC \ |
322 | 326 |
#-DF_MALLOC \ |
323 | 327 |
#-DDBG_F_MALLOC \ |
... | ... |
@@ -21,13 +21,38 @@ core: |
21 | 21 |
- tcp: - improved performance (io event handling), using OS specific |
22 | 22 |
optimizations |
23 | 23 |
- 1024 connections limit removed (see tcp_max_connections) |
24 |
+- resolver: - timeouts, retries a.s.o can no be set from ser.cfg |
|
25 |
+ (see below dns_* and man resolv.conf(6)). |
|
26 |
+ The maximum time a dns request can take (before failing) is: |
|
27 |
+ (dns_retr_time*dns_retr_no)*(search_list_domains) |
|
28 |
+ If dns_try_ipv6 is yes, mutliply it again by 2. |
|
29 |
+ The fastest possible dns config (max 1s): |
|
30 |
+ dns_try_ipv6=no |
|
31 |
+ dns_retr_time=1 |
|
32 |
+ dns_retr_no=1 |
|
33 |
+ dns_use_search_list=no |
|
24 | 34 |
new config variables: |
35 |
+ dns_try_ipv6 = yes/no - if yes and a dns lookup fails, it will retry it |
|
36 |
+ for ipv6 (AAAA record). Default: yes |
|
37 |
+ dns_retr_time = time - time in s before retrying a dns request. |
|
38 |
+ Default: system specific, depends also on the/etc/resolv.conf content |
|
39 |
+ (usually 5s). |
|
40 |
+ dns_retr_no = no. - number of dns retransmissions before giving up. |
|
41 |
+ Default: see above (usually 4) |
|
42 |
+ dns_server_no = no. - how many dns servers from the ones defined in |
|
43 |
+ /etc/resolv.conf will be used. Default: all of them. |
|
44 |
+ dns_use_search_list= yes/no - if no, the search list in /etc/resolv.conf |
|
45 |
+ will be ignored (=> fewer lookups => gives up faster). Default: yes. |
|
46 |
+ HINT: even if you don't have a search list defined, setting this option |
|
47 |
+ to "no" will still be "faster", because an empty search list is in |
|
48 |
+ fact search "" (so even if the search list is empty/missing there will |
|
49 |
+ still be 2 dns queries, eg. foo+'.' and foo+""+'.') |
|
25 | 50 |
tcp_connection_lifetime = value (s) - how long the lifetime of a |
26 | 51 |
tcp connection will be exteneded after an IO event (accept, connect, |
27 | 52 |
read, write). Default: 120 s. |
28 | 53 |
tcp_poll_method = poll|select|epoll_et|epoll-lt|kqueue|devpoll - poll |
29 | 54 |
method used (by default the best one for the current OS is selected) |
30 |
- tcp_max_connections = no - maximum number of tcp connections (if the number |
|
55 |
+ tcp_max_connections = no. - maximum number of tcp connections (if the number |
|
31 | 56 |
is exceeded no new tcp connections will be accepted). Default: 2048. |
32 | 57 |
|
33 | 58 |
|
... | ... |
@@ -54,6 +54,8 @@ |
54 | 54 |
* 2004-11-30 added force_send_socket |
55 | 55 |
* 2005-07-08 added tcp_connection_lifetime, tcp_poll_method, |
56 | 56 |
* tcp_max_connections (andrei) |
57 |
+ * 2005-07-11 added dns_retr_{time,no}, dns_servers_no, dns_use_search_list, |
|
58 |
+ * dns_try_ipv6 (andrei) |
|
57 | 59 |
*/ |
58 | 60 |
|
59 | 61 |
|
... | ... |
@@ -182,6 +184,11 @@ LISTEN listen |
182 | 184 |
ALIAS alias |
183 | 185 |
DNS dns |
184 | 186 |
REV_DNS rev_dns |
187 |
+DNS_TRY_IPV6 dns_try_ipv6 |
|
188 |
+DNS_RETR_TIME dns_retr_time |
|
189 |
+DNS_RETR_NO dns_retr_no |
|
190 |
+DNS_SERVERS_NO dns_servers_no |
|
191 |
+DNS_USE_SEARCH dns_use_search_list |
|
185 | 192 |
PORT port |
186 | 193 |
STAT statistics |
187 | 194 |
MAXBUFFER maxbuffer |
... | ... |
@@ -356,6 +363,16 @@ EAT_ABLE [\ \t\b\r] |
356 | 363 |
<INITIAL>{ALIAS} { count(); yylval.strval=yytext; return ALIAS; } |
357 | 364 |
<INITIAL>{DNS} { count(); yylval.strval=yytext; return DNS; } |
358 | 365 |
<INITIAL>{REV_DNS} { count(); yylval.strval=yytext; return REV_DNS; } |
366 |
+<INITIAL>{DNS_TRY_IPV6} { count(); yylval.strval=yytext; |
|
367 |
+ return DNS_TRY_IPV6; } |
|
368 |
+<INITIAL>{DNS_RETR_TIME} { count(); yylval.strval=yytext; |
|
369 |
+ return DNS_RETR_TIME; } |
|
370 |
+<INITIAL>{DNS_RETR_NO} { count(); yylval.strval=yytext; |
|
371 |
+ return DNS_RETR_NO; } |
|
372 |
+<INITIAL>{DNS_SERVERS_NO} { count(); yylval.strval=yytext; |
|
373 |
+ return DNS_SERVERS_NO; } |
|
374 |
+<INITIAL>{DNS_USE_SEARCH} { count(); yylval.strval=yytext; |
|
375 |
+ return DNS_USE_SEARCH; } |
|
359 | 376 |
<INITIAL>{PORT} { count(); yylval.strval=yytext; return PORT; } |
360 | 377 |
<INITIAL>{STAT} { count(); yylval.strval=yytext; return STAT; } |
361 | 378 |
<INITIAL>{MAXBUFFER} { count(); yylval.strval=yytext; return MAXBUFFER; } |
... | ... |
@@ -60,6 +60,8 @@ |
60 | 60 |
* 2004-11-30 added force_send_socket (andrei) |
61 | 61 |
* 2005-07-08 added TCP_CON_LIFETIME, TCP_POLL_METHOD, TCP_MAX_CONNECTIONS |
62 | 62 |
* (andrei) |
63 |
+ * 2005-07-11 added DNS_RETR_TIME, DNS_RETR_NO, DNS_SERVERS_NO, DNS_USE_SEARCH, |
|
64 |
+ * DNS_TRY_IPV6 (andrei) |
|
63 | 65 |
*/ |
64 | 66 |
|
65 | 67 |
|
... | ... |
@@ -195,6 +197,11 @@ static struct socket_id* mk_listen_id(char*, int, int); |
195 | 197 |
%token ALIAS |
196 | 198 |
%token DNS |
197 | 199 |
%token REV_DNS |
200 |
+%token DNS_TRY_IPV6 |
|
201 |
+%token DNS_RETR_TIME |
|
202 |
+%token DNS_RETR_NO |
|
203 |
+%token DNS_SERVERS_NO |
|
204 |
+%token DNS_USE_SEARCH |
|
198 | 205 |
%token PORT |
199 | 206 |
%token STAT |
200 | 207 |
%token CHILDREN |
... | ... |
@@ -402,6 +409,16 @@ assign_stm: DEBUG EQUAL NUMBER { debug=$3; } |
402 | 409 |
| DNS EQUAL error { yyerror("boolean value expected"); } |
403 | 410 |
| REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; } |
404 | 411 |
| REV_DNS EQUAL error { yyerror("boolean value expected"); } |
412 |
+ | DNS_TRY_IPV6 EQUAL NUMBER { dns_try_ipv6=$3; } |
|
413 |
+ | DNS_TRY_IPV6 error { yyerror("boolean value expected"); } |
|
414 |
+ | DNS_RETR_TIME EQUAL NUMBER { dns_retr_time=$3; } |
|
415 |
+ | DNS_RETR_TIME error { yyerror("number expected"); } |
|
416 |
+ | DNS_RETR_NO EQUAL NUMBER { dns_retr_no=$3; } |
|
417 |
+ | DNS_RETR_NO error { yyerror("number expected"); } |
|
418 |
+ | DNS_SERVERS_NO EQUAL NUMBER { dns_servers_no=$3; } |
|
419 |
+ | DNS_SERVERS_NO error { yyerror("number expected"); } |
|
420 |
+ | DNS_USE_SEARCH EQUAL NUMBER { dns_search_list=$3; } |
|
421 |
+ | DNS_USE_SEARCH error { yyerror("boolean value expected"); } |
|
405 | 422 |
| PORT EQUAL NUMBER { port_no=$3; } |
406 | 423 |
| STAT EQUAL STRING { |
407 | 424 |
#ifdef STATS |
... | ... |
@@ -165,4 +165,10 @@ extern str default_global_port; |
165 | 165 |
extern int disable_core_dump; |
166 | 166 |
extern int open_files_limit; |
167 | 167 |
|
168 |
+/* resolver */ |
|
169 |
+extern int dns_retr_time; |
|
170 |
+extern int dns_retr_no; |
|
171 |
+extern int dns_servers_no; |
|
172 |
+extern int dns_search_list; |
|
173 |
+ |
|
168 | 174 |
#endif |
... | ... |
@@ -29,6 +29,7 @@ |
29 | 29 |
* ------- |
30 | 30 |
* 2003-02-13 added proto to sip_resolvehost, for SRV lookups (andrei) |
31 | 31 |
* 2003-07-03 default port value set according to proto (andrei) |
32 |
+ * 2005-07-11 added resolv_init (timeouts a.s.o) (andrei) |
|
32 | 33 |
*/ |
33 | 34 |
|
34 | 35 |
|
... | ... |
@@ -49,6 +50,48 @@ |
49 | 50 |
#define local_malloc pkg_malloc |
50 | 51 |
#define local_free pkg_free |
51 | 52 |
|
53 |
+int dns_try_ipv6=1; /* default on */ |
|
54 |
+/* declared in globals.h */ |
|
55 |
+int dns_retr_time=-1; |
|
56 |
+int dns_retr_no=-1; |
|
57 |
+int dns_servers_no=-1; |
|
58 |
+int dns_search_list=-1; |
|
59 |
+ |
|
60 |
+ |
|
61 |
+/* init. the resolver |
|
62 |
+ * params: retr_time - time before retransmitting (must be >0) |
|
63 |
+ * retr_no - retransmissions number |
|
64 |
+ * servers_no - how many dns servers will be used |
|
65 |
+ * (from the one listed in /etc/resolv.conf) |
|
66 |
+ * search - if 0 the search list in /etc/resolv.conf will |
|
67 |
+ * be ignored (HINT: even if you don't have a |
|
68 |
+ * search list in resolv.conf, it's still better |
|
69 |
+ * to set search to 0, because an empty seachlist |
|
70 |
+ * means in fact search "" => it takes more time) |
|
71 |
+ * If any of the parameters <0, the default (system specific) value |
|
72 |
+ * will be used. See also resolv.conf(5). |
|
73 |
+ * returns: 0 on success, -1 on error |
|
74 |
+ */ |
|
75 |
+int resolv_init() |
|
76 |
+{ |
|
77 |
+ res_init(); |
|
78 |
+#ifdef HAVE_RESOLV_RES |
|
79 |
+ if (dns_retr_time>0) |
|
80 |
+ _res.retrans=dns_retr_time; |
|
81 |
+ if (dns_retr_no>0) |
|
82 |
+ _res.retry=dns_retr_no; |
|
83 |
+ if (dns_servers_no>=0) |
|
84 |
+ _res.nscount=dns_servers_no; |
|
85 |
+ if (dns_search_list==0) |
|
86 |
+ _res.options&=~(RES_DEFNAMES|RES_DNSRCH); |
|
87 |
+#else |
|
88 |
+#warning "no resolv timeout support" |
|
89 |
+ LOG(L_WARN, "WARNING: resolv_init: no resolv options support - resolv" |
|
90 |
+ " options will be ignored\n"); |
|
91 |
+#endif |
|
92 |
+ return 0; |
|
93 |
+} |
|
94 |
+ |
|
52 | 95 |
|
53 | 96 |
|
54 | 97 |
/* skips over a domain name in a dns message |
... | ... |
@@ -118,6 +118,7 @@ struct rdata* get_record(char* name, int type); |
118 | 118 |
void free_rdata_list(struct rdata* head); |
119 | 119 |
|
120 | 120 |
|
121 |
+extern int dns_try_ipv6; |
|
121 | 122 |
|
122 | 123 |
|
123 | 124 |
#define rev_resolvehost(ip)\ |
... | ... |
@@ -330,7 +331,7 @@ static inline struct hostent* resolvehost(char* name) |
330 | 331 |
/* ipv4 */ |
331 | 332 |
he=gethostbyname(name); |
332 | 333 |
#ifdef USE_IPV6 |
333 |
- if(he==0){ |
|
334 |
+ if(he==0 && dns_try_ipv6){ |
|
334 | 335 |
#ifndef DNS_IP_HACK |
335 | 336 |
skip_ipv4: |
336 | 337 |
#endif |
... | ... |
@@ -356,4 +357,6 @@ skip_ipv4: |
356 | 357 |
|
357 | 358 |
|
358 | 359 |
|
360 |
+int resolv_init(); |
|
361 |
+ |
|
359 | 362 |
#endif |