<net-dev> Java_java_net_Inet6AddressImpl_isReachable0 is returning false for InetAdress 0.0.0.0

Deven You youdwei at linux.vnet.ibm.com
Mon Apr 9 00:57:04 PDT 2012


Hi net-devs,

There is a test case [1] can reproduce this problem. Please use root 
privilege to run this test case(create raw socket need root privilege).

Test results:

sudo ~/jdks/oracle/jdk1.7.0_03/bin/java Javanet
The target ip is 0.0.0.0
the target is reachable: false
Test failed
Exception in thread "main" java.lang.Exception: address 0.0.0.0 can not 
be reachable!
     at Javanet.main(Javanet.java:40)

The root cause is that ping4 method in Inet4AddressImpl.c does a check 
of sending and receiving address.
(him->sin_addr.s_addr == sa_recv.sin_addr.s_addr)

This is not true for InetAddress 0.0.0.0. We can using ping command on 
Linux to confirm it:

ping 0.0.0.0
ING 0.0.0.0 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_req=1 ttl=64 time=0.024 ms
64 bytes from 127.0.0.1: icmp_req=2 ttl=64 time=0.025 ms

So for 0.0.0.0, we can remove the (him->sin_addr.s_addr == 
sa_recv.sin_addr.s_addr).

I have made a patch[1] to solve this issue.

Thanks a lot!

[1] http://cr.openjdk.java.net/~youdwei/inet4adr/webrev.00/ 
<http://cr.openjdk.java.net/%7Eyoudwei/inet4adr/webrev.00/>

-- 
Best Regards,

Deven

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/net-dev/attachments/20120409/5e708d9c/attachment.html 


More information about the net-dev mailing list