Browse code

- use_dns_cache can be enabled/disabled runtime - dns_cache_init is introduced: if set to 0, the dns cache is not initialized, and cannot be enabled later (default is 1) - dst_blacklist_init is introduced: if set to 0, the dst blacklist is not initialized (similar to dns_cache_init) (default is 1)

Miklos Tirpak authored on 11/02/2008 17:11:59
Showing 13 changed files
... ...
@@ -197,6 +197,13 @@ new config variables:
197 197
   tcp_source_ipv6 = IPv6 address
198 198
     Set the given source IP for all outbound TCP connections.
199 199
     If setting the IP fails the TCP connection will use the default.
200
+  dns_cache_init = on | off (default on) - if off, the dns cache is not
201
+    initialized at startup and cannot be enabled runtime, that saves some
202
+    memory.
203
+  dst_blacklist_init = on | off (default on) - if off, the blacklist
204
+    is not initialized at startup and cannot be enabled runtime,
205
+    that saves some memory.
206
+
200 207
 
201 208
 
202 209
 2.0.0 changes
... ...
@@ -250,6 +250,7 @@ DNS_SERVERS_NO	dns_servers_no
250 250
 DNS_USE_SEARCH	dns_use_search_list
251 251
 DNS_SEARCH_FMATCH	dns_search_full_match
252 252
 /* dns cache */
253
+DNS_CACHE_INIT	dns_cache_init
253 254
 DNS_USE_CACHE	use_dns_cache
254 255
 DNS_USE_FAILOVER	use_dns_failover
255 256
 DNS_CACHE_FLAGS		dns_cache_flags
... ...
@@ -260,6 +261,7 @@ DNS_CACHE_MEM		dns_cache_mem
260 260
 DNS_CACHE_GC_INT	dns_cache_gc_interval
261 261
 DNS_CACHE_DEL_NONEXP	dns_cache_del_nonexp|dns_cache_delete_nonexpired
262 262
 /* blacklist */
263
+DST_BLST_INIT	dst_blacklist_init
263 264
 USE_DST_BLST		use_dst_blacklist
264 265
 DST_BLST_MEM		dst_blacklist_mem
265 266
 DST_BLST_TTL		dst_blacklist_expire|dst_blacklist_ttl
... ...
@@ -506,6 +508,8 @@ EAT_ABLE	[\ \t\b\r]
506 506
 								return DNS_USE_SEARCH; }
507 507
 <INITIAL>{DNS_SEARCH_FMATCH}	{ count(); yylval.strval=yytext;
508 508
 								return DNS_SEARCH_FMATCH; }
509
+<INITIAL>{DNS_CACHE_INIT}	{ count(); yylval.strval=yytext;
510
+								return DNS_CACHE_INIT; }
509 511
 <INITIAL>{DNS_USE_CACHE}	{ count(); yylval.strval=yytext;
510 512
 								return DNS_USE_CACHE; }
511 513
 <INITIAL>{DNS_USE_FAILOVER}	{ count(); yylval.strval=yytext;
... ...
@@ -524,6 +528,8 @@ EAT_ABLE	[\ \t\b\r]
524 524
 								return DNS_CACHE_GC_INT; }
525 525
 <INITIAL>{DNS_CACHE_DEL_NONEXP}	{ count(); yylval.strval=yytext;
526 526
 								return DNS_CACHE_DEL_NONEXP; }
527
+<INITIAL>{DST_BLST_INIT}	{ count(); yylval.strval=yytext;
528
+								return DST_BLST_INIT; }
527 529
 <INITIAL>{USE_DST_BLST}	{ count(); yylval.strval=yytext;
528 530
 								return USE_DST_BLST; }
