RFR : 8072384 : Setting IP_TOS on java.net sockets not working on unix

Seán Coffey sean.coffey at oracle.com
Wed Mar 25 17:21:39 UTC 2015


I didn't see any review on this request yet. I've modified the 
OptionsTest to test for IP_TOS on ServerSockets. The 
-Djava.net.preferIPv4Stack=true addition also allows the code to test 
both stacks where applicable.

http://cr.openjdk.java.net/~coffeys/webrev.8072384.jdk9.v2/webrev/

regards,
Sean.

On 27/02/15 11:37, Seán Coffey wrote:
> It looks like setting and getting the IP_TOS values on the java.net 
> Sockets is currently broken for some scenarios. It's not possible to 
> set the value on a ServerSocket via the jdk.net.Sockets.setOption API. 
> See below for a webrev I'm proposing. It basically makes best efforts 
> to set the IP_TOS value by mapping it to the IPV6_TCLASS option in an 
> IPV6 enabled environment. NIO follows a similar approach.
>
> Some of the comments in NET_SetSockOpt seem to be legacy and I've 
> removed the no-op that was in place for IP_TOS. A corner case of 
> setting of IP_TOS was found on Solaris. It doesn't seem to support 
> setting the value once the socket is connected. I've handled this via 
> catching of exception and we should be ok with this since the spec 
> doesn't make any promises in this area if the socket is connected.
>
> I've been testing various fixes across IPv4/v6 sockets on Solaris, 
> Linux and macosx. So far, the proposed changes seem to work and 
> wireshark traces help to confirm that TOS/TCLASS values are being set.
>
> I still need to see if I can improve the getOpt logic for IP_TOS. At 
> the moment, it can return a cached value which may not represent the 
> true value in place at kernel socket level. I'll also improve test 
> coverage in this area.
>
> bug report : https://bugs.openjdk.java.net/browse/JDK-8072384
> webrev : 
> http://cr.openjdk.java.net/~coffeys/webrev.8072384.jdk9.v1/webrev/
>
> regards,
> Sean.
>
>



More information about the net-dev mailing list