edns-buffer-size option.

git-svn-id: file:///svn/unbound/trunk@1881 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2009-10-29 10:37:44 +00:00
parent 81cfcd8053
commit 5b66f07e38
13 changed files with 1507 additions and 1422 deletions

View file

@ -1,5 +1,6 @@
29 October 2009: Wouter
- iana portlist updated.
- edns-buffer-size option, default 4096.
28 October 2009: Wouter
- removed abort on prealloc failure, error still printed but softfail.

View file

@ -77,6 +77,10 @@ server:
# 0 is system default. Use 4m to catch query spikes for busy servers.
# so-rcvbuf: 0
# EDNS reassembly buffer to advertise to UDP peers (the actual buffer
# is set with msg-buffer-size). 1480 can solve fragmentation (timeouts).
# edns-buffer-size: 4096
# buffer size for handling DNS data. No messages larger than this
# size can be sent or received, by UDP or TCP. In bytes.
# msg-buffer-size: 65552

View file

@ -165,6 +165,17 @@ to 0, or if do_tcp is "no", no TCP queries to authoritative servers are done.
Number of incoming TCP buffers to allocate per thread. Default is 10. If set
to 0, or if do_tcp is "no", no TCP queries from clients are accepted.
.TP
.B edns\-buffer\-size: \fI<number>
Number of bytes size to advertise as the EDNS reassembly buffer size.
This is the value put into datagrams over UDP towards peers. The actual
buffer size is determined by msg\-buffer\-size (both for TCP and UDP). Do
not set lower than that value. Default is 4096 which is RFC recommended.
If you have fragmentation reassembly problems, usually seen as timeouts,
then a value of 1480 can fix it. Setting to 512 bypasses even the most
stringent path MTU problems, but is seen as extreme, since the amount
of TCP fallback generated is excessive (probably also for this resolver,
consider tuning the outgoing tcp number).
.TP
.B msg\-buffer\-size: \fI<number>
Number of bytes size of the message buffers. Default is 65552 bytes, enough
for 64 Kb packets, the maximum DNS message size. No message larger than this

View file

@ -135,6 +135,7 @@ print_option(struct config_file* cfg, const char* opt)
else O_DEC(opt, "outgoing-range", outgoing_num_ports)
else O_DEC(opt, "outgoing-num-tcp", outgoing_num_tcp)
else O_DEC(opt, "incoming-num-tcp", incoming_num_tcp)
else O_DEC(opt, "edns-buffer-size", edns_buffer_size)
else O_DEC(opt, "msg-buffer-size", msg_buffer_size)
else O_MEM(opt, "msg-cache-size", msg_cache_size)
else O_DEC(opt, "msg-cache-slabs", msg_cache_slabs)
@ -442,6 +443,9 @@ morechecks(struct config_file* cfg, const char* fname)
fatal_exit("ip4 and ip6 are both disabled, pointless");
if(!cfg->do_udp && !cfg->do_tcp)
fatal_exit("udp and tcp are both disabled, pointless");
if(cfg->edns_buffer_size > cfg->msg_buffer_size)
fatal_exit("edns-buffer-size larger than msg-buffer-size, "
"answers will not fit in processing buffer");
if(cfg->chrootdir && cfg->chrootdir[0] &&
cfg->chrootdir[strlen(cfg->chrootdir)-1] == '/')

View file

