Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4825092

InetAddress.getByName(ipv6 name) doesn't work on FreeBSD with Linuxulator

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.1
    • core-libs
    • x86
    • linux



      Name: nt126004 Date: 02/27/2003


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)


      FULL OPERATING SYSTEM VERSION : FreeBSD 5.0 with Linux
      emulation, Linux


      A DESCRIPTION OF THE PROBLEM :
      If I call InetAddress.getByName() with an IPv6 literal
      address as a quoted string, it works.

      If I call InetAddress.getByName() with a host name that has
      A and AAAA records in DNS, I never get the AAAA result, even
      when I use -Djava.net.preferIPv6Addresses=true on the
      command line.

      If I call InetAddress.getByName() with a host name that has
      only AAAA records in DNS, I get an UnknownHost exception.

      Calling Inet6Address.getByName() does not do any better.

      If I run tcpdump and watch the DNS queries, I only ever see
      queries for A records.

      If I create an Inet6Address either manually or with
      getByName() with an IPv6 literal, using it to make
      connections works just fine.

      I find it rather unlikely that this has anything to do with
      the fact that it's running under the FreeBSD linuxulator.

      The underlying implementation of getipnodebyname() works
      correctly.

      >my guess is that the issue is with the BSD (or Linux
      >emulation) implementation of getaddrinfo. If the tcpdump shows that a
      >AAAA record isn't returned that probably explains it.
      >

      No, no. it's not that an AAAA record isn't being returned, it's that
      AAAA records are never *asked for*. That is, the query always goes out
      looking for an A record.

      > It would be
      >interesting to see his results if he runs with
      >-Dsun.net.spi.nameservice.provider.1=dns,sun as this will use our
      >JNDI-DNS provider and avoid using the getaddrinfo routines."
      >
      Trying that, I get correct results for the first and third test, but I
      still get an IPv4 connection for the 2nd test, which I believe is incorrect.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. InetAddress foo =
      InetAddress.getByName("3ffe:1200:301b:0:2d0:b7ff:febe:e2a8");

      2. InetAddress foo = InetAddress.getByName("quack.kfu.com");
      with -Djava.net.preferIPv6Addresses=true

      3. InetAddress foo = InetAddress.getByName("morpheus.kfu.com");



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      In all cases, I expect an Inet6Address object properly
      filled in.

      Observed:

      1. Correct
      2. Inet4Address
      3. UnknownHostException


      REPRODUCIBILITY :
      This bug can be reproduced always.

      -------------- BEGIN SOURCE -------------------
      /*
      The expectation is that all 3 of the runs of DoATest() print out IPv6
      addresses and report successful connections.

      The observed behavior is that the first test works as described, the
      second makes an IPv4 connection, and the third reports 'unknown host'.
      */

      import java.lang.*;
      import java.io.*;
      import java.net.*;

      public class foo {
              public static void main(String[] args) {
      System.setProperty("java.net.preferIPv6Addresses", "true");
      DoATest("literal", "3ffe:1200:301b:0:2d0:b7ff:febe:e2a8");
      DoATest("A and AAAA host", "quack.kfu.com");
      DoATest("AAAA only host", "morpheus.kfu.com");
              }

              private static void DoATest(String testname, String host) {
                      System.out.println("Starting test " + testname);
                      try {
                              InetAddress ad = InetAddress.getByName(host);
                              System.out.println("Success: " + ad);
                              Socket s = new Socket(ad, 22);
                              System.out.println("Got connected.");
                              s.close();
                      }
                      catch(UnknownHostException e) {
                              System.out.println("Unknown host!");
                              return;
                      }
                      catch(IOException e) {
                              System.out.println("I/O Error!");
                              return;
                      }

              }
      }
      --------------- END SOURCE --------------------
      (Review ID: 181254)
      ======================================================================

            michaelm Michael McMahon
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: