[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#505020: apt: always does AAAA queries first



package: apt
version: 0.7.16
tags: patch
severity: important

When using a nameserver from some standard German t-online DSL-router
(so I guess it might effect a larger number of people) the missing
capabilities of that thing (it does not answer to AAAA queries at all),
unveil a bug in apt's methods:

Name resolving always sends out AAAA queries first and only after
timeout sends A queries, even if no ipv6 is available at all.

The attached patch makes it use the default flags as described in
RFC 2553.

Hochachtungsvoll,
	Bernhard R. Link

I'm setting to important because in that setting above, which I guess
might be quite common, it simply looks like the network would fail and
the timeout is so long that most people will have aborted by the time,
and having that timeout for every single apt-get install makes apt
practically unuseable. Feel encouraged to change it if you disagree...
=== modified file 'methods/connect.cc'
--- methods/connect.cc	2008-02-08 10:31:11 +0000
+++ methods/connect.cc	2008-11-08 15:09:14 +0000
@@ -158,6 +158,7 @@
       struct addrinfo Hints;
       memset(&Hints,0,sizeof(Hints));
       Hints.ai_socktype = SOCK_STREAM;
+      Hints.ai_flags = AI_DEFAULT;
       Hints.ai_protocol = 0;
       
       // if we couldn't resolve the host before, we don't try now

=== modified file 'methods/ftp.cc'
--- methods/ftp.cc	2007-10-02 12:36:42 +0000
+++ methods/ftp.cc	2008-11-08 15:00:55 +0000
@@ -503,7 +503,7 @@
       memset(&Hints,0,sizeof(Hints));
       Hints.ai_socktype = SOCK_STREAM;
       Hints.ai_family = ((struct sockaddr *)&PeerAddr)->sa_family;
-      Hints.ai_flags |= AI_NUMERICHOST;
+      Hints.ai_flags = AI_DEFAULT|AI_NUMERICHOST;
       
       // Get a new passive address.
       char Port[100];
@@ -517,7 +517,7 @@
    memset(&Hints,0,sizeof(Hints));
    Hints.ai_socktype = SOCK_STREAM;
    Hints.ai_family = AF_INET;
-   Hints.ai_flags |= AI_NUMERICHOST;
+   Hints.ai_flags = AI_DEFAULT|AI_NUMERICHOST;
    
    // Get a new passive address.
    char Port[100];
@@ -584,7 +584,7 @@
    struct addrinfo Hints;
    memset(&Hints,0,sizeof(Hints));
    Hints.ai_socktype = SOCK_STREAM;
-   Hints.ai_flags |= AI_NUMERICHOST;
+   Hints.ai_flags = AI_DEFAULT|AI_NUMERICHOST;
    
    /* The RFC defined case, connect to the old IP/protocol using the
       new port. */
@@ -715,7 +715,7 @@
    struct addrinfo Hints;
    memset(&Hints,0,sizeof(Hints));
    Hints.ai_socktype = SOCK_STREAM;
-   Hints.ai_flags |= AI_PASSIVE;
+   Hints.ai_flags = AI_DEFAULT|AI_PASSIVE;
    Hints.ai_family = ((struct sockaddr *)&ServerAddr)->sa_family;
    int Res;
    if ((Res = getaddrinfo(0,"0",&Hints,&BindAddr)) != 0)

=== modified file 'methods/rfc2553emu.h'
--- methods/rfc2553emu.h	2004-09-20 16:56:08 +0000
+++ methods/rfc2553emu.h	2008-11-08 14:58:34 +0000
@@ -110,4 +110,8 @@
 #define AI_NUMERICHOST 0
 #endif
 
+#ifndef AI_DEFAULT
+#define  AI_DEFAULT  (AI_V4MAPPED | AI_ADDRCONFIG)
+#endif
+
 #endif


Reply to: