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

InetAddress.getAllByName(hostname) is giving only v4 address on dual stack machi

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.4.0
    • Fix Version/s: 1.4.0
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      beta2
    • CPU:
      x86
    • OS:
      solaris_8
    • Verification:
      Verified

      Description

      InetAddress.getAllByName(hostname) is giving only IPv4 address on a dual stack machine with build 66. With build 65 its giving both v4 and v6 addresses on a dual stack machine. With build 66 I have checked this on Linux RH 6.2 dual stack machine, Solaris sparc8 dualstack and Solaris 8 x86 dual stack machine.

      On Solaris sparc 8 V6 only machine InetAddress.getAllByName(hostname) gives
      the following exception. same works find with build 65.

      java.net.UnknownHostException: marsbase
              at java.net.InetAddress.getAllByName0(InetAddress.java:785)
              at java.net.InetAddress.getAllByName0(InetAddress.java:755)
              at java.net.InetAddress.getAllByName(InetAddress.java:749)
              at GetIP.main(GetIP.java:11)



      How to reproduce it:
      -------------------

      1. Take the below pasted code and execute ..

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

      public class GetIP {


         public static void main(String[] arg)
         {
             try {

               InetAddress[] iadr = InetAddress.getAllByName(arg[0]);
              System.out.println("iadr length " + iadr.length);

              System.out.println("host name " + arg[0]);
              InetAddress iadrnic = InetAddress.getByName(arg[0]);
              System.out.println("AFter getting iadr ");

              NetworkInterface niface = NetworkInterface.getByAddr(iadrnic);

              System.out.println("AFter getting niface");

              System.out.println("network interface " + niface);

               for(int i=0; i< iadr.length; i++)
               {
                System.out.println("ip address : " + iadr[i].getHostAddress());
                System.out.println(" Host Name :" + iadr[i].getHostName());
                //System.out.println("family " + iadr[i].getFamily());
                System.out.println("Host aadd byte arr " + iadr[i].getAddress());
                if(iadr[i] instanceof Inet4Address)
                      System.out.println("v4 address");
                if(iadr[i] instanceof Inet6Address)
                      System.out.println("v6 address ");

                if(!iadr[i].isMCOrgLocal()) {
                    System.out.println("NOt org local scope");
                 }
               // InetAddress[] iadrtest = InetAddress.getAllByName(iadr[i].getHostName());
                InetAddress iadrtest = InetAddress.getByName(iadr[i].getHostName());
                System.out.println("working....");
               }

            } catch(Exception exp) {
               System.out.println("exp mesg " + exp.getMessage());
               exp.printStackTrace();
            }
         } // End of main

      }


      Execution output:
      -----------------

      on Solaris 8 x86 machine ifconfig -a

      ifconfig -a
      lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
              inet 127.0.0.1 netmask ff000000
      iprb0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
              inet 10.7.130.11 netmask ffffff00 broadcast 10.7.130.255
      lo0: flags=2000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6> mtu 8252 index 1
              inet6 ::1/128
      iprb0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2
              inet6 fe80::2d0:b7ff:fe9e:e0c8/10


      With build 65:
      --------------
      java GetIP hyperdrive
      iadr length 2
      host name hyperdrive
      AFter getting iadr
      AFter getting niface
      network interface name:iprb0 (iprb0) index: 2 addresses:
      /10.7.130.11;
      /[fe80::2d0:b7ff:fe9e:e0c8];

      ip address : 10.7.130.11
       Host Name :hyperdrive
      Host aadd byte arr [B@76a746
      v4 address
      NOt org local scope
      working....
      ip address : [fe80::2d0:b7ff:fe9e:e0c8]
       Host Name :hyperdrive
      Host aadd byte arr [B@5ff48b
      v6 address
      NOt org local scope
      working....


      With build 66:
      ----------------

      java GetIP hyperdrive
      iadr length 1
      host name hyperdrive
      AFter getting iadr
      AFter getting niface
      network interface name:iprb0 (iprb0) index: 2 addresses:
      /fe80::2d0:b7ff:fe9e:e0c8;
      /10.7.130.11;

      ip address : 10.7.130.11
       Host Name :hyperdrive
      Host aadd byte arr [B@4ac268
      v4 address
      NOt org local scope
      working....


      With build 66 on V6only machine:
      -------------------------------
      java GetIP marsbase
      java.net.UnknownHostException: marsbase
              at java.net.InetAddress.getAllByName0(InetAddress.java:785)
              at java.net.InetAddress.getAllByName0(InetAddress.java:755)
              at java.net.InetAddress.getAllByName(InetAddress.java:749)
              at GetIP.main(GetIP.java:11)
      exp mesg marsbase

      Other Information:
      -----------------

      Same thing is showing up on linux red hat 6.2 dual stack machine.



        Attachments

          Activity

            People

            Assignee:
            alanb Alan Bateman
            Reporter:
            vakellasunw Venkata Akella (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: