From: Mark Andrews Date: Wed, 26 Feb 2003 02:04:00 +0000 (+0000) Subject: 1432. [func] The advertised EDNS UDP buffer size can now be set X-Git-Tag: v9.2.3rc1~104^2~99 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=e2fb08b85de8158fe6b71008311e3d98104b92a6;p=thirdparty%2Fbind9.git 1432. [func] The advertised EDNS UDP buffer size can now be set via named.conf (edns-udp-size). developer: marka reviewer: explorer --- diff --git a/CHANGES b/CHANGES index be896830e0b..f8a0d763f63 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +1432. [func] The advertised EDNS UDP buffer size can now be set + via named.conf (edns-udp-size). + 1431. [bug] isc_print_snprintf() "%s" with precision could walk of end of arguement. [RT #5191] diff --git a/bin/named/client.c b/bin/named/client.c index 5b24c684a2f..df14047736f 100644 --- a/bin/named/client.c +++ b/bin/named/client.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: client.c,v 1.214 2003/01/21 06:11:45 marka Exp $ */ +/* $Id: client.c,v 1.215 2003/02/26 02:03:57 marka Exp $ */ #include @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1028,6 +1029,9 @@ client_addopt(ns_client_t *client) { dns_rdatalist_t *rdatalist; dns_rdata_t *rdata; isc_result_t result; + dns_view_t *view; + dns_resolver_t *resolver; + isc_uint16_t udpsize; REQUIRE(client->opt == NULL); /* XXXRTH free old. */ @@ -1051,7 +1055,13 @@ client_addopt(ns_client_t *client) { /* * Set the maximum UDP buffer size. */ - rdatalist->rdclass = RECV_BUFFER_SIZE; + view = client->view; + resolver = (view != NULL) ? view->resolver : NULL; + if (resolver != NULL) + udpsize = dns_resolver_getudpsize(resolver); + else + udpsize = ns_g_udpsize; + rdatalist->rdclass = udpsize; /* * Set EXTENDED-RCODE, VERSION and Z to 0. diff --git a/bin/named/config.c b/bin/named/config.c index 597e8e96af0..02610d403fa 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: config.c,v 1.37 2003/02/04 06:10:08 marka Exp $ */ +/* $Id: config.c,v 1.38 2003/02/26 02:03:57 marka Exp $ */ #include @@ -91,6 +91,7 @@ options {\n\ treat-cr-as-space true;\n\ use-id-pool true;\n\ use-ixfr true;\n\ + edns-udp-size 4096;\n\ \n\ /* view */\n\ allow-notify {none;};\n\ diff --git a/bin/named/include/named/globals.h b/bin/named/include/named/globals.h index 87f9521d178..0c07831d6a6 100644 --- a/bin/named/include/named/globals.h +++ b/bin/named/include/named/globals.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: globals.h,v 1.60 2002/11/12 23:38:11 explorer Exp $ */ +/* $Id: globals.h,v 1.61 2003/02/26 02:03:58 marka Exp $ */ #ifndef NAMED_GLOBALS_H #define NAMED_GLOBALS_H 1 @@ -84,6 +84,7 @@ EXTERN const char * lwresd_g_resolvconffile INIT("/etc" "/resolv.conf"); EXTERN isc_boolean_t ns_g_conffileset INIT(ISC_FALSE); EXTERN isc_boolean_t lwresd_g_useresolvconf INIT(ISC_FALSE); +EXTERN isc_uint16_t ns_g_udpsize INIT(4096); /* * Initial resource limits. diff --git a/bin/named/server.c b/bin/named/server.c index 5ef855ee41e..6aa3e466170 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.394 2003/01/20 23:51:23 marka Exp $ */ +/* $Id: server.c,v 1.395 2003/02/26 02:03:58 marka Exp $ */ #include @@ -581,6 +581,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, int i; char *str; dns_order_t *order = NULL; + isc_uint32_t udpsize; REQUIRE(DNS_VIEW_VALID(view)); @@ -741,6 +742,19 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, lame_ttl = 1800; dns_resolver_setlamettl(view->resolver, lame_ttl); + /* + * Set the resolver's EDNS UDP size. + */ + obj = NULL; + result = ns_config_get(maps, "edns-udp-size", &obj); + INSIST(result == ISC_R_SUCCESS); + udpsize = cfg_obj_asuint32(obj); + if (udpsize < 512) + udpsize = 512; + if (udpsize > 4096) + udpsize = 4096; + dns_resolver_setudpsize(view->resolver, udpsize); + /* * A global or view "forwarders" option, if present, * creates an entry for "." in the forwarding table. @@ -1756,6 +1770,7 @@ load_configuration(const char *filename, ns_server_t *server, dns_dispatch_t *dispatchv6 = NULL; isc_uint32_t interface_interval; isc_uint32_t heartbeat_interval; + isc_uint32_t udpsize; in_port_t listen_port; int i; @@ -1856,6 +1871,19 @@ load_configuration(const char *filename, ns_server_t *server, INSIST(result == ISC_R_SUCCESS); server->aclenv.match_mapped = cfg_obj_asboolean(obj); + /* + * Set the EDNS UDP size when we don't match a view. + */ + obj = NULL; + result = ns_config_get(maps, "edns-udp-size", &obj); + INSIST(result == ISC_R_SUCCESS); + udpsize = cfg_obj_asuint32(obj); + if (udpsize < 512) + udpsize = 512; + if (udpsize > 4096) + udpsize = 4096; + ns_g_udpsize = udpsize; + /* * Configure the zone manager. */ diff --git a/doc/arm/Bv9ARM-book.xml b/doc/arm/Bv9ARM-book.xml index a9093fb8759..ca396c8165a 100644 --- a/doc/arm/Bv9ARM-book.xml +++ b/doc/arm/Bv9ARM-book.xml @@ -2,7 +2,7 @@ - + BIND 9 Administrator Reference Manual @@ -2782,6 +2782,7 @@ statement in the named.conf file: max-cache-size size_spec ; match-mapped-addresses yes_or_no; preferred-glue ( A | AAAA | NONE ); + edns-udp-size number; }; @@ -4014,6 +4015,16 @@ These options are valid for slave and stub zones, and clamp the SOA refresh and retry times to the specified values. + +edns-udp-size + +edns-udp-size sets the advertised EDNS UDP buffer +size. Valid values are 512 to 4096 (values outside this range will be +silently adjusted). The default value is 4096. The usual reason for +setting edns-udp-size to a non default value it to get UDP answers to +pass through broken firewalls that block fragmented packets and/or +block UDP packets that are greater than 512 bytes. + diff --git a/lib/dns/include/dns/resolver.h b/lib/dns/include/dns/resolver.h index 076aea9dc18..29589ec2546 100644 --- a/lib/dns/include/dns/resolver.h +++ b/lib/dns/include/dns/resolver.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.h,v 1.36 2003/01/16 03:59:25 marka Exp $ */ +/* $Id: resolver.h,v 1.37 2003/02/26 02:03:59 marka Exp $ */ #ifndef DNS_RESOLVER_H #define DNS_RESOLVER_H 1 @@ -371,6 +371,18 @@ dns_resolver_addalternate(dns_resolver_t *resolver, isc_sockaddr_t *alt, * only one of 'name' or 'alt' to be valid. */ +void +dns_resolver_setudpsize(dns_resolver_t *resolver, isc_uint16_t udpsize); +/* + * Set the EDNS UDP buffer size advertised by the server. + */ + +isc_uint16_t +dns_resolver_getudpsize(dns_resolver_t *resolver); +/* + * Get the current EDNS UDP buffer size. + */ + ISC_LANG_ENDDECLS #endif /* DNS_RESOLVER_H */ diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 981a21f8c3c..4f17c76fa77 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.260 2003/01/18 03:18:30 marka Exp $ */ +/* $Id: resolver.c,v 1.261 2003/02/26 02:03:59 marka Exp $ */ #include @@ -93,7 +93,7 @@ /* * Maximum EDNS0 input packet size. */ -#define SEND_BUFFER_SIZE 2048 /* XXXRTH Constant. */ +#define RECV_BUFFER_SIZE 4096 /* XXXRTH Constant. */ /* * This defines the maximum number of timeouts we will permit before we @@ -284,6 +284,7 @@ struct dns_resolver { fctxbucket_t * buckets; isc_uint32_t lame_ttl; ISC_LIST(alternate_t) alternates; + isc_uint16_t udpsize; /* Locked by lock. */ unsigned int references; isc_boolean_t exiting; @@ -706,7 +707,7 @@ resquery_senddone(isc_task_t *task, isc_event_t *event) { } static inline isc_result_t -fctx_addopt(dns_message_t *message) { +fctx_addopt(dns_message_t *message, dns_resolver_t *res) { dns_rdataset_t *rdataset; dns_rdatalist_t *rdatalist; dns_rdata_t *rdata; @@ -732,7 +733,7 @@ fctx_addopt(dns_message_t *message) { /* * Set Maximum UDP buffer size. */ - rdatalist->rdclass = SEND_BUFFER_SIZE; + rdatalist->rdclass = res->udpsize; /* * Set EXTENDED-RCODE, VERSION, and Z to 0, and the DO bit to 1. @@ -1078,7 +1079,7 @@ resquery_send(resquery_t *query) { if ((query->options & DNS_FETCHOPT_NOEDNS0) == 0) { if ((query->addrinfo->flags & DNS_FETCHOPT_NOEDNS0) == 0) { - result = fctx_addopt(fctx->qmessage); + result = fctx_addopt(fctx->qmessage, res); if (result != ISC_R_SUCCESS) { /* * We couldn't add the OPT, but we'll press on. @@ -5281,6 +5282,7 @@ dns_resolver_create(dns_view_t *view, res->options = options; res->lame_ttl = 0; ISC_LIST_INIT(res->alternates); + res->udpsize = RECV_BUFFER_SIZE; res->nbuckets = ntasks; res->activebuckets = ntasks; @@ -5925,3 +5927,15 @@ dns_resolver_addalternate(dns_resolver_t *resolver, isc_sockaddr_t *alt, return (ISC_R_SUCCESS); } + +void +dns_resolver_setudpsize(dns_resolver_t *resolver, isc_uint16_t udpsize) { + REQUIRE(VALID_RESOLVER(resolver)); + resolver->udpsize = udpsize; +} + +isc_uint16_t +dns_resolver_getudpsize(dns_resolver_t *resolver) { + REQUIRE(VALID_RESOLVER(resolver)); + return (resolver->udpsize); +} diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index c7fb83ee1a4..2e8b02a2d3b 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: namedconf.c,v 1.15 2003/02/04 06:10:09 marka Exp $ */ +/* $Id: namedconf.c,v 1.16 2003/02/26 02:04:00 marka Exp $ */ #include @@ -607,6 +607,7 @@ view_clauses[] = { { "suppress-initial-notify", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI }, { "preferred-glue", &cfg_type_astring, 0 }, { "dual-stack-servers", &cfg_type_nameportiplist, 0 }, + { "edns-udp-size", &cfg_type_uint32, 0 }, { NULL, NULL, 0 } };