tcp_source_ipv6 = IPv6 address
Set the given source IP for all outbound TCP connections.
If setting the IP fails the TCP connection will use the default.
+ dns_cache_init = on | off (default on) - if off, the dns cache is not
+ initialized at startup and cannot be enabled runtime, that saves some
+ memory.
+ dst_blacklist_init = on | off (default on) - if off, the blacklist
+ is not initialized at startup and cannot be enabled runtime,
+ that saves some memory.
+
2.0.0 changes
DNS_USE_SEARCH dns_use_search_list
DNS_SEARCH_FMATCH dns_search_full_match
/* dns cache */
+DNS_CACHE_INIT dns_cache_init
DNS_USE_CACHE use_dns_cache
DNS_USE_FAILOVER use_dns_failover
DNS_CACHE_FLAGS dns_cache_flags
DNS_CACHE_GC_INT dns_cache_gc_interval
DNS_CACHE_DEL_NONEXP dns_cache_del_nonexp|dns_cache_delete_nonexpired
/* blacklist */
+DST_BLST_INIT dst_blacklist_init
USE_DST_BLST use_dst_blacklist
DST_BLST_MEM dst_blacklist_mem
DST_BLST_TTL dst_blacklist_expire|dst_blacklist_ttl
return DNS_USE_SEARCH; }
<INITIAL>{DNS_SEARCH_FMATCH} { count(); yylval.strval=yytext;
return DNS_SEARCH_FMATCH; }
+<INITIAL>{DNS_CACHE_INIT} { count(); yylval.strval=yytext;
+ return DNS_CACHE_INIT; }
<INITIAL>{DNS_USE_CACHE} { count(); yylval.strval=yytext;
return DNS_USE_CACHE; }
<INITIAL>{DNS_USE_FAILOVER} { count(); yylval.strval=yytext;
return DNS_CACHE_GC_INT; }
<INITIAL>{DNS_CACHE_DEL_NONEXP} { count(); yylval.strval=yytext;
return DNS_CACHE_DEL_NONEXP; }
+<INITIAL>{DST_BLST_INIT} { count(); yylval.strval=yytext;
+ return DST_BLST_INIT; }
<INITIAL>{USE_DST_BLST} { count(); yylval.strval=yytext;
return USE_DST_BLST; }
<INITIAL>{DST_BLST_MEM} { count(); yylval.strval=yytext;
%token DNS_SERVERS_NO
%token DNS_USE_SEARCH
%token DNS_SEARCH_FMATCH
+%token DNS_CACHE_INIT
%token DNS_USE_CACHE
%token DNS_USE_FAILOVER
%token DNS_CACHE_FLAGS
%token DNS_CACHE_GC_INT
%token DNS_CACHE_DEL_NONEXP
/*blacklist*/
+%token DST_BLST_INIT
%token USE_DST_BLST
%token DST_BLST_MEM
%token DST_BLST_TTL
| DNS_USE_SEARCH error { yyerror("boolean value expected"); }
| DNS_SEARCH_FMATCH EQUAL NUMBER { default_core_cfg.dns_search_fmatch=$3; }
| DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
- | DNS_USE_CACHE EQUAL NUMBER { IF_DNS_CACHE(use_dns_cache=$3); }
+ | DNS_CACHE_INIT EQUAL NUMBER { IF_DNS_CACHE(dns_cache_init=$3); }
+ | DNS_CACHE_INIT error { yyerror("boolean value expected"); }
+ | DNS_USE_CACHE EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.use_dns_cache=$3); }
| DNS_USE_CACHE error { yyerror("boolean value expected"); }
| DNS_USE_FAILOVER EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.use_dns_failover=$3);}
| DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
| DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
| DNS_CACHE_DEL_NONEXP EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
| DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
+ | DST_BLST_INIT EQUAL NUMBER { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
+ | DST_BLST_INIT error { yyerror("boolean value expected"); }
| USE_DST_BLST EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.use_dst_blacklist=$3); }
| USE_DST_BLST error { yyerror("boolean value expected"); }
| DST_BLST_MEM EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.blst_max_mem=$3); }
0, /* dns_reinit */
/* DNS cache */
#ifdef USE_DNS_CACHE
+ 1, /* use_dns_cache -- on by default */
0, /* dns_cache_flags */
0, /* use_dns_failover -- off by default */
0, /* dns_srv_lb -- off by default */
{"debug", CFG_VAR_INT, 0, 0, 0, 0, "debug level"},
#ifdef USE_DST_BLACKLIST
/* blacklist */
- {"use_dst_blacklist", CFG_VAR_INT, 0, 0, 0, 0,
+ {"use_dst_blacklist", CFG_VAR_INT, 0, 1, use_dst_blacklist_fixup, 0,
"enable/disable destination blacklisting"},
{"dst_blacklist_expire", CFG_VAR_INT, 0, 0, 0, 0,
"how much time (in s) a blacklisted destination is kept in the list"},
"set to 1 in order to reinitialize the DNS resolver"},
/* DNS cache */
#ifdef USE_DNS_CACHE
+ {"use_dns_cache", CFG_VAR_INT, 0, 1, use_dns_cache_fixup, 0,
+ "enable/disable the dns cache"},
{"dns_cache_flags", CFG_VAR_INT, 0, 4, 0, fix_dns_flags,
"dns cache specific resolver flags "
"(1=ipv4 only, 2=ipv6 only, 4=prefer ipv6"},
int dns_reinit;
/* DNS cache */
#ifdef USE_DNS_CACHE
+ int use_dns_cache;
int dns_cache_flags;
int use_dns_failover;
int dns_srv_lb;
* 2007-08-17 dns_cache_del_nonexp config option is introduced (Miklos)
* 2008-02-04 DNS cache options are adapted for the configuration
* framework (Miklos)
+ * 2008-02-11 dns_cache_init cfg parameter is introduced (Miklos)
*/
#ifdef USE_DNS_CACHE
#define MAX_CNAME_CHAIN 10
#define SPACE_FORMAT " " /* format of view output */
-
+int dns_cache_init=1; /* if 0, the DNS cache is not initialized at startup */
static gen_lock_t* dns_hash_lock=0;
static volatile unsigned int *dns_cache_mem_used=0; /* current mem. use */
unsigned int dns_timer_interval=DEFAULT_DNS_TIMER_INTERVAL; /* in s */
*/
int use_dns_failover_fixup(void *handle, str *name, void **val)
{
- if ((int)(long)(*val) && !use_dns_cache) {
+ if ((int)(long)(*val) && !cfg_get(core, handle, use_dns_cache)) {
LOG(L_ERR, "ERROR: use_dns_failover_fixup(): "
"DNS cache is turned off, failover cannot be enabled. "
"(set use_dns_cache to 1)\n");
return 0;
}
+/* fixup function for use_dns_cache
+ * verifies that dns_cache_init is set to 1
+ */
+int use_dns_cache_fixup(void *handle, str *name, void **val)
+{
+ if ((int)(long)(*val) && !dns_cache_init) {
+ LOG(L_ERR, "ERROR: use_dns_cache_fixup(): "
+ "DNS cache is turned off by dns_cache_init=0, "
+ "it cannot be enabled runtime.\n");
+ return -1;
+ }
+ if (((int)(long)(*val)==0) && cfg_get(core, handle, use_dns_failover)) {
+ LOG(L_ERR, "ERROR: use_dns_failover_fixup(): "
+ "DNS failover depends on use_dns_cache, set use_dns_failover "
+ "to 0 before disabling the DNS cache\n");
+ return -1;
+ }
+ return 0;
+}
+
/* KByte to Byte conversion */
int dns_cache_max_mem_fixup(void *handle, str *name, void **val)
{
int r;
int ret;
+ if (dns_cache_init==0) {
+ /* the DNS cache is turned off */
+ default_core_cfg.use_dns_cache=0;
+ default_core_cfg.use_dns_failover=0;
+ return 0;
+ }
+
ret=0;
/* sanity check */
if (E_DNS_CRITICAL>=sizeof(dns_str_errors)/sizeof(char*)){
/* fix options */
default_core_cfg.dns_cache_max_mem<<=10; /* Kb */ /* TODO: test with 0 */
+ if (default_core_cfg.use_dns_cache==0)
+ default_core_cfg.use_dns_failover=0; /* cannot work w/o dns_cache support */
/* fix flags */
fix_dns_flags(NULL);
}
#ifdef USE_DNS_CACHE_STATS
-int init_dns_cache_stats(int iproc_num) {
+int init_dns_cache_stats(int iproc_num)
+{
+ /* do not initialize the stats array if the DNS cache will not be used */
+ if (dns_cache_init==0) return 0;
+
/* if it is already initialized */
if (dns_cache_stats)
shm_free(dns_cache_stats);
{
str host;
- if ((use_dns_cache==0) || (dns_hash==0)){ /* not init yet */
+ if ((cfg_get(core, core_cfg, use_dns_cache)==0) || (dns_hash==0)){ /* not init yet */
return _resolvehost(name);
}
host.s=name;
struct ip_addr ip;
int ret;
- if ((use_dns_cache==0) || (dns_hash==0)){
+ if ((cfg_get(core, core_cfg, use_dns_cache==0)) || (dns_hash==0)){
/* not init or off => use normal, non-cached version */
return _sip_resolvehost(name, port, proto);
}
str srv_name;
char srv_proto;
- if ((use_dns_cache==0) || (dns_hash==0)){
+ if ((cfg_get(core, core_cfg, use_dns_cache)==0) || (dns_hash==0)){
/* not init or off => use normal, non-cached version */
return _sip_resolvehost(name, port, proto);
}
/* rpc functions */
void dns_cache_mem_info(rpc_t* rpc, void* ctx)
{
- if (!use_dns_cache){
+ if (!cfg_get(core, core_cfg, use_dns_cache)){
rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
return;
}
struct dns_hash_entry* e;
ticks_t now;
- if (!use_dns_cache){
+ if (!cfg_get(core, core_cfg, use_dns_cache)){
rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
return;
}
};
- if (!use_dns_cache) {
+ if (!cfg_get(core, core_cfg, use_dns_cache)) {
rpc->fault(c, 500, "dns cache support disabled");
return;
}
int i;
ticks_t now;
- if (!use_dns_cache){
+ if (!cfg_get(core, core_cfg, use_dns_cache)){
rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
return;
}
ticks_t now;
str s;
- if (!use_dns_cache){
+ if (!cfg_get(core, core_cfg, use_dns_cache)){
rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
return;
}
/* deletes all the entries from the cache */
void dns_cache_delete_all(rpc_t* rpc, void* ctx)
{
- if (!use_dns_cache){
+ if (!cfg_get(core, core_cfg, use_dns_cache)){
rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
return;
}
ip_addr = 0;
size = 0;
- if (!use_dns_cache){
+ if (!cfg_get(core, core_cfg, use_dns_cache)){
rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
return;
}
str name;
int err, h, found=0;
- if (!use_dns_cache){
+ if (!cfg_get(core, core_cfg, use_dns_cache)){
rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
return;
}
{
int state;
- if (!use_dns_cache){
+ if (!cfg_get(core, core_cfg, use_dns_cache)){
rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
return;
}
/* prints the DNS server state */
void dns_get_server_state_rpc(rpc_t* rpc, void* ctx)
{
- if (!use_dns_cache){
+ if (!cfg_get(core, core_cfg, use_dns_cache)){
rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
return;
}
void fix_dns_flags(str *name);
int use_dns_failover_fixup(void *handle, str *name, void **val);
+int use_dns_cache_fixup(void *handle, str *name, void **val);
int dns_cache_max_mem_fixup(void *handle, str *name, void **val);
int init_dns_cache();
#ifdef USE_DNS_CACHE_STATS
ones. The last-recently used entries are deleted first.
Default: no
+ dns_cache_init = on | off - if off, the dns cache is not initialized
+ at startup and cannot be enabled runtime, that saves some memory.
+ Default: on
DNS Cache Compile Options
dst_blacklist_gc_interval = time in s (default 60 s) - how often the
garbage collection will run (eliminating old, expired entries).
+ dst_blacklist_init = on | off (default on) - if off, the blacklist
+ is not initialized at startup and cannot be enabled runtime,
+ that saves some memory.
Compile Options
* 2007-06-26 added hooks for search (andrei)
* 2007-07-30 added dst_blacklist_del() and dst_blacklist_add_to() (andrei)
* 2007-07-30 dst blacklist measurements added (Gergo)
+ * 2008-02-11 dns_blacklist_init cfg parameter is introduced (Miklos)
*/
#endif
};
+int dst_blacklist_init=1; /* if 0, the dst blacklist is not initialized at startup */
static struct timer_ln* blst_timer_h=0;
static volatile unsigned int* blst_mem_used=0;
struct blacklist_hook* tmp;
int new_max_hooks;
+ if (dst_blacklist_init==0) {
+ LOG(L_ERR, "register_blacklist_hook: blacklist is turned off, "
+ "the hook cannot be registered\n");
+ goto error;
+ }
+
switch(type){
case DST_BLACKLIST_ADD_CB:
cb_lst=&blst_add_cb;
blst_timer_h=0;
}
#ifdef BLST_LOCK_PER_BUCKET
+ if (dst_blst_hash)
for(r=0; r<DST_BLST_HASH_SIZE; r++)
lock_destroy(&dst_blst_hash[r].lock);
#elif defined BLST_LOCK_SET
int r;
#endif
+ if (dst_blacklist_init==0) {
+ /* the dst blacklist is turned off */
+ default_core_cfg.use_dst_blacklist=0;
+ return 0;
+ }
+
ret=-1;
#ifdef DST_BLACKLIST_HOOKS
if (init_blacklist_hooks()!=0){
#ifdef USE_DST_BLACKLIST_STATS
int init_dst_blacklist_stats(int iproc_num)
{
+ /* do not initialize the stats array if the dst blacklist will not be used */
+ if (dst_blacklist_init==0) return 0;
+
/* if it is already initialized */
if (dst_blacklist_stats)
shm_free(dst_blacklist_stats);
rpc->fault(ctx, 400, "Failed to add the entry to the blacklist");
}
+/* fixup function for use_dst_blacklist
+ * verifies that dst_blacklist_init is set to 1
+ */
+int use_dst_blacklist_fixup(void *handle, str *name, void **val)
+{
+ if ((int)(long)(*val) && !dst_blacklist_init) {
+ LOG(L_ERR, "ERROR: use_dst_blacklist_fixup(): "
+ "dst blacklist is turned off by dst_blacklist_init=0, "
+ "it cannot be enabled runtime.\n");
+ return -1;
+ }
+ return 0;
+}
+
/* KByte to Byte conversion */
int blst_max_mem_fixup(void *handle, str *name, void **val)
{
*/
void dst_blst_flush(void);
+int use_dst_blacklist_fixup(void *handle, str *name, void **val);
/* KByte to Byte conversion */
int blst_max_mem_fixup(void *handle, str *name, void **val);
#ifdef USE_DNS_CACHE
-extern int use_dns_cache; /* 1 if the cache is enabled, 0 otherwise */
+extern int dns_cache_init; /* if 0, the DNS cache is not initialized at startup */
extern unsigned int dns_timer_interval; /* gc timer interval in s */
extern int dns_flags; /* default flags used for the dns_*resolvehost
(compatibility wrappers) */
#endif /* USE_DNS_CACHE_STATS */
#endif
#ifdef USE_DST_BLACKLIST
+extern int dst_blacklist_init; /* if 0, the dst blacklist is not initialized at startup */
extern unsigned int blst_timer_interval; /*blacklist gc timer interval (in s)*/
#ifdef USE_DST_BLACKLIST_STATS
int mcast_loopback = 0;
int mcast_ttl = -1; /* if -1, don't touch it, use the default (usually 1) */
#endif /* USE_MCAST */
-#ifdef USE_DNS_CACHE
-int use_dns_cache=1; /* 1 if the cache is enabled, 0 otherwise */
-#endif
int tos = IPTOS_LOWDELAY;
int pmtu_discovery = 0;
goto error;
}
#ifdef USE_DNS_CACHE
- if (use_dns_cache && init_dns_cache()<0){
+ if (init_dns_cache()<0){
LOG(L_CRIT, "could not initialize the dns cache, exiting...\n");
goto error;
}
- if (use_dns_cache==0)
- default_core_cfg.use_dns_failover=0; /* cannot work w/o dns_cache support */
#ifdef USE_DNS_CACHE_STATS
/* preinitializing before the nubmer of processes is determined */
if (init_dns_cache_stats(1)<0){