Re: icmp and raw sockets on linux

2020-11-29 Thread Jamie Le Tual
Although I've only just sent in the pdf form for an ora, I've already
submitted a pull request, https://github.com/openjdk/jdk/pull/1502 wherein
an attempt is first made to use an IPPROTO_ICMP socket before falling back
on RAW_SOCK and finally tcp echo.

I suppose now I have to wait until I am able to open an issue in the bug
tracker so I can associate the pull request to it.

Does anyone know what a unit test for this might look like? To cover the
use cases the code has to be invoked by both a privileged and unprivileged
user, and I'm not sure how to go about setting up a unit test.




On Sun, 29 Nov 2020 at 02:37, Alan Bateman  wrote:

> On 28/11/2020 02:42, Jamie Le Tual wrote:
>
> :
>
> It all seems to check out (at least on my machine,) the icmp packets look
> good in wireshark, so the first thing I'm wondering is what the catch must
> be, because this seems like a simple solution and I'm wondering why it was
> never done like this.
>
> The isReachable methods were added in Java 5 so they pre-date the kernel
> support for non-privileged ICMP. It seems a good idea to explore this now
> and work through any implications for using it.
>
> -Alan.
>


Re: icmp and raw sockets on linux

2020-11-29 Thread Alan Bateman

On 29/11/2020 14:54, Jamie Le Tual wrote:
Although I've only just sent in the pdf form for an ora, I've already 
submitted a pull request, https://github.com/openjdk/jdk/pull/1502 
 
wherein an attempt is first made to use an IPPROTO_ICMP socket before 
falling back on RAW_SOCK and finally tcp echo.


I suppose now I have to wait until I am able to open an issue in the 
bug tracker so I can associate the pull request to it.


Does anyone know what a unit test for this might look like? To cover 
the use cases the code has to be invoked by both a privileged and 
unprivileged user, and I'm not sure how to go about setting up a unit 
test.


I've created JDK-8257235 [1] to track this. One thing to understand is 
whether there is an equivalent for IPPROTO_ICMPV6. Sorry, I can't look 
at the patch or comment in the PR until the bot confirms that you have 
signed the OCA.


Have you looked at the existing tests in test/jdk/java/net/InetAddress? 
It will be awkward to verify as the behaviour before/after will not be 
observable without looking at the network or system call trace.


-Alan

[1] https://bugs.openjdk.java.net/browse/JDK-8257235