mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
max ttl option.
git-svn-id: file:///svn/unbound/trunk@721 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
63dc8ffde2
commit
fe44f5918a
14 changed files with 918 additions and 838 deletions
|
|
@ -117,6 +117,7 @@ apply_dir(struct daemon* daemon, struct config_file* cfg, int cmdline_verbose)
|
||||||
/* apply if they have changed */
|
/* apply if they have changed */
|
||||||
daemon->cfg = cfg;
|
daemon->cfg = cfg;
|
||||||
verbosity = cmdline_verbose + cfg->verbosity;
|
verbosity = cmdline_verbose + cfg->verbosity;
|
||||||
|
config_apply(cfg);
|
||||||
if(cfg->directory && cfg->directory[0]) {
|
if(cfg->directory && cfg->directory[0]) {
|
||||||
if(!daemon->cwd || strcmp(daemon->cwd, cfg->directory) != 0) {
|
if(!daemon->cwd || strcmp(daemon->cwd, cfg->directory) != 0) {
|
||||||
if(chdir(cfg->directory)) {
|
if(chdir(cfg->directory)) {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
31 October 2007: Wouter
|
||||||
|
- cache-max-ttl config option.
|
||||||
|
|
||||||
30 October 2007: Wouter
|
30 October 2007: Wouter
|
||||||
- fixup assertion failure that relied on compressed names to be
|
- fixup assertion failure that relied on compressed names to be
|
||||||
smaller than uncompressed names. A packet from comrite.com was seen
|
smaller than uncompressed names. A packet from comrite.com was seen
|
||||||
|
|
|
||||||
3
doc/TODO
3
doc/TODO
|
|
@ -52,6 +52,3 @@ o make timeout backoffs randomized (a couple percent random) to spread traffic.
|
||||||
o inspect date on executable, then warn user in log if its more than 1 year.
|
o inspect date on executable, then warn user in log if its more than 1 year.
|
||||||
o proactively prime root, stubs and trust anchors, feature.
|
o proactively prime root, stubs and trust anchors, feature.
|
||||||
early failure, faster on first query, but more traffic.
|
early failure, faster on first query, but more traffic.
|
||||||
o look into whether in incoming message should have RRsets replaced with
|
|
||||||
rrsets from the cache, if the one from the cache is more trusted, or has
|
|
||||||
lower TTL.
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,10 @@ server:
|
||||||
# more slabs reduce lock contention, but fragment memory usage.
|
# more slabs reduce lock contention, but fragment memory usage.
|
||||||
# rrset-cache-slabs: 4
|
# rrset-cache-slabs: 4
|
||||||
|
|
||||||
|
# the time to live (TTL) value cap for RRsets and messages in the
|
||||||
|
# cache. Items are not cached for longer. In seconds.
|
||||||
|
# cache-max-ttl: 864000
|
||||||
|
|
||||||
# the time to live (TTL) value for cached roundtrip times and
|
# the time to live (TTL) value for cached roundtrip times and
|
||||||
# EDNS version information for hosts. In seconds.
|
# EDNS version information for hosts. In seconds.
|
||||||
# infra-host-ttl: 900
|
# infra-host-ttl: 900
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,13 @@ Number of bytes size of the RRset cache. Default is 4 megabytes.
|
||||||
.It \fBrrset-cache-slabs:\fR <number>
|
.It \fBrrset-cache-slabs:\fR <number>
|
||||||
Number of slabs in the RRset cache. Slabs reduce lock contention by threads.
|
Number of slabs in the RRset cache. Slabs reduce lock contention by threads.
|
||||||
Must be set to a power of 2.
|
Must be set to a power of 2.
|
||||||
|
.It \fBcache-max-ttl:\fR <seconds>
|
||||||
|
Time to live maximum for RRsets and messages in the cache. Default is
|
||||||
|
864000 seconds (10 days). If the maximum kicks in, responses to clients
|
||||||
|
still get decrementing TTLs based on the original (larger) values.
|
||||||
|
When the internal TTL expires, the cache item has expired.
|
||||||
|
Can be set lower to force the resolver to query for data often, and not
|
||||||
|
trust (very large) TTL values.
|
||||||
.It \fBinfra-host-ttl:\fR <seconds>
|
.It \fBinfra-host-ttl:\fR <seconds>
|
||||||
Time to live for entries in the host cache. The host cache contains
|
Time to live for entries in the host cache. The host cache contains
|
||||||
roundtrip timing and EDNS support information. Default is 900.
|
roundtrip timing and EDNS support information. Default is 900.
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ config_create()
|
||||||
cfg->host_ttl = 900;
|
cfg->host_ttl = 900;
|
||||||
cfg->lame_ttl = 900;
|
cfg->lame_ttl = 900;
|
||||||
cfg->bogus_ttl = 900;
|
cfg->bogus_ttl = 900;
|
||||||
|
cfg->max_ttl = 3600 * 24 * 10;
|
||||||
cfg->infra_cache_slabs = 4;
|
cfg->infra_cache_slabs = 4;
|
||||||
cfg->infra_cache_numhosts = 10000;
|
cfg->infra_cache_numhosts = 10000;
|
||||||
cfg->infra_cache_lame_size = 10240; /* easily 40 or more entries */
|
cfg->infra_cache_lame_size = 10240; /* easily 40 or more entries */
|
||||||
|
|
@ -325,3 +326,12 @@ cfg_count_numbers(const char* s)
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the MAX_TTL global */
|
||||||
|
extern uint32_t MAX_TTL;
|
||||||
|
|
||||||
|
void
|
||||||
|
config_apply(struct config_file* config)
|
||||||
|
{
|
||||||
|
MAX_TTL = (uint32_t)config->max_ttl;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,8 @@ struct config_file {
|
||||||
/** files with trusted DNSKEYs in named.conf format, list */
|
/** files with trusted DNSKEYs in named.conf format, list */
|
||||||
struct config_strlist* trusted_keys_file_list;
|
struct config_strlist* trusted_keys_file_list;
|
||||||
|
|
||||||
|
/** the number of seconds maximal TTL used for RRsets and messages */
|
||||||
|
int max_ttl;
|
||||||
/** if not 0, this value is the validation date for RRSIGs */
|
/** if not 0, this value is the validation date for RRSIGs */
|
||||||
int32_t val_date_override;
|
int32_t val_date_override;
|
||||||
/** this value sets the number of seconds before revalidating bogus */
|
/** this value sets the number of seconds before revalidating bogus */
|
||||||
|
|
@ -227,6 +229,12 @@ int config_read(struct config_file* config, char* filename);
|
||||||
*/
|
*/
|
||||||
void config_delete(struct config_file* config);
|
void config_delete(struct config_file* config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply config to global constants; this routine is called in single thread.
|
||||||
|
* @param config: to apply. Side effect: global constants change.
|
||||||
|
*/
|
||||||
|
void config_apply(struct config_file* config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert string into strlist.
|
* Insert string into strlist.
|
||||||
* @param head: pointer to strlist head variable.
|
* @param head: pointer to strlist head variable.
|
||||||
|
|
|
||||||
1140
util/configlexer.c
1140
util/configlexer.c
File diff suppressed because it is too large
Load diff
|
|
@ -123,6 +123,7 @@ msg-cache-size{COLON} { YDOUT; return VAR_MSG_CACHE_SIZE;}
|
||||||
msg-cache-slabs{COLON} { YDOUT; return VAR_MSG_CACHE_SLABS;}
|
msg-cache-slabs{COLON} { YDOUT; return VAR_MSG_CACHE_SLABS;}
|
||||||
rrset-cache-size{COLON} { YDOUT; return VAR_RRSET_CACHE_SIZE;}
|
rrset-cache-size{COLON} { YDOUT; return VAR_RRSET_CACHE_SIZE;}
|
||||||
rrset-cache-slabs{COLON} { YDOUT; return VAR_RRSET_CACHE_SLABS;}
|
rrset-cache-slabs{COLON} { YDOUT; return VAR_RRSET_CACHE_SLABS;}
|
||||||
|
cache-max-ttl{COLON} { YDOUT; return VAR_CACHE_MAX_TTL;}
|
||||||
infra-host-ttl{COLON} { YDOUT; return VAR_INFRA_HOST_TTL;}
|
infra-host-ttl{COLON} { YDOUT; return VAR_INFRA_HOST_TTL;}
|
||||||
infra-lame-ttl{COLON} { YDOUT; return VAR_INFRA_LAME_TTL;}
|
infra-lame-ttl{COLON} { YDOUT; return VAR_INFRA_LAME_TTL;}
|
||||||
infra-cache-slabs{COLON} { YDOUT; return VAR_INFRA_CACHE_SLABS;}
|
infra-cache-slabs{COLON} { YDOUT; return VAR_INFRA_CACHE_SLABS;}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -106,7 +106,8 @@
|
||||||
VAR_USE_SYSLOG = 322,
|
VAR_USE_SYSLOG = 322,
|
||||||
VAR_OUTGOING_INTERFACE = 323,
|
VAR_OUTGOING_INTERFACE = 323,
|
||||||
VAR_ROOT_HINTS = 324,
|
VAR_ROOT_HINTS = 324,
|
||||||
VAR_DO_NOT_QUERY_LOCALHOST = 325
|
VAR_DO_NOT_QUERY_LOCALHOST = 325,
|
||||||
|
VAR_CACHE_MAX_TTL = 326
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
|
|
@ -178,6 +179,7 @@
|
||||||
#define VAR_OUTGOING_INTERFACE 323
|
#define VAR_OUTGOING_INTERFACE 323
|
||||||
#define VAR_ROOT_HINTS 324
|
#define VAR_ROOT_HINTS 324
|
||||||
#define VAR_DO_NOT_QUERY_LOCALHOST 325
|
#define VAR_DO_NOT_QUERY_LOCALHOST 325
|
||||||
|
#define VAR_CACHE_MAX_TTL 326
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -189,7 +191,7 @@ typedef union YYSTYPE
|
||||||
char* str;
|
char* str;
|
||||||
}
|
}
|
||||||
/* Line 1489 of yacc.c. */
|
/* Line 1489 of yacc.c. */
|
||||||
#line 193 "util/configparser.h"
|
#line 195 "util/configparser.h"
|
||||||
YYSTYPE;
|
YYSTYPE;
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ extern struct config_parser_state* cfg_parser;
|
||||||
%token VAR_KEY_CACHE_SLABS VAR_TRUSTED_KEYS_FILE
|
%token VAR_KEY_CACHE_SLABS VAR_TRUSTED_KEYS_FILE
|
||||||
%token VAR_VAL_NSEC3_KEYSIZE_ITERATIONS VAR_USE_SYSLOG
|
%token VAR_VAL_NSEC3_KEYSIZE_ITERATIONS VAR_USE_SYSLOG
|
||||||
%token VAR_OUTGOING_INTERFACE VAR_ROOT_HINTS VAR_DO_NOT_QUERY_LOCALHOST
|
%token VAR_OUTGOING_INTERFACE VAR_ROOT_HINTS VAR_DO_NOT_QUERY_LOCALHOST
|
||||||
|
%token VAR_CACHE_MAX_TTL
|
||||||
|
|
||||||
%%
|
%%
|
||||||
toplevelvars: /* empty */ | toplevelvars toplevelvar ;
|
toplevelvars: /* empty */ | toplevelvars toplevelvar ;
|
||||||
|
|
@ -122,7 +123,7 @@ content_server: server_num_threads | server_verbosity | server_port |
|
||||||
server_key_cache_size | server_key_cache_slabs |
|
server_key_cache_size | server_key_cache_slabs |
|
||||||
server_trusted_keys_file | server_val_nsec3_keysize_iterations |
|
server_trusted_keys_file | server_val_nsec3_keysize_iterations |
|
||||||
server_use_syslog | server_outgoing_interface | server_root_hints |
|
server_use_syslog | server_outgoing_interface | server_root_hints |
|
||||||
server_do_not_query_localhost
|
server_do_not_query_localhost | server_cache_max_ttl
|
||||||
;
|
;
|
||||||
stubstart: VAR_STUB_ZONE
|
stubstart: VAR_STUB_ZONE
|
||||||
{
|
{
|
||||||
|
|
@ -587,6 +588,15 @@ server_val_override_date: VAR_VAL_OVERRIDE_DATE STRING
|
||||||
free($2);
|
free($2);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
server_cache_max_ttl: VAR_CACHE_MAX_TTL STRING
|
||||||
|
{
|
||||||
|
OUTYY(("P(server_cache_max_ttl:%s)\n", $2));
|
||||||
|
if(atoi($2) == 0 && strcmp($2, "0") != 0)
|
||||||
|
yyerror("number expected");
|
||||||
|
else cfg_parser->cfg->max_ttl = atoi($2);
|
||||||
|
free($2);
|
||||||
|
}
|
||||||
|
;
|
||||||
server_bogus_ttl: VAR_BOGUS_TTL STRING
|
server_bogus_ttl: VAR_BOGUS_TTL STRING
|
||||||
{
|
{
|
||||||
OUTYY(("P(server_bogus_ttl:%s)\n", $2));
|
OUTYY(("P(server_bogus_ttl:%s)\n", $2));
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ struct regional;
|
||||||
/** number of buckets in parse rrset hash table. Must be power of 2. */
|
/** number of buckets in parse rrset hash table. Must be power of 2. */
|
||||||
#define PARSE_TABLE_SIZE 1024
|
#define PARSE_TABLE_SIZE 1024
|
||||||
/** Maximum TTL that is allowed. */
|
/** Maximum TTL that is allowed. */
|
||||||
#define MAX_TTL 3600*24*365*10 /* ten years */
|
extern uint32_t MAX_TTL;
|
||||||
/** Negative cache time (for entries without any RRs.) */
|
/** Negative cache time (for entries without any RRs.) */
|
||||||
#define NORR_TTL 5 /* seconds */
|
#define NORR_TTL 5 /* seconds */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@
|
||||||
#include "util/data/msgparse.h"
|
#include "util/data/msgparse.h"
|
||||||
#include "util/data/msgencode.h"
|
#include "util/data/msgencode.h"
|
||||||
|
|
||||||
|
/** MAX TTL default for messages and rrsets */
|
||||||
|
uint32_t MAX_TTL = 3600 * 24 * 10; /* ten days */
|
||||||
|
|
||||||
/** allocate qinfo, return 0 on error */
|
/** allocate qinfo, return 0 on error */
|
||||||
static int
|
static int
|
||||||
parse_create_qinfo(ldns_buffer* pkt, struct msg_parse* msg,
|
parse_create_qinfo(ldns_buffer* pkt, struct msg_parse* msg,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue