Commit e2fb08b8 authored by Mark Andrews's avatar Mark Andrews

1432. [func] The advertised EDNS UDP buffer size can now be set

                        via named.conf (edns-udp-size).
developer: marka
reviewer: explorer
parent 28dd899f
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]
......
......@@ -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 <config.h>
......@@ -34,6 +34,7 @@
#include <dns/events.h>
#include <dns/message.h>
#include <dns/rcode.h>
#include <dns/resolver.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
......@@ -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.
......
......@@ -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 <config.h>
......@@ -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\
......
......@@ -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.
......
......@@ -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 <config.h>
......@@ -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.
*/
......
......@@ -2,7 +2,7 @@
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
<!-- File: $Id: Bv9ARM-book.xml,v 1.214 2003/02/07 01:13:11 marka Exp $ -->
<!-- File: $Id: Bv9ARM-book.xml,v 1.215 2003/02/26 02:03:58 marka Exp $ -->
<book>
<title>BIND 9 Administrator Reference Manual</title>
......@@ -2782,6 +2782,7 @@ statement in the <filename>named.conf</filename> file:</para>
<optional> max-cache-size <replaceable>size_spec</replaceable> ; </optional>
<optional> match-mapped-addresses <replaceable>yes_or_no</replaceable>; </optional>
<optional> preferred-glue ( <replaceable>A</replaceable> | <replaceable>AAAA</replaceable> | <replaceable>NONE</replaceable> ); </optional>
<optional> edns-udp-size <replaceable>number</replaceable>; </optional>
};
</programlisting>
</sect2>
......@@ -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.
</para></listitem></varlistentry>
<varlistentry>
<term><command>edns-udp-size</command></term>
<listitem><para>
<command>edns-udp-size</command> 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.
</para></listitem></varlistentry>
</variablelist>
</sect3>
......
......@@ -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 */
......@@ -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 <config.h>
......@@ -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);
}
......@@ -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 <config.h>
......@@ -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 }
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment