]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1432. [func] The advertised EDNS UDP buffer size can now be set
authorMark Andrews <marka@isc.org>
Wed, 26 Feb 2003 02:04:00 +0000 (02:04 +0000)
committerMark Andrews <marka@isc.org>
Wed, 26 Feb 2003 02:04:00 +0000 (02:04 +0000)
                        via named.conf (edns-udp-size).
developer: marka
reviewer: explorer

CHANGES
bin/named/client.c
bin/named/config.c
bin/named/include/named/globals.h
bin/named/server.c
doc/arm/Bv9ARM-book.xml
lib/dns/include/dns/resolver.h
lib/dns/resolver.c
lib/isccfg/namedconf.c

diff --git a/CHANGES b/CHANGES
index be896830e0b2b34b9bce20d2c202795da91a9e05..f8a0d763f634cb7d1740933a6f6163bf428022fc 100644 (file)
--- 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]
 
index 5b24c684a2fc67fd4df1c3291cf47999cf6f4708..df14047736f9af78884c53044258956aa8d328d8 100644 (file)
@@ -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.
index 597e8e96af02c9b81acd8a6b267328e0b2208634..02610d403fa3a5fa6b1be1fd7a1632df4f2be11b 100644 (file)
@@ -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\
index 87f9521d178471f48a89bf62f2e6ca06dd17f62d..0c07831d6a652742ee1697e78ba42f184a542f2a 100644 (file)
@@ -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.
index 5ef855ee41e47b664986dcae6ece95dda6b60ddf..6aa3e466170bcc8752fec63ab39288f3fdd8bff1 100644 (file)
@@ -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.
         */
index a9093fb8759c1a7415899c71ed349cb451fcceb3..ca396c8165a6da98b3f95f921334d3d9dbc5320d 100644 (file)
@@ -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>
index 076aea9dc18945426d87a6118fe285f9ce93c60d..29589ec2546bea640ad7539ecd8634a3f7e50290 100644 (file)
@@ -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 */
index 981a21f8c3c2637ae1fecaa0674491551f7698c3..4f17c76fa778b56d80e8e8ff9733334b61637915 100644 (file)
@@ -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);
+}
index c7fb83ee1a44c26aced029f6a93655d2ca1cba1f..2e8b02a2d3b79a28fdfc0dd5c4eaa3aa7eaf24fa 100644 (file)
@@ -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 }
 };