dlv negative cache size option.

git-svn-id: file:///svn/unbound/trunk@1213 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2008-08-27 13:02:22 +00:00
parent e474ca2619
commit 21cd9936d8
13 changed files with 1021 additions and 979 deletions

View file

@ -1,8 +1,11 @@
27 August 2008: Wouter
- daemon(3) is causing problems for people. Reverting the patch.
bug#200, and 199 and 203 contain sideline discussion on it.
- bug#199: pidfile can be outside chroot. openlog is done before
- bug#199 fixed: pidfile can be outside chroot. openlog is done before
chroot and drop permissions.
- config option to set size of aggressive negative cache,
neg-cache-size.
- bug#203 fixed: dlv has been implemented.
26 August 2008: Wouter
- test for insecure zone when DLV is in use, also does negative cache.

View file

@ -307,6 +307,10 @@ server:
# the number of slabs must be a power of 2.
# more slabs reduce lock contention, but fragment memory usage.
# key-cache-slabs: 4
# the amount of memory to use for the negative cache (used for DLV).
# plain value in bytes or you can append k, m or G. default is "1Mb".
# neg-cache-size: 1m
# a number of locally served zones can be configured.
# local-zone: <zone> <type>

View file

@ -472,6 +472,11 @@ Number of slabs in the key cache. Slabs reduce lock contention by threads.
Must be set to a power of 2. Setting (close) to the number of cpus is a
reasonable guess.
.TP
.B neg\-cache\-size: \fI<number>
Number of bytes size of the aggressive negative cache. Default is 1 megabyte.
A plain number is in bytes, append 'k', 'm' or 'g' for kilobytes, megabytes
or gigabytes (1024*1024 bytes in a megabyte).
.TP
.B local\-zone: \fI<zone> <type>
Configure a local zone. The type determines the answer to give if there is
no match from local\-data. The types are deny, refuse, static, transparent,
@ -689,6 +694,7 @@ server:
infra\-cache\-lame\-size: 1k
key\-cache\-size: 100k
key\-cache\-slabs: 1
neg\-cache\-size: 10k
num\-queries\-per\-thread: 30
target\-fetch\-policy: "2 1 0 0 0 0"
harden\-large\-queries: "yes"

View file

@ -144,6 +144,7 @@ config_create()
cfg->val_permissive_mode = 0;
cfg->key_cache_size = 4 * 1024 * 1024;
cfg->key_cache_slabs = 4;
cfg->neg_cache_size = 1 * 1024 * 1024;
cfg->local_zones = NULL;
cfg->local_zones_nodefault = NULL;
cfg->local_data = NULL;
@ -175,6 +176,7 @@ struct config_file* config_create_forlib()
cfg->use_syslog = 0;
cfg->key_cache_size = 1024*1024;
cfg->key_cache_slabs = 1;
cfg->neg_cache_size = 100 * 1024;
cfg->donotquery_localhost = 0; /* allow, so that you can ask a
forward nameserver running on localhost */
return cfg;
@ -339,6 +341,8 @@ int config_set_option(struct config_file* cfg, const char* opt,
} else if(strcmp(opt, "key-cache-slabs:") == 0) {
IS_POW2_NUMBER;
cfg->key_cache_slabs = (size_t)atoi(val);
} else if(strcmp(opt, "neg-cache-size:") == 0) {
return cfg_parse_memsize(val, &cfg->neg_cache_size);
} else if(strcmp(opt, "local-data:") == 0) {
return cfg_strlist_insert(&cfg->local_data, strdup(val));
} else if(strcmp(opt, "module-config:") == 0) {

View file

@ -200,6 +200,8 @@ struct config_file {
size_t key_cache_size;
/** slabs in the key cache. */
size_t key_cache_slabs;
/** size of the neg cache */
size_t neg_cache_size;
/** local zones config */
struct config_str2list* local_zones;

File diff suppressed because it is too large Load diff

View file

@ -174,6 +174,7 @@ val-clean-additional{COLON} { YDOUT; return VAR_VAL_CLEAN_ADDITIONAL;}
val-permissive-mode{COLON} { YDOUT; return VAR_VAL_PERMISSIVE_MODE;}
key-cache-size{COLON} { YDOUT; return VAR_KEY_CACHE_SIZE;}
key-cache-slabs{COLON} { YDOUT; return VAR_KEY_CACHE_SLABS;}
neg-cache-size{COLON} { YDOUT; return VAR_NEG_CACHE_SIZE;}
val-nsec3-keysize-iterations{COLON} { YDOUT; return VAR_VAL_NSEC3_KEYSIZE_ITERATIONS;}
use-syslog{COLON} { YDOUT; return VAR_USE_SYSLOG;}
local-zone{COLON} { YDOUT; return VAR_LOCAL_ZONE;}

File diff suppressed because it is too large Load diff

View file

@ -119,7 +119,8 @@
VAR_OUTGOING_PORT_PERMIT = 335,
VAR_OUTGOING_PORT_AVOID = 336,
VAR_DLV_ANCHOR_FILE = 337,
VAR_DLV_ANCHOR = 338
VAR_DLV_ANCHOR = 338,
VAR_NEG_CACHE_SIZE = 339
};
#endif
/* Tokens. */
@ -204,6 +205,7 @@
#define VAR_OUTGOING_PORT_AVOID 336
#define VAR_DLV_ANCHOR_FILE 337
#define VAR_DLV_ANCHOR 338
#define VAR_NEG_CACHE_SIZE 339
@ -215,7 +217,7 @@ typedef union YYSTYPE
char* str;
}
/* Line 1489 of yacc.c. */
#line 219 "util/configparser.h"
#line 221 "util/configparser.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1

