Code Review 6947677: InetAddress.isReachable() throws "java.net.SocketException:Invalid argument" on Linux if run as root
Chris Hegarty
chris.hegarty at oracle.com
Thu Oct 21 06:50:31 PDT 2010
On 21/10/2010 14:05, Alan Bateman wrote:
> Chris Hegarty wrote:
>> Hi Michael,
>>
>> On some Linuxes, when bound to the loopback interface, sendto will
>> fail and errno will be set to EINVAL. When that happens, don't throw
>> an exception, just return false. We already do this in the case where
>> we cannot create raw sockets, i.e. when not running as root.
>>
>> http://cr.openjdk.java.net/~chegar/6947677/webrev.00/webrev/
>>
>> Thanks,
>> -Chris.
> Chris - is this a kernel bug where it should be returning EHOSTUNREACH
> or some other error instead? It is specific to the loopback interface so
> do you have the same issue when bound to a real interface?
It appears to be specific to the loopback interface. You can reproduce
the very same behavior using DatagramSocket and DatagramChannel; bind to
the loopback address and send a packet to a remote address.
I was not too happy about doing this until I found that we do the very
same thing in non raw sockets case.
-Chris.
>
> -Alan
More information about the net-dev
mailing list