<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Erm, this is really strange.  I mean just using the c-ares ahost()
    which calls ares_gethostbyname(), I get reasonable results:<br>
    <br>
    $ ./ahost -t u production-all-ipv6.easypost.com<br>
    production-all-ipv6.easypost.com    2607:f0d0:2901:7e::2<br>
    production-all-ipv6.easypost.com    2607:f0d0:3803:ca::2<br>
    production-all-ipv6.easypost.com    2607:f0d0:2901:7e::3<br>
    production-all-ipv6.easypost.com    2607:f0d0:3803:ca::3<br>
    <br>
    Using ahost instead of adig is more representative of how consumers
    of c-ares use it as adig uses low level apis whereas ahost uses the
    higher level apis.<br>
    <br>
    The socket(), connect(), getsockname() pattern you see for each IP
    address is actually a weird thing about getaddrinfo() where you have
    to determine reach-ability by the routes to the destination as per
    rfc6724 section 6.  If you notice, the socket() is SOCK_DGRAM,
    IPPROTO_UDP and UDP is stateless, so connect() doesn't actually
    connect, but it *does* resolve if the system thinks the endpoint is
    reachable.<br>
    <br>
    I guess maybe I need to look at the curl code to see how its calling
    into c-ares to see if the change has some weird sanity check that
    isn't covered by our test cases.<br>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 10/26/21 5:16 PM, James Brown via
      c-ares wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CALgeuKz=jqop9c+CK90sSZZLx2ppaSEMAQQNnPVYv6y+33NT1w@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div class="gmail_default" style="font-family:times new
          roman,serif">Testing an upgrade from 1.17.2 to 1.18.0 and all
          curl requests to internal names started failing with "Could
          not resolve host". adig and ahost are both able to resolve the
          names just fine. It appears that this affects any lookup that
          only returns IPv6 addresses, and possibly also any lookup that
          is behind a DNAME. The IPv6 case is easier to reproduce so
          that's what I've put below:</div>
        <div class="gmail_default" style="font-family:times new
          roman,serif"><br>
        </div>
        <div class="gmail_default" style=""><span
            style="font-family:"times new roman",serif">This
            can be easily reproduced from `</span><font face="monospace">curl
            -vs <a
              href="https://production-all-ipv6.easypost.com/health/ok"
              moz-do-not-send="true" class="moz-txt-link-freetext">https://production-all-ipv6.easypost.com/health/ok</a></font><font
            face="times new roman, serif">` on any host with c-ares
            1.18.0 installed and curl linked against c-ares.</font></div>
        <div class="gmail_default" style="font-family:times new
          roman,serif"><br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif">Bizarrely enough, if I strace curl, I see it
          actually connecting to the correct remote IP before returning
          the "Could not resolve host" error. ???</div>
        <div class="gmail_default" style="font-family:times new
          roman,serif"><br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif">I did a git-bisect run and it points at <a
