]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2519. [bug] dig/host with -4 or -6 didn't work if more than two
authorTatuya JINMEI 神明達哉 <jinmei@isc.org>
Wed, 17 Dec 2008 19:23:27 +0000 (19:23 +0000)
committerTatuya JINMEI 神明達哉 <jinmei@isc.org>
Wed, 17 Dec 2008 19:23:27 +0000 (19:23 +0000)
nameserver addresses of the excluded address family
preceded in resolv.conf. [RT #19081]

CHANGES
bin/dig/dighost.c
lib/lwres/context.c
lib/lwres/context_p.h
lib/lwres/include/lwres/context.h
lib/lwres/lwconfig.c

diff --git a/CHANGES b/CHANGES
index 6c56dc8fca8cfe2b652246ee3a7e3450855933c3..2474acc7a1c78aa8373a5a2a20d599c4b01228d7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,12 +1,16 @@
+2519.  [bug]           dig/host with -4 or -6 didn't work if more than two
+                       nameserver addresses of the excluded address family
+                       preceded in resolv.conf. [RT #19081]
+
 2517.  [bug]           dig +trace with -4 or -6 failed when it chose a
-                       nameserver address of the unsupported address.
+                       nameserver address of the excluded address.
                        [RT #18843]
 
 2516.  [bug]           glue sort for responses was performed even when not
                        needed. [RT #19039]
 
 2514.  [bug]           dig/host failed with -4 or -6 when resolv.conf contains
-                       a nameserver of the unsupported address family.
+                       a nameserver of the excluded address family.
                        [RT #18848]
 
 2511.  [cleanup]       dns_rdata_tofmttext() add const to linebreak.
index cd5cd70ed5bbb56e8b4a3bb52365a0b51191ce67..c62d120cc4003f627b7f5c39851330c99fc40471 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dighost.c,v 1.259.18.52 2008/12/16 03:00:06 jinmei Exp $ */
+/* $Id: dighost.c,v 1.259.18.53 2008/12/17 19:23:27 jinmei Exp $ */
 
 /*! \file
  *  \note
@@ -1009,10 +1009,18 @@ void
 setup_system(void) {
        dig_searchlist_t *domain = NULL;
        lwres_result_t lwresult;
+       unsigned int lwresflags;
 
        debug("setup_system()");
 
-       lwresult = lwres_context_create(&lwctx, mctx, mem_alloc, mem_free, 1);
+       lwresflags = LWRES_CONTEXT_SERVERMODE;
+       if (have_ipv4)
+               lwresflags |= LWRES_CONTEXT_USEIPV4;
+       if (have_ipv6)
+               lwresflags |= LWRES_CONTEXT_USEIPV6;
+
+       lwresult = lwres_context_create(&lwctx, mctx, mem_alloc, mem_free,
+                                       lwresflags);
        if (lwresult != LWRES_R_SUCCESS)
                fatal("lwres_context_create failed");
 
index c731bb746e4652bbd95f21967a3778d3105b21b8..eca52fdebe1c479fa8f40c079b61f6d7f68c27cc 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: context.c,v 1.45.18.7 2007/08/28 07:20:06 tbox Exp $ */
+/* $Id: context.c,v 1.45.18.8 2008/12/17 19:23:27 jinmei Exp $ */
 
 /*! \file context.c 
    lwres_context_create() creates a #lwres_context_t structure for use in
@@ -156,7 +156,6 @@ lwres_context_create(lwres_context_t **contextp, void *arg,
        lwres_context_t *ctx;
 
        REQUIRE(contextp != NULL && *contextp == NULL);
-       UNUSED(flags);
 
        /*
         * If we were not given anything special to use, use our own
@@ -184,6 +183,17 @@ lwres_context_create(lwres_context_t **contextp, void *arg,
        ctx->timeout = LWRES_DEFAULT_TIMEOUT;
        ctx->serial = time(NULL); /* XXXMLG or BEW */
 
+       ctx->use_ipv4 = 1;
+       ctx->use_ipv6 = 1;
+       if ((flags & (LWRES_CONTEXT_USEIPV4 | LWRES_CONTEXT_USEIPV6)) ==
+           LWRES_CONTEXT_USEIPV6) {
+               ctx->use_ipv4 = 0;
+       }
+       if ((flags & (LWRES_CONTEXT_USEIPV4 | LWRES_CONTEXT_USEIPV6)) ==
+           LWRES_CONTEXT_USEIPV4) {
+               ctx->use_ipv6 = 0;
+       }
+
        /*
         * Init resolv.conf bits.
         */
index d255ef6d72be61b85929663243f44c2f7e022814..fa351d3829c7e10e0da512dbc114ad89d9de20df 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: context_p.h,v 1.13.18.2 2005/04/29 00:17:17 marka Exp $ */
+/* $Id: context_p.h,v 1.13.18.3 2008/12/17 19:23:27 jinmei Exp $ */
 
 #ifndef LWRES_CONTEXT_P_H
 #define LWRES_CONTEXT_P_H 1
@@ -46,6 +46,8 @@ struct lwres_context {
         */
        int                     sock;           /*%< socket to send on */
        lwres_addr_t            address;        /*%< address to send to */
+       int                     use_ipv4;       /*%< use IPv4 transaction */
+       int                     use_ipv6;       /*%< use IPv6 transaction */
 
        /*@{*/
        /*
index bd2444638b9cdf0506154541ce666bfc244735c7..41d143819b74f39e3bdff01e0010734c4e4ddd48 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: context.h,v 1.15.18.2 2005/04/29 00:17:21 marka Exp $ */
+/* $Id: context.h,v 1.15.18.3 2008/12/17 19:23:27 jinmei Exp $ */
 
 #ifndef LWRES_CONTEXT_H
 #define LWRES_CONTEXT_H 1
@@ -57,8 +57,15 @@ typedef void (*lwres_free_t)(void *arg, void *mem, size_t length);
  * _SERVERMODE
  *     Don't allocate and connect a socket to the server, since the
  *     caller _is_ a server.
+ *
+ * _USEIPV4, _USEIPV6
+ *     Use IPv4 and IPv6 transactions with remote servers, respectively.
+ *     For backward compatibility, regard both flags as being set when both
+ *     are cleared.
  */
 #define LWRES_CONTEXT_SERVERMODE       0x00000001U
+#define LWRES_CONTEXT_USEIPV4          0x00000002U
+#define LWRES_CONTEXT_USEIPV6          0x00000004U
 
 lwres_result_t
 lwres_context_create(lwres_context_t **contextp, void *arg,
index cf4f6a7f054994aca8e103c622a28ab3dcd1fce1..d8966750e181d5a398475b0d0be93ced3aa73877 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: lwconfig.c,v 1.38.18.5 2006/10/03 23:50:51 marka Exp $ */
+/* $Id: lwconfig.c,v 1.38.18.6 2008/12/17 19:23:27 jinmei Exp $ */
 
 /*! \file */
 
@@ -313,8 +313,11 @@ lwres_conf_parsenameserver(lwres_context_t *ctx,  FILE *fp) {
                return (LWRES_R_FAILURE); /* Extra junk on line. */
 
        res = lwres_create_addr(word, &address, 1);
-       if (res == LWRES_R_SUCCESS)
+       if (res == LWRES_R_SUCCESS &&
+           ((address.family == LWRES_ADDRTYPE_V4 && ctx->use_ipv4 == 1) ||
+            (address.family == LWRES_ADDRTYPE_V6 && ctx->use_ipv6 == 1))) {
                confdata->nameservers[confdata->nsnext++] = address;
+       }
 
        return (LWRES_R_SUCCESS);
 }