529 531
 <INITIAL>{DST_BLST_MEM}	{ count(); yylval.strval=yytext;
... ...
@@ -292,6 +292,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
292 292
 %token DNS_SERVERS_NO
293 293
 %token DNS_USE_SEARCH
294 294
 %token DNS_SEARCH_FMATCH
295
+%token DNS_CACHE_INIT
295 296
 %token DNS_USE_CACHE
296 297
 %token DNS_USE_FAILOVER
297 298
 %token DNS_CACHE_FLAGS
... ...
@@ -302,6 +303,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
302 302
 %token DNS_CACHE_GC_INT
303 303
 %token DNS_CACHE_DEL_NONEXP
304 304
 /*blacklist*/
305
+%token DST_BLST_INIT
305 306
 %token USE_DST_BLST
306 307
 %token DST_BLST_MEM
307 308
 %token DST_BLST_TTL
... ...
@@ -630,7 +632,9 @@ assign_stm:
630 630
 	| DNS_USE_SEARCH error { yyerror("boolean value expected"); }
631 631
 	| DNS_SEARCH_FMATCH EQUAL NUMBER   { default_core_cfg.dns_search_fmatch=$3; }
632 632
 	| DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
633
-	| DNS_USE_CACHE EQUAL NUMBER   { IF_DNS_CACHE(use_dns_cache=$3); }
633
+	| DNS_CACHE_INIT EQUAL NUMBER   { IF_DNS_CACHE(dns_cache_init=$3); }
634
+	| DNS_CACHE_INIT error { yyerror("boolean value expected"); }
635
+	| DNS_USE_CACHE EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.use_dns_cache=$3); }
634 636
 	| DNS_USE_CACHE error { yyerror("boolean value expected"); }
635 637
 	| DNS_USE_FAILOVER EQUAL NUMBER   { IF_DNS_FAILOVER(default_core_cfg.use_dns_failover=$3);}
636 638
 	| DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
... ...
@@ -648,6 +652,8 @@ assign_stm:
648 648
 	| DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
649 649
 	| DNS_CACHE_DEL_NONEXP EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
650 650
 	| DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