View file

@ -91,6 +91,7 @@ extern struct config_parser_state* cfg_parser;
%token VAR_STATISTICS_INTERVAL VAR_DO_DAEMONIZE VAR_USE_CAPS_FOR_ID
%token VAR_STATISTICS_CUMULATIVE VAR_OUTGOING_PORT_PERMIT
%token VAR_OUTGOING_PORT_AVOID VAR_DLV_ANCHOR_FILE VAR_DLV_ANCHOR
%token VAR_NEG_CACHE_SIZE
%%
toplevelvars: /* empty */ | toplevelvars toplevelvar ;
@ -133,7 +134,7 @@ content_server: server_num_threads | server_verbosity | server_port |
server_statistics_interval | server_do_daemonize |
server_use_caps_for_id | server_statistics_cumulative |
server_outgoing_port_permit | server_outgoing_port_avoid |
server_dlv_anchor_file | server_dlv_anchor
server_dlv_anchor_file | server_dlv_anchor | server_neg_cache_size
;
stubstart: VAR_STUB_ZONE
{
@ -756,6 +757,14 @@ server_key_cache_slabs: VAR_KEY_CACHE_SLABS STRING
free($2);
}
;
server_neg_cache_size: VAR_NEG_CACHE_SIZE STRING
{
OUTYY(("P(server_neg_cache_size:%s)\n", $2));
if(!cfg_parse_memsize($2, &cfg_parser->cfg->neg_cache_size))
yyerror("memory size expected");
free($2);
}
;
server_local_zone: VAR_LOCAL_ZONE STRING STRING
{
OUTYY(("P(server_local_zone:%s %s)\n", $2, $3));

View file

@ -48,6 +48,7 @@
#include "util/data/msgreply.h"
#include "util/log.h"
#include "util/net_help.h"
#include "util/config_file.h"
#include "services/cache/rrset.h"
int val_neg_data_compare(const void* a, const void* b)
@ -71,7 +72,7 @@ int val_neg_zone_compare(const void* a, const void* b)
return dname_canon_lab_cmp(x->name, x->labs, y->name, y->labs, &m);
}
struct val_neg_cache* val_neg_create()
struct val_neg_cache* val_neg_create(struct config_file* cfg)
{
struct val_neg_cache* neg = (struct val_neg_cache*)calloc(1,
sizeof(*neg));
@ -80,18 +81,13 @@ struct val_neg_cache* val_neg_create()
return NULL;
}
neg->max = 1024*1024; /* 1 M is thousands of entries */
if(cfg) neg->max = cfg->neg_cache_size;
rbtree_init(&neg->tree, &val_neg_zone_compare);
lock_basic_init(&neg->lock);
lock_protect(&neg->lock, neg, sizeof(*neg));
return neg;
}
int val_neg_apply_cfg(struct val_neg_cache* neg, struct config_file* cfg)
{
/* TODO read max mem size from cfg */
return 1;
}
size_t val_neg_get_mem(struct val_neg_cache* neg)
{
size_t result;

View file

@ -151,17 +151,10 @@ struct val_neg_data {
/**
* Create negative cache
* @param cfg: config options.
* @return neg cache, empty or NULL on failure.
*/
struct val_neg_cache* val_neg_create();
/**
* Apply configuration settings to negative cache
* @param neg: negative cache.
* @param cfg: config options.
* @return false on error.
*/
int val_neg_apply_cfg(struct val_neg_cache* neg, struct config_file* cfg);
struct val_neg_cache* val_neg_create(struct config_file* cfg);
/**
* see how much memory is in use by the negative cache.

View file

@ -122,15 +122,11 @@ val_apply_cfg(struct module_env* env, struct val_env* val_env,
return 0;
}
if(!val_env->neg_cache)
val_env->neg_cache = val_neg_create();
val_env->neg_cache = val_neg_create(cfg);
if(!val_env->neg_cache) {
log_err("out of memory");
return 0;
}
if(!val_neg_apply_cfg(val_env->neg_cache, cfg)) {
log_err("validator: error in negative cache config");
return 0;
}
val_env->date_override = cfg->val_date_override;
c = cfg_count_numbers(cfg->val_nsec3_key_iterations);
if(c < 1 || (c&1)) {