href="https://github.com/c-ares/c-ares/commit/778d7cd9e7bf6b31ce697f47cbe935e33a63a5b4"
            moz-do-not-send="true">778d7cd9e7bf6b31ce697f47cbe935e33a63a5b4</a> as
          the offending commit.</div>
        <div class="gmail_default" style="font-family:times new
          roman,serif"><br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif">I'm running dnsmasq on localhost and nothing
          about it has changed. Below is some probably-relevant output
          from a system with c-ares 1.17.2 installed system wide and
          c-ares 1.18.0 installed in the "./prefix" directory.</div>
        <div class="gmail_default" style="font-family:times new
          roman,serif"><br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif">$ curl --version<br>
          curl 7.79.1 (x86_64-redhat-linux-gnu) libcurl/7.79.1
          OpenSSL/1.0.2u zlib/1.2.3 zstd/1.4.9 c-ares/1.17.2
          libidn2/2.3.0 libssh2/1.10.0 nghttp2/1.45.1 OpenLDAP/2.4.40<br>
          Release-Date: 2021-09-22<br>
          Protocols: dict file ftp ftps gopher gophers http https imap
          imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp
          smtps telnet tftp<br>
          Features: alt-svc AsynchDNS HSTS HTTP2 HTTPS-proxy IDN IPv6
          Largefile libz NTLM NTLM_WB SSL UnixSockets zstd<br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif"><br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif">$ env LD_LIBRARY_PATH=./prefix/lib/ curl
          --version<br>
          curl 7.79.1 (x86_64-redhat-linux-gnu) libcurl/7.79.1
          OpenSSL/1.0.2u zlib/1.2.3 zstd/1.4.9 c-ares/1.18.0
          libidn2/2.3.0 libssh2/1.10.0 nghttp2/1.45.1 OpenLDAP/2.4.40<br>
          Release-Date: 2021-09-22<br>
          Protocols: dict file ftp ftps gopher gophers http https imap
          imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp
          smtps telnet tftp<br>
          Features: alt-svc AsynchDNS HSTS HTTP2 HTTPS-proxy IDN IPv6
          Largefile libz NTLM NTLM_WB SSL UnixSockets zstd</div>
        <div class="gmail_default" style="font-family:times new
          roman,serif"><br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif">$ curl <a
            href="https://production-all-ipv6.easypost.com/health/ok"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://production-all-ipv6.easypost.com/health/ok</a><br>
          UP<br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif"><br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif">$ env LD_LIBRARY_PATH=./prefix/lib/  curl <a
            href="https://production-all-ipv6.easypost.com/health/ok"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://production-all-ipv6.easypost.com/health/ok</a><br>
          curl: (6) Could not resolve host: <a
            href="http://production-all-ipv6.easypost.com"
            moz-do-not-send="true">production-all-ipv6.easypost.com</a><br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif"><br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif">$ env LD_LIBRARY_PATH=./prefix/lib/ strace curl <a
            href="https://production-all-ipv6.easypost.com/health/ok"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://production-all-ipv6.easypost.com/health/ok</a><br>
        </div>
        <div class="gmail_default" style="font-family:times new
          roman,serif">[snip]</div>
        <div class="gmail_default" style="font-family:times new
          roman,serif">connect(5, {sa_family=AF_INET6,
          sin6_port=htons(53), inet_pton(AF_INET6, "::1",
          &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0<br>
          sendto(5,
          "Q\337\1\0\0\1\0\0\0\0\0\0\23production-all-ipv6"..., 50,
          MSG_NOSIGNAL, NULL, 0) = 50<br>
          sendto(5,
          "~\311\1\0\0\1\0\0\0\0\0\0\23production-all-ipv6"..., 50,
          MSG_NOSIGNAL, NULL, 0) = 50<br>
          poll([{fd=5, events=POLLIN|POLLRDNORM}], 1, 0) = 1 ([{fd=5,
          revents=POLLIN|POLLRDNORM}])<br>
          recvfrom(5,
          "Q\337\201\200\0\1\0\0\0\0\0\0\23production-all-ipv6"...,
          4097, 0, {sa_family=AF_INET6, sin6_port=htons(53),
          inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=0,
          sin6_scope_id=0}, [28]) = 50<br>
          recvfrom(5,
          "~\311\201\200\0\1\0\4\0\0\0\0\23production-all-ipv6"...,
          4097, 0, {sa_family=AF_INET6, sin6_port=htons(53),
          inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=0,
          sin6_scope_id=0}, [28]) = 162<br>
          socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP) = 6<br>
          connect(6, {sa_family=AF_INET6, sin6_port=htons(443),
          inet_pton(AF_INET6, "2607:f0d0:2901:7e::3", &sin6_addr),
          sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0<br>
          getsockname(6, {sa_family=AF_INET6, sin6_port=htons(43428),
          inet_pton(AF_INET6, "2607:f0d0:2901:4b::66", &sin6_addr),
          sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 0<br>
          close(6)                                = 0<br>
          socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP) = 6<br>
          connect(6, {sa_family=AF_INET6, sin6_port=htons(443),
          inet_pton(AF_INET6, "2607:f0d0:3803:ca::3", &sin6_addr),
          sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0<br>
          getsockname(6, {sa_family=AF_INET6, sin6_port=htons(44405),
          inet_pton(AF_INET6, "2607:f0d0:2901:4b::66", &sin6_addr),
          sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 0<br>
          close(6)                                = 0<br>
          socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP) = 6<br>
          connect(6, {sa_family=AF_INET6, sin6_port=htons(443),
          inet_pton(AF_INET6, "2607:f0d0:3803:ca::2", &sin6_addr),
          sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0<br>
          getsockname(6, {sa_family=AF_INET6, sin6_port=htons(33765),
          inet_pton(AF_INET6, "2607:f0d0:2901:4b::66", &sin6_addr),
          sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 0<br>
          close(6)                                = 0<br>
          socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP) = 6<br>
          connect(6, {sa_family=AF_INET6, sin6_port=htons(443),
          inet_pton(AF_INET6, "2607:f0d0:2901:7e::2", &sin6_addr),
          sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0<br>
          getsockname(6, {sa_family=AF_INET6, sin6_port=htons(59083),
          inet_pton(AF_INET6, "2607:f0d0:2901:4b::66", &sin6_addr),
          sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 0<br>
          close(6)                                = 0<br>
          close(5)                                = 0<br>
          rt_sigaction(SIGPIPE, {SIG_IGN, [PIPE],
          SA_RESTORER|SA_RESTART, 0x7ff5cb5f4570}, NULL, 8) = 0<br>
          rt_sigaction(SIGPIPE, {SIG_IGN, [PIPE],
          SA_RESTORER|SA_RESTART, 0x7ff5cb5f4570}, NULL, 8) = 0<br>
          write(2, "c", 1c)                        = 1<br>
          write(2, "u", 1u)                        = 1<br>
          write(2, "r", 1r)                        = 1<br>
          write(2, "l", 1l)                        = 1<br>
          write(2, ":", 1:)                        = 1<br>
          write(2, " ", 1 )                        = 1<br>
          write(2, "(", 1()                        = 1<br>
          write(2, "6", 16)                        = 1<br>
          write(2, ")", 1))                        = 1<br>
          write(2, " ", 1 )                        = 1<br>
          write(2, "C", 1C)                        = 1<br>
          write(2, "o", 1o)                        = 1<br>
          write(2, "u", 1u)                        = 1<br>
          write(2, "l", 1l)                        = 1<br>
          write(2, "d", 1d)                        = 1<br>
          write(2, " ", 1 )                        = 1<br>
          write(2, "n", 1n)                        = 1<br>
          write(2, "o", 1o)                        = 1<br>
          write(2, "t", 1t)                        = 1<br>
          write(2, " ", 1 )                        = 1<br>
          write(2, "r", 1r)                        = 1<br>
          write(2, "e", 1e)                        = 1<br>
          write(2, "s", 1s)                        = 1<br>
          write(2, "o", 1o)                        = 1<br>
          write(2, "l", 1l)                        = 1<br>
          write(2, "v", 1v)                        = 1<br>
          write(2, "e", 1e)                        = 1<br>
          write(2, " ", 1 )                        = 1<br>
          write(2, "h", 1h)                        = 1<br>
          write(2, "o", 1o)                        = 1<br>
          write(2, "s", 1s)                        = 1<br>
          write(2, "t", 1t)                        = 1<br>
          write(2, ":", 1:)                        = 1<br>
        </div>
        -- <br>
        <div dir="ltr" class="gmail_signature"
          data-smartmail="gmail_signature">
          <div dir="ltr">
            <div>
              <div dir="ltr"><span style="font-family:times new
                  roman,serif">James Brown</span>
                <div><span style="font-family:times new roman,serif">Engineer</span></div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
    </blockquote>
    <br>
  </body>
</html>