RFR : 8072384 : Setting IP_TOS on java.net sockets not working on unix
Michael McMahon
michael.x.mcmahon at oracle.com
Thu Jun 4 15:41:28 UTC 2015
Sean,
I'm happy with this change now.
Thanks
Michael
On 25/05/15 15:01, Seán Coffey wrote:
> Jumping back on this issue...Michael identified a regression on linux
> with my last webrev. It was connected with IPv6 sockets connecting to
> IPv4 interfaces. Linux seems to cater for IP_TOS settings in this
> area. I've modified my last webrev so that we only 'promote' IP_TOS
> requests to IPV6_TCLASS requests if dealing with solaris or macosx.
>
> I discovered one bug where setting IP_TOS on the server (remote)
> socket in an IPv6 <-> IPv6 environment wasn't working (on the server
> SYN reply packet) So overcome that, setting both the TOS and TCLASS
> values works and setsockopt on linux doesn't complain with such an
> approach. A simple server side test using the new Sockets API might be :
>
> jdk.net.Sockets.setOption(ss,
> java.net.StandardSocketOptions.IP_TOS, 128);
> ss.bind(new
> InetSocketAddress("2606:b400:818:8f:xxxx:xxxx:xxxx:xxxx", 19001));
> ss.accept();
>
> This is the server socket setsockopt strace with new fix :
>
> 16788 setsockopt(4, SOL_IPV6, IPV6_V6ONLY, [0], 4) = 0
> 16788 setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
> 16788 setsockopt(4, SOL_IPV6, 0x21 /* IPV6_??? */, [1], 4) = 0
> 16788 setsockopt(4, SOL_IPV6, 0x43 /* IPV6_??? */, [128], 4) = 0
> 16788 setsockopt(4, SOL_IP, IP_TOS, [128], 4) = 0
>
> Note :
> 0x43 == IPV6_TCLASS 67
> 0x21 == IPV6_FLOWINFO_SEND 33
>
> latest webrev :
> http://cr.openjdk.java.net/~coffeys/webrev.tos-may22/webrev/
>
> Regards,
> Sean.
>
> On 25/03/15 17:21, Seán Coffey wrote:
>> 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