JDK-4922568 : IsReachable returns true for IPv6
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_7
  • CPU: sparc
  • Submitted: 2003-09-15
  • Updated: 2003-10-14
  • Resolved: 2003-09-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Relates :  
Description
The IsReachable API returns true for IPv6 addresses from an IPv4 solaris host.

Steps to reproduce the bug :
1. Copy the code below to a file.
2. Compile the code.
3. Execute the code by giving an IPv6 address on the command line.
4. An Exception should be thrown or a false value should be returned.

-----------------BEGIN CODE-----------------------------
import java.net.*;
import java.io.*;

public class IsHostReachableBug {
    public static void main(String[] args) throws Exception{
                String hostName = "yamlok.india";
                BufferedReader in = null;
                FileWriter fw = null;
                String inString = " ";
                if (args.length > 0)
                        hostName = args[0];

                InetAddress addr = InetAddress.getByName(hostName);
                System.out.println("InetAddress is : " + addr);
                System.out.println("Is InetAddress instance of Inet6Address ? " + (addr instanceof Inet6Address));
                if (!addr.isReachable(10000)){
                        System.out.println(hostName + " is not reachable");
                }else {
                        System.out.println(hostName + " is reachable");
                }


    }
}
----------------END CODE----------------------------

---------------BEGIN OUTPUT-------------------------
sqindia: <150> $$JHOME/bin/java IsHostReachableBug fe80::a00:20ff:fefe:3440
InetAddress is : /fe80:0:0:0:a00:20ff:fefe:3440
Is InetAddress instance of Inet6Address ? true
fe80::a00:20ff:fefe:3440 is reachable
sqindia: <151> $                                                           
sqindia: <151> $
sqindia: <151> $ping fe80::a00:20ff:fefe:3440
ping: unknown host fe80::a00:20ff:fefe:3440
sqindia: <152> $                             
sqindia: <152> $
sqindia: <152> $ifconfig -a
lo0: flags=849<UP,LOOPBACK,RUNNING,MULTICAST> mtu 8232
        inet 127.0.0.1 netmask ff000000 
hme0: flags=863<UP,BROADCAST,NOTRAILERS,RUNNING,MULTICAST> mtu 1500
        inet 10.12.151.12 netmask ffffff00 broadcast 10.12.151.255
sqindia: <153> $
--------------------------END OUTPUT---------------

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b22 VERIFIED IN: tiger-beta
03-09-2004

EVALUATION Indeed. Strange thing is happening here. It seems that when an Inet6Address is created on an IPv4 only machine, it is created with an Inet4AddressImpl. That's why the code in isReachable is failing. It is treated as an IPv4 address. Need to fix this for Tiger. ###@###.### 2003-09-15
15-09-2003