651
+	| DST_BLST_INIT EQUAL NUMBER   { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
652
+	| DST_BLST_INIT error { yyerror("boolean value expected"); }
651 653
 	| USE_DST_BLST EQUAL NUMBER   { IF_DST_BLACKLIST(default_core_cfg.use_dst_blacklist=$3); }
652 654
 	| USE_DST_BLST error { yyerror("boolean value expected"); }
653 655
 	| DST_BLST_MEM EQUAL NUMBER   { IF_DST_BLACKLIST(default_core_cfg.blst_max_mem=$3); }
... ...
@@ -67,6 +67,7 @@ struct cfg_group_core default_core_cfg = {
67 67
 	0,  /* dns_reinit */
68 68
 	/* DNS cache */
69 69
 #ifdef USE_DNS_CACHE
70
+	1,  /* use_dns_cache -- on by default */
70 71
 	0,  /* dns_cache_flags */
71 72
 	0,  /* use_dns_failover -- off by default */
72 73
 	0,  /* dns_srv_lb -- off by default */
... ...
@@ -84,7 +85,7 @@ cfg_def_t core_cfg_def[] = {
84 84
 	{"debug",	CFG_VAR_INT,	0, 0, 0, 0, "debug level"},
85 85
 #ifdef USE_DST_BLACKLIST
86 86
 	/* blacklist */
87
-	{"use_dst_blacklist",	CFG_VAR_INT,	0, 0, 0, 0,
87
+	{"use_dst_blacklist",	CFG_VAR_INT,	0, 1, use_dst_blacklist_fixup, 0,
88 88
 		"enable/disable destination blacklisting"},
89 89
 	{"dst_blacklist_expire",	CFG_VAR_INT,	0, 0, 0, 0,
90 90
 		"how much time (in s) a blacklisted destination is kept in the list"},
... ...
@@ -126,6 +127,8 @@ cfg_def_t core_cfg_def[] = {
126 126
 		"set to 1 in order to reinitialize the DNS resolver"},
127 127
 	/* DNS cache */
128 128
 #ifdef USE_DNS_CACHE
129
+	{"use_dns_cache",	CFG_VAR_INT,	0, 1, use_dns_cache_fixup, 0,
130
+		"enable/disable the dns cache"},
129 131
 	{"dns_cache_flags",	CFG_VAR_INT,	0, 4, 0, fix_dns_flags,
130 132
 		"dns cache specific resolver flags "
131 133
 		"(1=ipv4 only, 2=ipv6 only, 4=prefer ipv6"},
... ...
@@ -67,6 +67,7 @@ struct cfg_group_core {
67 67
 	int dns_reinit;
68 68
 	/* DNS cache */
69 69
 #ifdef USE_DNS_CACHE
70
+	int use_dns_cache;
70 71
 	int dns_cache_flags;
71 72
 	int use_dns_failover;
72 73
 	int dns_srv_lb;
... ...
@@ -41,6 +41,7 @@
41 41
  *  2007-08-17  dns_cache_del_nonexp config option is introduced (Miklos)
42 42
  *  2008-02-04  DNS cache options are adapted for the configuration
43 43
  *		framework (Miklos)
44
+ *  2008-02-11  dns_cache_init cfg parameter is introduced (Miklos)
44 45
  */
45 46
 
46 47
 #ifdef USE_DNS_CACHE
... ...
@@ -87,7 +88,7 @@
87 87
 #define MAX_CNAME_CHAIN  10
88 88
 #define SPACE_FORMAT "    " /* format of view output */
89 89
 
90
-
90
+int dns_cache_init=1;	/* if 0, the DNS cache is not initialized at startup */
91 91
 static gen_lock_t* dns_hash_lock=0;
92 92
 static volatile unsigned int *dns_cache_mem_used=0; /* current mem. use */
93 93
 unsigned int dns_timer_interval=DEFAULT_DNS_TIMER_INTERVAL; /* in s */
... ...
@@ -299,7 +300,7 @@ void fix_dns_flags(str *name)
299 299
  */
300 300
 int use_dns_failover_fixup(void *handle, str *name, void **val)
301 301
 {
302
-	if ((int)(long)(*val) && !use_dns_cache) {
302
+	if ((int)(long)(*val) && !cfg_get(core, handle, use_dns_cache)) {
303 303
 		LOG(L_ERR, "ERROR: use_dns_failover_fixup(): "
304 304
 			"DNS cache is turned off, failover cannot be enabled. "
305 305
 			"(set use_dns_cache to 1)\n");
... ...
@@ -308,6 +309,26 @@ int use_dns_failover_fixup(void *handle, str *name, void **val)
308 308
 	return 0;
309 309
 }
310 310
 
311
+/* fixup function for use_dns_cache
312
+ * verifies that dns_cache_init is set to 1
313
+ */
314
+int use_dns_cache_fixup(void *handle, str *name, void **val)
315
+{
316
+	if ((int)(long)(*val) && !dns_cache_init) {
317
+		LOG(L_ERR, "ERROR: use_dns_cache_fixup(): "
318
+			"DNS cache is turned off by dns_cache_init=0, "
319
+			"it cannot be enabled runtime.\n");
320
+		return -1;
321
+	}
322
+	if (((int)(long)(*val)==0) && cfg_get(core, handle, use_dns_failover)) {
323
+		LOG(L_ERR, "ERROR: use_dns_failover_fixup(): "
324
+			"DNS failover depends on use_dns_cache, set use_dns_failover "
325
+			"to 0 before disabling the DNS cache\n");
326
+		return -1;
327
+	}
328
+	return 0;
329
+}
330
+
311 331
 /* KByte to Byte conversion */
312 332
 int dns_cache_max_mem_fixup(void *handle, str *name, void **val)
313 333
 {
... ...
@@ -323,6 +344,13 @@ int init_dns_cache()
323 323
 	int r;
324 324
 	int ret;
325 325
 
326
+	if (dns_cache_init==0) {
327
+		/* the DNS cache is turned off */
328
+		default_core_cfg.use_dns_cache=0;
329
+		default_core_cfg.use_dns_failover=0;
330
+		return 0;
331
+	}
332
+
326 333
 	ret=0;
327 334
 	/* sanity check */
328 335
 	if (E_DNS_CRITICAL>=sizeof(dns_str_errors)/sizeof(char*)){
... ...
@@ -374,6 +402,8 @@ int init_dns_cache()
374 374
 
375 375
 	/* fix options */
376 376
 	default_core_cfg.dns_cache_max_mem<<=10; /* Kb */ /* TODO: test with 0 */
377
+	if (default_core_cfg.use_dns_cache==0)
378
+		default_core_cfg.use_dns_failover=0; /* cannot work w/o dns_cache support */
377 379
 	/* fix flags */
378 380
 	fix_dns_flags(NULL);
379 381
 
... ...
@@ -399,7 +429,11 @@ error:
399 399
 }
400 400
 
401 401
 #ifdef USE_DNS_CACHE_STATS
402
-int init_dns_cache_stats(int iproc_num) {
402
+int init_dns_cache_stats(int iproc_num)
403
+{
404
+	/* do not initialize the stats array if the DNS cache will not be used */
405
+	if (dns_cache_init==0) return 0;
406
+
403 407
 	/* if it is already initialized */
404 408
 	if (dns_cache_stats)
405 409
 		shm_free(dns_cache_stats);
... ...
@@ -2225,7 +2259,7 @@ struct hostent* dns_resolvehost(char* name)
2225 2225
 {
2226 2226
 	str host;
2227 2227
 
2228
-	if ((use_dns_cache==0) || (dns_hash==0)){ /* not init yet */
2228
+	if ((cfg_get(core, core_cfg, use_dns_cache)==0) || (dns_hash==0)){ /* not init yet */
2229 2229
 		return _resolvehost(name);
2230 2230
 	}
2231 2231
 	host.s=name;
... ...
@@ -2250,7 +2284,7 @@ struct hostent* dns_sip_resolvehost(str* name, unsigned short* port,
2250 2250
 	struct ip_addr ip;
2251 2251
 	int ret;
2252 2252
 
2253
-	if ((use_dns_cache==0) || (dns_hash==0)){
2253
+	if ((cfg_get(core, core_cfg, use_dns_cache==0)) || (dns_hash==0)){
2254 2254
 		/* not init or off => use normal, non-cached version */
2255 2255
 		return _sip_resolvehost(name, port, proto);
2256 2256
 	}
... ...
@@ -2282,7 +2316,7 @@ struct hostent* dns_srv_sip_resolvehost(str* name, unsigned short* port,
2282 2282
 	str srv_name;
2283 2283
 	char srv_proto;
2284 2284
 
2285
-	if ((use_dns_cache==0) || (dns_hash==0)){
2285
+	if ((cfg_get(core, core_cfg, use_dns_cache)==0) || (dns_hash==0)){
2286 2286
 		/* not init or off => use normal, non-cached version */
2287 2287
 		return _sip_resolvehost(name, port, proto);
2288 2288
 	}
... ...
@@ -3172,7 +3206,7 @@ int dns_get_server_state(void)
3172 3172
 /* rpc functions */
3173 3173
 void dns_cache_mem_info(rpc_t* rpc, void* ctx)
3174 3174
 {
3175
-	if (!use_dns_cache){
3175
+	if (!cfg_get(core, core_cfg, use_dns_cache)){
3176 3176
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
3177 3177
 		return;
3178 3178
 	}
... ...
@@ -3186,7 +3220,7 @@ void dns_cache_debug(rpc_t* rpc, void* ctx)
3186 3186
 	struct dns_hash_entry* e;
3187 3187
 	ticks_t now;
3188 3188
 
3189
-	if (!use_dns_cache){
3189
+	if (!cfg_get(core, core_cfg, use_dns_cache)){
3190 3190
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
3191 3191
 		return;
3192 3192
 	}
... ...
@@ -3255,7 +3289,7 @@ void dns_cache_stats_get(rpc_t* rpc, void* c)
3255 3255
 	};
3256 3256
 
3257 3257
 
3258
-	if (!use_dns_cache) {
3258
+	if (!cfg_get(core, core_cfg, use_dns_cache)) {
3259 3259
 		rpc->fault(c, 500, "dns cache support disabled");
3260 3260
 		return;
3261 3261
 	}
... ...
@@ -3300,7 +3334,7 @@ void dns_cache_debug_all(rpc_t* rpc, void* ctx)
3300 3300
 	int i;
3301 3301
 	ticks_t now;
3302 3302
 
3303
-	if (!use_dns_cache){
3303
+	if (!cfg_get(core, core_cfg, use_dns_cache)){
3304 3304
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
3305 3305
 		return;
3306 3306
 	}
... ...
@@ -3380,7 +3414,7 @@ void dns_cache_view(rpc_t* rpc, void* ctx)
3380 3380
 	ticks_t now;
3381 3381
 	str s;
3382 3382
 
3383
-	if (!use_dns_cache){
3383
+	if (!cfg_get(core, core_cfg, use_dns_cache)){
3384 3384
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
3385 3385
 		return;
3386 3386
 	}
... ...
@@ -3488,7 +3522,7 @@ void dns_cache_flush(void)
3488 3488
 /* deletes all the entries from the cache */
3489 3489
 void dns_cache_delete_all(rpc_t* rpc, void* ctx)
3490 3490
 {
3491
-	if (!use_dns_cache){
3491
+	if (!cfg_get(core, core_cfg, use_dns_cache)){
3492 3492
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
3493 3493
 		return;
3494 3494
 	}
... ...
@@ -3637,7 +3671,7 @@ static void dns_cache_add_record(rpc_t* rpc, void* ctx, unsigned short type)
3637 3637
 	ip_addr = 0;
3638 3638
 	size = 0;
3639 3639
 
3640
-	if (!use_dns_cache){
3640
+	if (!cfg_get(core, core_cfg, use_dns_cache)){
3641 3641
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
3642 3642
 		return;
3643 3643
 	}
... ...
@@ -3844,7 +3878,7 @@ static void dns_cache_delete_record(rpc_t* rpc, void* ctx, unsigned short type)
3844 3844
 	str name;
3845 3845
 	int err, h, found=0;
3846 3846
 
3847
-	if (!use_dns_cache){
3847
+	if (!cfg_get(core, core_cfg, use_dns_cache)){
3848 3848
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
3849 3849
 		return;
3850 3850
 	}
... ...
@@ -3911,7 +3945,7 @@ void dns_set_server_state_rpc(rpc_t* rpc, void* ctx)
3911 3911
 {
3912 3912
 	int	state;
3913 3913
 
3914
-	if (!use_dns_cache){
3914
+	if (!cfg_get(core, core_cfg, use_dns_cache)){
3915 3915
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
3916 3916
 		return;
3917 3917
 	}
... ...
@@ -3923,7 +3957,7 @@ void dns_set_server_state_rpc(rpc_t* rpc, void* ctx)
3923 3923
 /* prints the DNS server state */
3924 3924
 void dns_get_server_state_rpc(rpc_t* rpc, void* ctx)
3925 3925
 {
3926
-	if (!use_dns_cache){
3926
+	if (!cfg_get(core, core_cfg, use_dns_cache)){
3927 3927
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
3928 3928
 		return;
3929 3929
 	}
... ...
@@ -180,6 +180,7 @@ const char* dns_strerror(int err);
180 180
 
181 181
 void fix_dns_flags(str *name);
182 182
 int use_dns_failover_fixup(void *handle, str *name, void **val);
183
+int use_dns_cache_fixup(void *handle, str *name, void **val);
183 184
 int dns_cache_max_mem_fixup(void *handle, str *name, void **val);
184 185
 int init_dns_cache();
185 186
 #ifdef USE_DNS_CACHE_STATS
... ...
@@ -258,6 +258,9 @@ DNS Cache and Failover Config Variables
258 258
       ones. The last-recently used entries are deleted first.
259 259
       Default: no
260 260
 
261
+   dns_cache_init = on | off - if off, the dns cache is not initialized
262
+      at startup and cannot be enabled runtime, that saves some memory.
263
+      Default: on
261 264
 
262 265
 DNS Cache Compile Options
263 266
 
... ...
@@ -55,6 +55,9 @@ Config Variables
55 55
  dst_blacklist_gc_interval = time in s (default 60 s) - how often the 
56 56
   garbage collection will run (eliminating old, expired entries).
57 57
 
58
+ dst_blacklist_init = on | off (default on) - if off, the blacklist
59
+  is not initialized at startup and cannot be enabled runtime,
60
+  that saves some memory.
58 61
 
59 62
 Compile Options
60 63
 
... ...
@@ -33,6 +33,7 @@
33 33
  *  2007-06-26  added hooks for search (andrei)
34 34
  *  2007-07-30  added dst_blacklist_del() and dst_blacklist_add_to()  (andrei)
35 35
  *  2007-07-30  dst blacklist measurements added (Gergo)
36
+ *  2008-02-11  dns_blacklist_init cfg parameter is introduced (Miklos)
36 37
  */
37 38
 
38 39
 
... ...
@@ -123,6 +124,7 @@ struct dst_blst_lst_head{
123 123
 #endif
124 124
 };
125 125
 
126
+int dst_blacklist_init=1; /* if 0, the dst blacklist is not initialized at startup */
126 127
 static struct timer_ln* blst_timer_h=0;
127 128
 
128 129
 static volatile unsigned int* blst_mem_used=0;
... ...
@@ -226,6 +228,12 @@ int register_blacklist_hook(struct blacklist_hook *h, int type)
226 226
 	struct blacklist_hook* tmp;
227 227
 	int new_max_hooks;
228 228
 
229
+	if (dst_blacklist_init==0) {
230
+		LOG(L_ERR, "register_blacklist_hook: blacklist is turned off, "
231
+			"the hook cannot be registered\n");
232
+		goto error;
233
+	}
234
+
229 235
 	switch(type){
230 236
 		case DST_BLACKLIST_ADD_CB:
231 237
 			cb_lst=&blst_add_cb;
... ...
@@ -339,6 +347,7 @@ void destroy_dst_blacklist()
339 339
 		blst_timer_h=0;
340 340
 	}
341 341
 #ifdef BLST_LOCK_PER_BUCKET
342
+	if (dst_blst_hash)
342 343
 		for(r=0; r<DST_BLST_HASH_SIZE; r++)
343 344
 			lock_destroy(&dst_blst_hash[r].lock);
344 345
 #elif defined BLST_LOCK_SET
... ...
@@ -390,6 +399,12 @@ int init_dst_blacklist()
390 390
 	int r;
391 391
 #endif
392 392
 
393
+	if (dst_blacklist_init==0) {
394
+		/* the dst blacklist is turned off */
395
+		default_core_cfg.use_dst_blacklist=0;
396
+		return 0;
397
+	}
398
+
393 399
 	ret=-1;
394 400
 #ifdef DST_BLACKLIST_HOOKS
395 401
 	if (init_blacklist_hooks()!=0){
... ...
@@ -468,6 +483,9 @@ error:
468 468
 #ifdef USE_DST_BLACKLIST_STATS
469 469
 int init_dst_blacklist_stats(int iproc_num)
470 470
 {
471
+	/* do not initialize the stats array if the dst blacklist will not be used */
472
+	if (dst_blacklist_init==0) return 0;
473
+
471 474
 	/* if it is already initialized */
472 475
 	if (dst_blacklist_stats)
473 476
 		shm_free(dst_blacklist_stats);
... ...
@@ -1095,6 +1113,20 @@ void dst_blst_add(rpc_t* rpc, void* ctx)
1095 1095
 		rpc->fault(ctx, 400, "Failed to add the entry to the blacklist");
1096 1096
 }
1097 1097
 
1098
+/* fixup function for use_dst_blacklist
1099
+ * verifies that dst_blacklist_init is set to 1
1100
+ */
1101
+int use_dst_blacklist_fixup(void *handle, str *name, void **val)
1102
+{
1103
+	if ((int)(long)(*val) && !dst_blacklist_init) {
1104
+		LOG(L_ERR, "ERROR: use_dst_blacklist_fixup(): "
1105
+			"dst blacklist is turned off by dst_blacklist_init=0, "
1106
+			"it cannot be enabled runtime.\n");
1107
+		return -1;
1108
+	}
1109
+	return 0;
1110
+}
1111
+
1098 1112
 /* KByte to Byte conversion */
1099 1113
 int blst_max_mem_fixup(void *handle, str *name, void **val)
1100 1114
 {
... ...
@@ -103,6 +103,7 @@ int dst_blacklist_del(struct dest_info* si, struct sip_msg* msg);
103 103
  */
104 104
 void dst_blst_flush(void);
105 105
 
106
+int use_dst_blacklist_fixup(void *handle, str *name, void **val);
106 107
 /* KByte to Byte conversion */
107 108
 int blst_max_mem_fixup(void *handle, str *name, void **val);
108 109
 
... ...
@@ -191,7 +191,7 @@ extern int rt_timer2_policy; /* "slow" timer, SCHED_OTHER */
191 191
 
192 192
 
193 193
 #ifdef USE_DNS_CACHE
194
-extern int use_dns_cache; /* 1 if the cache is enabled, 0 otherwise */
194
+extern int dns_cache_init; /* if 0, the DNS cache is not initialized at startup */
195 195
 extern unsigned int dns_timer_interval; /* gc timer interval in s */
196 196
 extern int dns_flags; /* default flags used for the  dns_*resolvehost
197 197
                     (compatibility wrappers) */
... ...
@@ -207,6 +207,7 @@ extern struct t_dns_cache_stats* dns_cache_stats;
207 207
 #endif /* USE_DNS_CACHE_STATS */
208 208
 #endif
209 209
 #ifdef USE_DST_BLACKLIST
210
+extern int dst_blacklist_init; /* if 0, the dst blacklist is not initialized at startup */
210 211
 extern unsigned int blst_timer_interval; /*blacklist gc timer interval (in s)*/
211 212
 
212 213
 #ifdef USE_DST_BLACKLIST_STATS
... ...
@@ -371,9 +371,6 @@ int reply_to_via=0;
371 371
 int mcast_loopback = 0;
372 372
 int mcast_ttl = -1; /* if -1, don't touch it, use the default (usually 1) */
373 373
 #endif /* USE_MCAST */
374
-#ifdef USE_DNS_CACHE
375
-int use_dns_cache=1; /* 1 if the cache is enabled, 0 otherwise */
376
-#endif
377 374
 
378 375
 int tos = IPTOS_LOWDELAY;
379 376
 int pmtu_discovery = 0;
... ...
@@ -1652,12 +1649,10 @@ try_again:
1652 1652
 		goto error;
1653 1653
 	}
1654 1654
 #ifdef USE_DNS_CACHE
1655
-	if (use_dns_cache && init_dns_cache()<0){
1655
+	if (init_dns_cache()<0){
1656 1656
 		LOG(L_CRIT, "could not initialize the dns cache, exiting...\n");
1657 1657
 		goto error;
1658 1658
 	}
1659
-	if (use_dns_cache==0)
1660
-		default_core_cfg.use_dns_failover=0; /* cannot work w/o dns_cache support */
1661 1659
 #ifdef USE_DNS_CACHE_STATS
1662 1660
 	/* preinitializing before the nubmer of processes is determined */
1663 1661
 	if (init_dns_cache_stats(1)<0){