Code Review 6947677: InetAddress.isReachable() throws "java.net.SocketException:Invalid argument" on Linux if run as root

Alan Bateman Alan.Bateman at oracle.com
Thu Oct 21 07:25:27 PDT 2010


Chris Hegarty wrote:
> :
> 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.
>
The main concern is that you are hide a real "invalid argument" case. It 
would be good to follow this up with the Linux folks to clarify if the 
error make sense for this case.

So have you considered any other solution to this? I'm just wondering if 
it would be saner to check if the network interface is the loopback 
interface, and if so, just return false when the address is something 
other than the loopback. As regards the current fix - it's probably okay 
although it would be nicer if you didn't have to repeat the close and 
return JNI_FALSE.

-Alan.



More information about the net-dev mailing list