@ -95,6 +95,7 @@ config_create()
cfg->outgoing_num_tcp = 2; /* leaves 64-52=12 for: 4if,1stop,thread4 */
cfg->incoming_num_tcp = 2;
#endif
cfg->edns_buffer_size = 4096; /* 4k from rfc recommendation */
cfg->msg_buffer_size = 65552; /* 64 k + a small margin */
cfg->msg_cache_size = 4 * 1024 * 1024;
cfg->msg_cache_slabs = 4;
@ -277,6 +278,9 @@ int config_set_option(struct config_file* cfg, const char* opt,
} else if(strcmp(opt, "incoming-num-tcp:") == 0) {
IS_NUMBER_OR_ZERO;
cfg->incoming_num_tcp = (size_t)atoi(val);
} else if(strcmp(opt, "edns-buffer-size:") == 0) {
IS_NONZERO_NUMBER;
cfg->edns_buffer_size = (size_t)atoi(val);
} else if(strcmp(opt, "msg-buffer-size:") == 0) {
IS_NONZERO_NUMBER;
cfg->msg_buffer_size = (size_t)atoi(val);
@ -850,6 +854,7 @@ config_apply(struct config_file* config)
{
MAX_TTL = (uint32_t)config->max_ttl;
MIN_TTL = (uint32_t)config->min_ttl;
EDNS_ADVERTISED_SIZE = (uint16_t)config->edns_buffer_size;
log_set_time_asc(config->log_time_ascii);
}

View file

@ -86,6 +86,8 @@ struct config_file {
/** allowed udp port numbers, array with 0 if not allowed */
int* outgoing_avail_ports;
/** EDNS buffer size to use */
size_t edns_buffer_size;
/** number of bytes buffer size for DNS messages */
size_t msg_buffer_size;
/** size of the message cache */

File diff suppressed because it is too large Load diff

View file

@ -149,6 +149,7 @@ directory{COLON} { YDVAR(1, VAR_DIRECTORY) }
logfile{COLON} { YDVAR(1, VAR_LOGFILE) }
pidfile{COLON} { YDVAR(1, VAR_PIDFILE) }
root-hints{COLON} { YDVAR(1, VAR_ROOT_HINTS) }
edns-buffer-size{COLON} { YDVAR(1, VAR_EDNS_BUFFER_SIZE) }
msg-buffer-size{COLON} { YDVAR(1, VAR_MSG_BUFFER_SIZE) }
msg-cache-size{COLON} { YDVAR(1, VAR_MSG_CACHE_SIZE) }
msg-cache-slabs{COLON} { YDVAR(1, VAR_MSG_CACHE_SLABS) }

File diff suppressed because it is too large Load diff

View file

@ -149,7 +149,8 @@
VAR_KEEP_MISSING = 365,
VAR_ADD_HOLDDOWN = 366,
VAR_DEL_HOLDDOWN = 367,
VAR_SO_RCVBUF = 368
VAR_SO_RCVBUF = 368,
VAR_EDNS_BUFFER_SIZE = 369
};
#endif
/* Tokens. */
@ -264,6 +265,7 @@
#define VAR_ADD_HOLDDOWN 366
#define VAR_DEL_HOLDDOWN 367
#define VAR_SO_RCVBUF 368
#define VAR_EDNS_BUFFER_SIZE 369
@ -280,7 +282,7 @@ typedef union YYSTYPE
/* Line 1676 of yacc.c */
#line 284 "util/configparser.h"
#line 286 "util/configparser.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */

View file

@ -100,7 +100,7 @@ extern struct config_parser_state* cfg_parser;
%token VAR_DOMAIN_INSECURE VAR_PYTHON VAR_PYTHON_SCRIPT VAR_VAL_SIG_SKEW_MIN
%token VAR_VAL_SIG_SKEW_MAX VAR_CACHE_MIN_TTL VAR_VAL_LOG_LEVEL
%token VAR_AUTO_TRUST_ANCHOR_FILE VAR_KEEP_MISSING VAR_ADD_HOLDDOWN
%token VAR_DEL_HOLDDOWN VAR_SO_RCVBUF
%token VAR_DEL_HOLDDOWN VAR_SO_RCVBUF VAR_EDNS_BUFFER_SIZE
%%
toplevelvars: /* empty */ | toplevelvars toplevelvar ;
@ -152,7 +152,8 @@ content_server: server_num_threads | server_verbosity | server_port |
server_domain_insecure | server_val_sig_skew_min |
server_val_sig_skew_max | server_cache_min_ttl | server_val_log_level |
server_auto_trust_anchor_file | server_add_holddown |
server_del_holddown | server_keep_missing | server_so_rcvbuf
server_del_holddown | server_keep_missing | server_so_rcvbuf |
server_edns_buffer_size
;
stubstart: VAR_STUB_ZONE
{
@ -527,6 +528,19 @@ server_so_rcvbuf: VAR_SO_RCVBUF STRING_ARG
free($2);
}
;
server_edns_buffer_size: VAR_EDNS_BUFFER_SIZE STRING_ARG
{
OUTYY(("P(server_edns_buffer_size:%s)\n", $2));
if(atoi($2) == 0)
yyerror("number expected");
else if (atoi($2) < 12)
yyerror("edns buffer size too small");
else if (atoi($2) > 65535)
cfg_parser->cfg->edns_buffer_size = 65535;
else cfg_parser->cfg->edns_buffer_size = atoi($2);
free($2);
}
;
server_msg_buffer_size: VAR_MSG_BUFFER_SIZE STRING_ARG
{
OUTYY(("P(server_msg_buffer_size:%s)\n", $2));

View file

@ -47,6 +47,8 @@
/** max length of an IP address (the address portion) that we allow */
#define MAX_ADDR_STRLEN 128 /* characters */
/** default value for EDNS ADVERTISED size */
uint16_t EDNS_ADVERTISED_SIZE = 4096;
/* returns true is string addr is an ip6 specced address */
int

View file

@ -80,7 +80,7 @@ struct regional;
/** Advertised version of EDNS capabilities */
#define EDNS_ADVERTISED_VERSION 0
/** Advertised size of EDNS capabilities */
#define EDNS_ADVERTISED_SIZE 4096
extern uint16_t EDNS_ADVERTISED_SIZE;
/** bits for EDNS bitfield */
#define EDNS_DO 0x8000 /* Dnssec Ok */
/** byte size of ip4 address */