On 04/09/2012 03:57 PM, Deven You wrote:
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
Hi All,

Is there anyone could review this patch, thanks a lot!

--
Best Regards,

Deven

Reply via email to