[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-net-dev
Subject:    RE: Patch for adding SO_REUSEPORT socket option
From:       "Lu, Yingqi" <yingqi.lu () intel ! com>
Date:       2015-11-26 1:11:49
Message-ID: 9ACD5B67AAC5594CB6268234CF29CF9AA3A8A611 () ORSMSX113 ! amr ! corp ! intel ! com
[Download RAW message or body]

[Attachment #2 (text/plain)]

Here is an update.

Changes are already completed locally. All the tests passed on an old Linux kernel \
3.4.110 which does not have SO_REUSEPORT. Same tests are done on Linux 4.2 kernel \
before.

Here are the quick information on the current implementation:


1.       For multicast socket, SO_REUSEPORT will be set by default if supported. We \
use Net.reuseportSupported method to check before calling setReusePort(). If not \
supported, will silently continue without setting it.

2.       For socket, serversocket and datagramsocket, we check if SO_REUSEPORT is \
supported before calling setOption/getOption and setReusePort/ getReusePort methods. \
If not supported, UOE exception will be thrown.

3.       We modified a bug in the OptionsTest.java file.

We will test Windows environment to see if it behaves the expected way. However, we \
need help to test other OSes from the community ☺

Due to the Thanksgiving holiday schedule, we will send updated webrev package on \
Monday.

Thank you all for your help and happy thanksgiving!
Lucy


From: Lu, Yingqi
Sent: Wednesday, November 25, 2015 1:23 PM
To: 'Volker Simonis' <volker.simonis@gmail.com>
Cc: Michael McMahon <michael.x.mcmahon@oracle.com>; Alan Bateman \
<Alan.Bateman@oracle.com>; Kharbas, Kishor <kishor.kharbas@intel.com>; \
                net-dev@openjdk.java.net; Kaczmarek, Eric <eric.kaczmarek@intel.com>
Subject: RE: Patch for adding SO_REUSEPORT socket option

Yes, it should work! I already located the issues. Good catch!

I will submit an update as soon as possible.

Thanks,
Lucy

From: Volker Simonis [mailto:volker.simonis@gmail.com]
Sent: Wednesday, November 25, 2015 12:17 PM
To: Lu, Yingqi <yingqi.lu@intel.com<mailto:yingqi.lu@intel.com>>
Cc: Michael McMahon <michael.x.mcmahon@oracle.com<mailto:michael.x.mcmahon@oracle.com>>; \
Alan Bateman <Alan.Bateman@oracle.com<mailto:Alan.Bateman@oracle.com>>; Kharbas, \
Kishor <kishor.kharbas@intel.com<mailto:kishor.kharbas@intel.com>>; \
net-dev@openjdk.java.net<mailto:net-dev@openjdk.java.net>; Kaczmarek, Eric \
                <eric.kaczmarek@intel.com<mailto:eric.kaczmarek@intel.com>>
Subject: Re: Patch for adding SO_REUSEPORT socket option

Yes, I indeed tested on an old kernel - but that should still work after your change!

On Wednesday, November 25, 2015, Lu, Yingqi \
<yingqi.lu@intel.com<mailto:yingqi.lu@intel.com>> wrote: Hi Volker,

Thanks very much for letting me know. I actually took the related regression tests \
and they all passed. I think you tested on an old kernel which does not have \
SO_REUSEPORT enabled. In this case, it should not set the flag.

Let me double check. I will get back to you as soon as I can.

Thanks,
Lucy

-----Original Message-----
From: Volker Simonis [mailto:volker.simonis@gmail.com<javascript:;>]
Sent: Wednesday, November 25, 2015 10:46 AM
To: Lu, Yingqi <yingqi.lu@intel.com<javascript:;>>
Cc: Michael McMahon <michael.x.mcmahon@oracle.com<javascript:;>>; Alan Bateman \
<Alan.Bateman@oracle.com<javascript:;>>; Kharbas, Kishor \
<kishor.kharbas@intel.com<javascript:;>>; net-dev@openjdk.java.net<javascript:;>; \
                Kaczmarek, Eric <eric.kaczmarek@intel.com<javascript:;>>
Subject: Re: Patch for adding SO_REUSEPORT socket option

Hi Lucy,

I took a brief look at your changes but there seems to be something not right. I \
can't understand for example why you unconditionally try to set SO_REUSEPORT on all \
sockets in Java_sun_nio_ch_Net_socket0() ?

Also which your changes applied, simple regression tests like \
test/java/net/SocketOption/OptionsTest.java start to fail even on Linux/x86_64:

java.net.SocketException: Protocol not available
        at java.net.PlainDatagramSocketImpl.socketSetOption0(Native Method)
        at java.net.PlainDatagramSocketImpl.socketSetOption(PlainDatagramSocketImpl.java:85)
                
        at java.net.AbstractPlainDatagramSocketImpl.setOption(AbstractPlainDatagramSocketImpl.java:314)
  at java.net.DatagramSocket.setReusePort(DatagramSocket.java:1145)
        at java.net.MulticastSocket.<init>(MulticastSocket.java:180)
        at java.net.MulticastSocket.<init>(MulticastSocket.java:142)
        at OptionsTest.doMcSocketTests(OptionsTest.java:131)
        at OptionsTest.main(OptionsTest.java:247)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:520)
        at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:92)
  at java.lang.Thread.run(Thread.java:747)


Can you please make sure that your changes at least don't break the regression tests?

Thank you and best regards,
Volker

On Tue, Nov 24, 2015 at 6:04 PM, Lu, Yingqi <yingqi.lu@intel.com<javascript:;>> \
wrote:
> Hi Michael/Alan/Volker,
> 
> Following your suggestions, here is the most recent version (Version
> 4) of the patch.
> http://cr.openjdk.java.net/~mcberg/jdk/6432031/webrev.04/
> 
> In this version, we have done following changes:
> 
> 1. Add reuseportSupported() method in sun.nio.ch.Net<http://sun.nio.ch.Net> and its \
> implementation in Net.c. Only add SO_REUSEPORT to the option set when it is \
> supported. In all the tests, we use supportedOptions method to test if SO_REUSEPORT \
> is supported or not. 
> 2. We dropped NetworkChannels from the Javadoc. We removed Linux specific wordings \
> in Javadoc for SO_REUSEPORT. 
> 3. We expand the feature to all UNIX based OSes. However, we do not have all the \
> OSes to test. Please test and let us know if there is anything missing in either \
> compilation or run time. 
> Please review the patch and let us know your feedback. Thank you very much for your \
> help! 
> Thanks,
> Lucy
> 
> -----Original Message-----
> From: net-dev [mailto:net-dev-bounces@openjdk.java.net<javascript:;>] On Behalf Of
> Michael McMahon
> Sent: Monday, November 23, 2015 2:54 AM
> To: Volker Simonis <volker.simonis@gmail.com<javascript:;>>; Alan Bateman
> <Alan.Bateman@oracle.com<javascript:;>>
> Cc: Kharbas, Kishor <kishor.kharbas@intel.com<javascript:;>>;
> net-dev@openjdk.java.net<javascript:;>
> Subject: Re: Patch for adding SO_REUSEPORT socket option
> 
> I agree we should enable the option on all platforms.
> We can add the code to do that and run the tests.
> 
> On the existing use of SO_REUSEPORT on AIX and Mac it appears that is set to \
> emulate expected behavior on other platforms when SO_REUSEADDR is set for datagram \
> sockets. The expectation is that ports can be reused for datagram sockets and the \
> JCK tests this. So, I guess we have to leave this behavior by default, except if \
> SO_REUSEPORT is explicitly disabled maybe. Though this code hasn't been forward \
> ported to JDK 9 yet. 
> For reference, SO_REUSEPORT on Linux is documented here
> http://man7.org/linux/man-pages/man7/socket.7.html
> 
> - Michael
> 
> On 23/11/15 09:13, Volker Simonis wrote:
> > Hi Lucy,
> > 
> > in general I support the addition of SO_REUSEPORT to the set of
> > standard socket options. However for me the problem is not that this
> > new option is not supported on all platforms, but instead that it has
> > such different semantics on different platforms. If you look at the
> > code, you'll see that we already implicitly set SO_REUSEPORT on Mac
> > and AIX for datagram sockets for which we set SO_REUSEADDR. So maybe
> > we have to rethink this, once  SO_REUSEPORT becomes available as a
> > standard socket option.
> > 
> > I like the new wording you've posted for JavaDoc of SO_REUSEPORT, but
> > I think the sentence:
> > 
> > * Although SO_REUSEADDR option already enables similar
> > * functionality, SO_REUSEPORT prevents port hijacking and
> > * distributes the involving datagrams evenly across all of the
> > * receiving threads.
> > 
> > refers to a Linux-specific implementation detail which shouldn't be
> > mentioned in the general documentation. You already have the sentence
> > "The exact semantics of this socket option are socket type and system
> > dependent" which should let everybody think twice before using this
> > option. I'm also not sure about the link to the Linux article but I
> > again think it is inappropriate in a general API documentation
> > (otherwise we would have to add links for every platform which
> > supports SO_REUSEPORT).
> > 
> > As far as I can see (and please correct me if I'm wrong) you actually
> > only add the new option for Linux platforms. But this socket option
> > is also supported on Solaris (>= 11), MacOS X, AIX. So could you
> > please enable it on the other platforms as well.
> > 
> > Finally I want to mention the good stackoverflow article at
> > http://stackoverflow.com/questions/14388706/socket-options-so-reusead
> > d r-and-so-reuseport-how-do-they-differ-do-they-mean-t
> > which covers the topic SO_REUSEADDR vs. SO_REUSEPORT quite well. And
> > I've collected the man-page entries for SO_REUSEADDR and SO_REUSEPORT
> > for the systems I have  (unfortunately, I couldn't find an updated
> > Linux man-page which mentions SO_REUSEPORT):
> > 
> > Linux
> > =====
> > 
> > SO_REUSEADDR
> > Indicates that the rules used in validating addresses
> > supplied in a bind(2) call should allow reuse of local
> > addresses.  For AF_INET sockets this means that a socket
> > may bind, except when there is an active listening
> > socket bound to the address.  When the listening socket
> > is bound to INADDR_ANY with a specific port then it is
> > not possi- ble to bind to this port for any local
> > address.  Argument is an integer boolean flag.
> > 
> > Linux will only allow port reuse with the SO_REUSEADDR option
> > when this option was set both in the previous program that
> > performed a bind(2) to the port and in the program that wants
> > to reuse the port.  This differs from some implementations
> > (e.g., FreeBSD) where only the later program needs to set the
> > SO_REUSEADDR option.  Typically this difference is invisi- ble,
> > since, for example, a server program is designed to always set
> > this option.
> > 
> > MacOS X
> > =======
> > SO_REUSEADDR    enables local address reuse
> > SO_REUSEPORT    enables duplicate address and port bindings
> > 
> > SO_REUSEADDR indicates that the rules used in validating
> > addresses supplied in a bind(2) call should allow reuse of local
> > addresses.
> > 
> > SO_REUSEPORT allows completely duplicate bindings by multiple
> > processes if they all set SO_REUSEPORT before bind- ing the port.
> > This option permits multiple instances of a program to each
> > receive UDP/IP multicast or broadcast datagrams destined for the
> > bound port.
> > 
> > Solaris
> > =======
> > 
> > SO_REUSEADDR          enable/disable local address reuse
> > 
> > 
> > SO_REUSEPORT          enable/disable local  port  reuse  for
> > PF_INET/PF_INET6 socket
> > 
> > The SO_REUSEADDR/SO_REUSEPORT options indi- cate that the rules
> > used in validating addresses and ports supplied in a
> > bind(3SOCKET) call should allow reuse of local addresses or
> > ports.
> > 
> > AIX
> > ===
> > 
> > SO_REUSEADDR
> > Specifies that the rules used in validating
> > addresses supplied by a bind subroutine should
> > allow reuse of a local port. A particular IP
> > address can only be bound once to the same
> > port. This option enables or disables reuse of
> > local ports.
> > 
> > SO_REUSEADDR allows an application to explicitly
> > deny subsequent bind subroutine to the port/address
> > of the socket with SO_REUSEADDR set. This allows an
> > application to block other applications from
> > binding with the bind subroutine.
> > 
> > SO_REUSEPORT
> > Specifies that the rules used in validating
> > addresses supplied by a bind subroutine should
> > allow reuse of a local port/address
> > combination. Each binding of the port/address
> > combination must specify the SO_REUSEPORT socket
> > option. This option enables or disables the reuse
> > of local port/address combinations.
> > 
> > HPUX
> > ====
> > 
> > SO_REUSEADDR
> > (int; boolean; AF_INET sockets only) If enabled, allows
> > a local address to be reused in subsequent calls to
> > bind().  Default: disallowed.
> > 
> > SO_REUSEPORT
> > (int; boolean; AF_INET sockets only) If enabled, allows
> > a local address and port to be reused in subsequent
> > calls to bind().  Default: disallowed.
> > 
> > Setting the SO_REUSEADDR option allows the local socket address
> > to be reused in subsequent calls to bind().  This permits
> > multiple SOCK_STREAM sockets to be bound to the same local
> > address, as long as all existing sockets with the desired local
> > address are in a connected state before bind() is called for a
> > new socket.  For SOCK_DGRAM sockets, SO_REUSEADDR allows
> > multiple sockets to receive UDP multicast datagrams addressed to
> > the bound port number.  For all SOCK_DGRAM sockets bound to the
> > same local address, SO_REUSEADDR must be set before calling
> > bind().
> > 
> > Setting the SO_REUSEPORT option allows multiple SOCK_DGRAM
> > sockets to share the same address and port.  Each one of those
> > sockets, including the first one to use that port, must specify
> > this option before calling bind().
> > 
> > Regards,
> > Volker
> > 
> > 
> > On Mon, Nov 23, 2015 at 9:00 AM, Alan Bateman \
> > <Alan.Bateman@oracle.com<javascript:;>> wrote:
> > > 
> > > On 23/11/2015 04:12, Lu, Yingqi wrote:
> > > 
> > > Hi Alan,
> > > 
> > > 
> > > 
> > > One more question please J I want to make sure I understand
> > > correctly on your following suggestion. In order to use
> > > supportedOptions method to test SO_REUSEPORT, I will need to first
> > > write a native function to check if SO_REUSEPORT is supported. Then,
> > > in the defaultOptions method, I do a conditional add for
> > > StandardSocketOptions.SO_REUSEPORT
> > > if it is supported on the platform? Is this a preferred way to implement? \
> > > Please let me know! 
> > > 
> > > Yes as supportedOptions() shouldn't return SO_REUSEPORT in the set
> > > when it's not supported. It might be simplest to put that code in
> > > sun.nio.ch.Net<http://sun.nio.ch.Net>, maybe isReusePortSupported or some such \
> > > method. In the implementation
> > > (Net.c) then you can return true or false depending on the platform
> > > and maybe kernel version.
> > > 
> > > -Alan
> 


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:SimSun;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:"\@SimSun";
	panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:.5in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman",serif;}
span.EmailStyle17
	{mso-style-type:personal;
	font-family:"Calibri",sans-serif;
	color:#1F497D;}
span.EmailStyle18
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:1588727522;
	mso-list-type:hybrid;
	mso-list-template-ids:-2128680830 67698703 67698713 67698715 67698703 67698713 \
67698715 67698703 67698713 67698715;} @list l0:level1
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level2
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level3
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
@list l0:level4
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level5
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level6
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
@list l0:level7
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level8
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level9
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
@list l1
	{mso-list-id:2122603040;
	mso-list-type:hybrid;
	mso-list-template-ids:781776878 67698703 67698713 67698715 67698703 67698713 \
67698715 67698703 67698713 67698715;} @list l1:level1
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l1:level2
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l1:level3
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
@list l1:level4
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l1:level5
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l1:level6
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
@list l1:level7
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l1:level8
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l1:level9
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Here \
is an update.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Changes \
are already completed locally. All the tests passed on an old Linux kernel 3.4.110 \
which does not have SO_REUSEPORT. Same tests are done on Linux 4.2  kernel \
before.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Here \
are the quick information on the current implementation:<o:p></o:p></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l1 level1 lfo2"><![if \
!supportLists]><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><span \
style="mso-list:Ignore">1.<span style="font:7.0pt &quot;Times New \
Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></span></span><![endif]><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">For \
multicast socket, SO_REUSEPORT will be set by default if supported. We use \
Net.reuseportSupported method to check before calling setReusePort().  If not \
supported, will silently continue without setting it.<o:p></o:p></span></p> <p \
class="MsoListParagraph" style="text-indent:-.25in;mso-list:l1 level1 lfo2"><![if \
!supportLists]><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><span \
style="mso-list:Ignore">2.<span style="font:7.0pt &quot;Times New \
Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></span></span><![endif]><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">For \
socket, serversocket and datagramsocket, we check if SO_REUSEPORT is supported before \
calling setOption/getOption and setReusePort/ getReusePort  methods. If not \
supported, UOE exception will be thrown. <o:p></o:p></span></p> <p \
class="MsoListParagraph" style="text-indent:-.25in;mso-list:l1 level1 lfo2"><![if \
!supportLists]><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><span \
style="mso-list:Ignore">3.<span style="font:7.0pt &quot;Times New \
Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></span></span><![endif]><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">We \
modified a bug in the OptionsTest.java file.<o:p></o:p></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">We \
will test Windows environment to see if it behaves the expected way. However, we need \
help to test other OSes from the community </span><span \
style="font-size:11.0pt;font-family:Wingdings;color:#1F497D">J</span><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p></o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Due \
to the Thanksgiving holiday schedule, we will send updated webrev package on \
Monday.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Thank \
you all for your help and happy thanksgiving!<o:p></o:p></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Lucy<o:p></o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"> Lu, Yingqi <br>
<b>Sent:</b> Wednesday, November 25, 2015 1:23 PM<br>
<b>To:</b> 'Volker Simonis' &lt;volker.simonis@gmail.com&gt;<br>
<b>Cc:</b> Michael McMahon &lt;michael.x.mcmahon@oracle.com&gt;; Alan Bateman \
&lt;Alan.Bateman@oracle.com&gt;; Kharbas, Kishor &lt;kishor.kharbas@intel.com&gt;; \
net-dev@openjdk.java.net; Kaczmarek, Eric &lt;eric.kaczmarek@intel.com&gt;<br> \
<b>Subject:</b> RE: Patch for adding SO_REUSEPORT socket option<o:p></o:p></span></p> \
</div> </div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Yes, \
it should work! I already located the issues. Good catch! <o:p></o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">I \
will submit an update as soon as possible.<o:p></o:p></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Thanks,<o:p></o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Lucy<o:p></o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><b><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"> Volker Simonis \
[<a href="mailto:volker.simonis@gmail.com">mailto:volker.simonis@gmail.com</a>] <br>
<b>Sent:</b> Wednesday, November 25, 2015 12:17 PM<br>
<b>To:</b> Lu, Yingqi &lt;<a \
href="mailto:yingqi.lu@intel.com">yingqi.lu@intel.com</a>&gt;<br> <b>Cc:</b> Michael \
McMahon &lt;<a href="mailto:michael.x.mcmahon@oracle.com">michael.x.mcmahon@oracle.com</a>&gt;; \
Alan Bateman &lt;<a href="mailto:Alan.Bateman@oracle.com">Alan.Bateman@oracle.com</a>&gt;; \
Kharbas, Kishor &lt;<a \
href="mailto:kishor.kharbas@intel.com">kishor.kharbas@intel.com</a>&gt;; <a \
href="mailto:net-dev@openjdk.java.net">net-dev@openjdk.java.net</a>; Kaczmarek, Eric \
&lt;<a href="mailto:eric.kaczmarek@intel.com">eric.kaczmarek@intel.com</a>&gt;<br> \
<b>Subject:</b> Re: Patch for adding SO_REUSEPORT socket option<o:p></o:p></span></p> \
<p class="MsoNormal"><o:p>&nbsp;</o:p></p> <p class="MsoNormal">Yes, I indeed tested \
on an old kernel - but that should still work after your change!<br> <br>
On Wednesday, November 25, 2015, Lu, Yingqi &lt;<a \
href="mailto:yingqi.lu@intel.com">yingqi.lu@intel.com</a>&gt; wrote:<o:p></o:p></p> \
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in \
6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt"> <p \
class="MsoNormal">Hi Volker,<br> <br>
Thanks very much for letting me know. I actually took the related regression tests \
and they all passed. I think you tested on an old kernel which does not have \
SO_REUSEPORT enabled. In this case, it should not set the flag.<br> <br>
Let me double check. I will get back to you as soon as I can.<br>
<br>
Thanks,<br>
Lucy<br>
<br>
-----Original Message-----<br>
From: Volker Simonis [mailto:<a href="javascript:;">volker.simonis@gmail.com</a>]<br>
Sent: Wednesday, November 25, 2015 10:46 AM<br>
To: Lu, Yingqi &lt;<a href="javascript:;">yingqi.lu@intel.com</a>&gt;<br>
Cc: Michael McMahon &lt;<a href="javascript:;">michael.x.mcmahon@oracle.com</a>&gt;; \
Alan Bateman &lt;<a href="javascript:;">Alan.Bateman@oracle.com</a>&gt;; Kharbas, \
Kishor &lt;<a href="javascript:;">kishor.kharbas@intel.com</a>&gt;; <a \
href="javascript:;">net-dev@openjdk.java.net</a>; Kaczmarek, Eric &lt;<a \
                href="javascript:;">eric.kaczmarek@intel.com</a>&gt;<br>
Subject: Re: Patch for adding SO_REUSEPORT socket option<br>
<br>
Hi Lucy,<br>
<br>
I took a brief look at your changes but there seems to be something not right. I \
can't understand for example why you unconditionally try to set SO_REUSEPORT on all \
sockets in Java_sun_nio_ch_Net_socket0() ?<br> <br>
Also which your changes applied, simple regression tests like \
test/java/net/SocketOption/OptionsTest.java start to fail even on<br> \
Linux/x86_64:<br> <br>
java.net.SocketException: Protocol not available<br>
&nbsp; &nbsp; &nbsp; &nbsp; at \
java.net.PlainDatagramSocketImpl.socketSetOption0(Native Method)<br> &nbsp; &nbsp; \
&nbsp; &nbsp; at java.net.PlainDatagramSocketImpl.socketSetOption(PlainDatagramSocketImpl.java:85)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; at \
java.net.AbstractPlainDatagramSocketImpl.setOption(AbstractPlainDatagramSocketImpl.java:314)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; at \
java.net.DatagramSocket.setReusePort(DatagramSocket.java:1145)<br> &nbsp; &nbsp; \
&nbsp; &nbsp; at java.net.MulticastSocket.&lt;init&gt;(MulticastSocket.java:180)<br> \
&nbsp; &nbsp; &nbsp; &nbsp; at \
java.net.MulticastSocket.&lt;init&gt;(MulticastSocket.java:142)<br> &nbsp; &nbsp; \
&nbsp; &nbsp; at OptionsTest.doMcSocketTests(OptionsTest.java:131)<br> &nbsp; &nbsp; \
&nbsp; &nbsp; at OptionsTest.main(OptionsTest.java:247)<br> &nbsp; &nbsp; &nbsp; \
&nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br> &nbsp; \
&nbsp; &nbsp; &nbsp; at \
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)<br> \
&nbsp; &nbsp; &nbsp; &nbsp; at \
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Method.java:520)<br>
&nbsp; &nbsp; &nbsp; &nbsp; at \
com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:92)<br> \
&nbsp; &nbsp; &nbsp; &nbsp; at java.lang.Thread.run(Thread.java:747)<br> <br>
<br>
Can you please make sure that your changes at least don't break the regression \
tests?<br> <br>
Thank you and best regards,<br>
Volker<br>
<br>
On Tue, Nov 24, 2015 at 6:04 PM, Lu, Yingqi &lt;<a \
href="javascript:;">yingqi.lu@intel.com</a>&gt; wrote:<br> &gt; Hi \
Michael/Alan/Volker,<br> &gt;<br>
&gt; Following your suggestions, here is the most recent version (Version<br>
&gt; 4) of the patch.<br>
&gt; <a href="http://cr.openjdk.java.net/~mcberg/jdk/6432031/webrev.04/" \
target="_blank"> http://cr.openjdk.java.net/~mcberg/jdk/6432031/webrev.04/</a><br>
&gt;<br>
&gt; In this version, we have done following changes:<br>
&gt;<br>
&gt; 1. Add reuseportSupported() method in <a href="http://sun.nio.ch.Net" \
target="_blank"> sun.nio.ch.Net</a> and its implementation in Net.c. Only add \
SO_REUSEPORT to the option set when it is supported. In all the tests, we use \
supportedOptions method to test if SO_REUSEPORT is supported or not.<br> &gt;<br>
&gt; 2. We dropped NetworkChannels from the Javadoc. We removed Linux specific \
wordings in Javadoc for SO_REUSEPORT.<br> &gt;<br>
&gt; 3. We expand the feature to all UNIX based OSes. However, we do not have all the \
OSes to test. Please test and let us know if there is anything missing in either \
compilation or run time.<br> &gt;<br>
&gt; Please review the patch and let us know your feedback. Thank you very much for \
your help!<br> &gt;<br>
&gt; Thanks,<br>
&gt; Lucy<br>
&gt;<br>
&gt; -----Original Message-----<br>
&gt; From: net-dev [mailto:<a \
href="javascript:;">net-dev-bounces@openjdk.java.net</a>] On Behalf Of<br> &gt; \
Michael McMahon<br> &gt; Sent: Monday, November 23, 2015 2:54 AM<br>
&gt; To: Volker Simonis &lt;<a href="javascript:;">volker.simonis@gmail.com</a>&gt;; \
Alan Bateman<br> &gt; &lt;<a href="javascript:;">Alan.Bateman@oracle.com</a>&gt;<br>
&gt; Cc: Kharbas, Kishor &lt;<a \
href="javascript:;">kishor.kharbas@intel.com</a>&gt;;<br> &gt; <a \
href="javascript:;">net-dev@openjdk.java.net</a><br> &gt; Subject: Re: Patch for \
adding SO_REUSEPORT socket option<br> &gt;<br>
&gt; I agree we should enable the option on all platforms.<br>
&gt; We can add the code to do that and run the tests.<br>
&gt;<br>
&gt; On the existing use of SO_REUSEPORT on AIX and Mac it appears that is set to \
emulate expected behavior on other platforms when SO_REUSEADDR is set for datagram \
sockets.<br> &gt; The expectation is that ports can be reused for datagram sockets \
and the JCK tests this. So, I guess we have to leave this behavior by default, except \
if SO_REUSEPORT is explicitly disabled maybe. Though this code hasn't been forward \
ported to JDK 9 yet.<br> &gt;<br>
&gt; For reference, SO_REUSEPORT on Linux is documented here<br>
&gt; <a href="http://man7.org/linux/man-pages/man7/socket.7.html" \
target="_blank">http://man7.org/linux/man-pages/man7/socket.7.html</a><br> &gt;<br>
&gt; - Michael<br>
&gt;<br>
&gt; On 23/11/15 09:13, Volker Simonis wrote:<br>
&gt;&gt; Hi Lucy,<br>
&gt;&gt;<br>
&gt;&gt; in general I support the addition of SO_REUSEPORT to the set of<br>
&gt;&gt; standard socket options. However for me the problem is not that this<br>
&gt;&gt; new option is not supported on all platforms, but instead that it has<br>
&gt;&gt; such different semantics on different platforms. If you look at the<br>
&gt;&gt; code, you'll see that we already implicitly set SO_REUSEPORT on Mac<br>
&gt;&gt; and AIX for datagram sockets for which we set SO_REUSEADDR. So maybe<br>
&gt;&gt; we have to rethink this, once&nbsp; SO_REUSEPORT becomes available as a<br>
&gt;&gt; standard socket option.<br>
&gt;&gt;<br>
&gt;&gt; I like the new wording you've posted for JavaDoc of SO_REUSEPORT, but<br>
&gt;&gt; I think the sentence:<br>
&gt;&gt;<br>
&gt;&gt; * Although SO_REUSEADDR option already enables similar<br>
&gt;&gt; * functionality, SO_REUSEPORT prevents port hijacking and<br>
&gt;&gt; * distributes the involving datagrams evenly across all of the<br>
&gt;&gt; * receiving threads.<br>
&gt;&gt;<br>
&gt;&gt; refers to a Linux-specific implementation detail which shouldn't be<br>
&gt;&gt; mentioned in the general documentation. You already have the sentence<br>
&gt;&gt; &quot;The exact semantics of this socket option are socket type and \
system<br> &gt;&gt; dependent&quot; which should let everybody think twice before \
using this<br> &gt;&gt; option. I'm also not sure about the link to the Linux article \
but I<br> &gt;&gt; again think it is inappropriate in a general API documentation<br>
&gt;&gt; (otherwise we would have to add links for every platform which<br>
&gt;&gt; supports SO_REUSEPORT).<br>
&gt;&gt;<br>
&gt;&gt; As far as I can see (and please correct me if I'm wrong) you actually<br>
&gt;&gt; only add the new option for Linux platforms. But this socket option<br>
&gt;&gt; is also supported on Solaris (&gt;= 11), MacOS X, AIX. So could you<br>
&gt;&gt; please enable it on the other platforms as well.<br>
&gt;&gt;<br>
&gt;&gt; Finally I want to mention the good stackoverflow article at<br>
&gt;&gt; <a href="http://stackoverflow.com/questions/14388706/socket-options-so-reusead" \
target="_blank"> http://stackoverflow.com/questions/14388706/socket-options-so-reusead</a><br>
 &gt;&gt; d r-and-so-reuseport-how-do-they-differ-do-they-mean-t<br>
&gt;&gt; which covers the topic SO_REUSEADDR vs. SO_REUSEPORT quite well. And<br>
&gt;&gt; I've collected the man-page entries for SO_REUSEADDR and SO_REUSEPORT<br>
&gt;&gt; for the systems I have&nbsp; (unfortunately, I couldn't find an updated<br>
&gt;&gt; Linux man-page which mentions SO_REUSEPORT):<br>
&gt;&gt;<br>
&gt;&gt; Linux<br>
&gt;&gt; =====<br>
&gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SO_REUSEADDR<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Indicates that the \
rules used in validating addresses<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; supplied in a bind(2) call should allow reuse of local<br> \
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addresses.&nbsp; For \
AF_INET sockets this means that a socket<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; may bind, except when there is an active listening<br> \
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; socket bound to the \
address.&nbsp; When the listening socket<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; is bound to INADDR_ANY with a specific port then it \
is<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; not possi- ble \
to bind to this port for any local<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; address.&nbsp; Argument is an integer boolean flag.<br> \
&gt;&gt;<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Linux will only allow port \
reuse with the SO_REUSEADDR option<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;when \
this option was set both in the previous program that<br> &gt;&gt;&nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;performed a bind(2) to the port and in the program that wants<br> \
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;to reuse the port.&nbsp; This differs from \
some implementations<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(e.g., FreeBSD) \
where only the later program needs to set the<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;SO_REUSEADDR option.&nbsp; Typically this difference is invisi- ble,<br> \
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;since, for example, a server program is \
designed to always set<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this option.<br>
&gt;&gt;<br>
&gt;&gt; MacOS X<br>
&gt;&gt; =======<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SO_REUSEADDR&nbsp; &nbsp; \
enables local address reuse<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;SO_REUSEPORT&nbsp; &nbsp; enables duplicate address and port bindings<br> \
&gt;&gt;<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;SO_REUSEADDR indicates that the rules \
used in validating<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;addresses supplied in a \
bind(2) call should allow reuse of local<br> &gt;&gt;&nbsp; &nbsp; &nbsp; \
&nbsp;addresses.<br> &gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;SO_REUSEPORT allows completely duplicate bindings \
by multiple<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;processes if they all set \
SO_REUSEPORT before bind- ing the port.<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;This \
option permits multiple instances of a program to each<br> &gt;&gt;&nbsp; &nbsp; \
&nbsp; &nbsp;receive UDP/IP multicast or broadcast datagrams destined for the<br> \
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;bound port.<br> &gt;&gt;<br>
&gt;&gt; Solaris<br>
&gt;&gt; =======<br>
&gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;SO_REUSEADDR&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
enable/disable local address reuse<br> &gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;SO_REUSEPORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
enable/disable local&nbsp; port&nbsp; reuse&nbsp; for<br> &gt;&gt;&nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;PF_INET/PF_INET6 socket<br> &gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;The SO_REUSEADDR/SO_REUSEPORT options indi- cate \
that the rules<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;used in validating addresses \
and ports supplied in a<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;bind(3SOCKET) call \
should allow reuse of local addresses or<br> &gt;&gt;&nbsp; &nbsp; &nbsp; \
&nbsp;ports.<br> &gt;&gt;<br>
&gt;&gt; AIX<br>
&gt;&gt; ===<br>
&gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SO_REUSEADDR<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;Specifies that the rules used in validating<br> &gt;&gt;&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;addresses supplied by a bind \
subroutine should<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;allow reuse of a local port. A particular IP<br> &gt;&gt;&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;address can only \
be bound once to the same<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;port. This option enables or disables reuse of<br> \
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;local ports.<br> &gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;SO_REUSEADDR allows an application to explicitly<br> &gt;&gt;&nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;deny subsequent bind \
subroutine to the port/address<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;of the socket with SO_REUSEADDR set. This allows \
an<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;application to block other applications from<br> &gt;&gt;&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;binding with the bind \
subroutine.<br> &gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SO_REUSEPORT<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;Specifies that the rules used in validating<br> &gt;&gt;&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;addresses supplied by a bind \
subroutine should<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;allow reuse of a local port/address<br> &gt;&gt;&nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;combination. Each \
binding of the port/address<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;combination must specify the SO_REUSEPORT \
socket<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp;option. This option enables or disables the reuse<br> &gt;&gt;&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;of local \
port/address combinations.<br> &gt;&gt;<br>
&gt;&gt; HPUX<br>
&gt;&gt; ====<br>
&gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SO_REUSEADDR<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (int; boolean; \
AF_INET sockets only) If enabled, allows<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; a local address to be reused in subsequent calls to<br> \
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bind().&nbsp; \
Default: disallowed.<br> &gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SO_REUSEPORT<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (int; boolean; \
AF_INET sockets only) If enabled, allows<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; a local address and port to be reused in subsequent<br> \
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; calls to \
bind().&nbsp; Default: disallowed.<br> &gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; Setting the SO_REUSEADDR option allows the local \
socket address<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; to be reused in subsequent \
calls to bind().&nbsp; This permits<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; multiple \
SOCK_STREAM sockets to be bound to the same local<br> &gt;&gt;&nbsp; &nbsp; &nbsp; \
&nbsp; address, as long as all existing sockets with the desired local<br> \
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; address are in a connected state before bind() is \
called for a<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; new socket.&nbsp; For SOCK_DGRAM \
sockets, SO_REUSEADDR allows<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; multiple sockets \
to receive UDP multicast datagrams addressed to<br> &gt;&gt;&nbsp; &nbsp; &nbsp; \
&nbsp; the bound port number.&nbsp; For all SOCK_DGRAM sockets bound to the<br> \
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; same local address, SO_REUSEADDR must be set \
before calling<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; bind().<br>
&gt;&gt;<br>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; Setting the SO_REUSEPORT option allows multiple \
SOCK_DGRAM<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; sockets to share the same address \
and port.&nbsp; Each one of those<br> &gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; sockets, \
including the first one to use that port, must specify<br> &gt;&gt;&nbsp; &nbsp; \
&nbsp; &nbsp; this option before calling bind().<br> &gt;&gt;<br>
&gt;&gt; Regards,<br>
&gt;&gt; Volker<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Mon, Nov 23, 2015 at 9:00 AM, Alan Bateman &lt;<a \
href="javascript:;">Alan.Bateman@oracle.com</a>&gt; wrote:<br> &gt;&gt;&gt;<br>
&gt;&gt;&gt; On 23/11/2015 04:12, Lu, Yingqi wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi Alan,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; One more question please J I want to make sure I understand<br>
&gt;&gt;&gt; correctly on your following suggestion. In order to use<br>
&gt;&gt;&gt; supportedOptions method to test SO_REUSEPORT, I will need to first<br>
&gt;&gt;&gt; write a native function to check if SO_REUSEPORT is supported. Then,<br>
&gt;&gt;&gt; in the defaultOptions method, I do a conditional add for<br>
&gt;&gt;&gt; StandardSocketOptions.SO_REUSEPORT<br>
&gt;&gt;&gt; if it is supported on the platform? Is this a preferred way to \
implement? Please let me know!<br> &gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Yes as supportedOptions() shouldn't return SO_REUSEPORT in the set<br>
&gt;&gt;&gt; when it's not supported. It might be simplest to put that code in<br>
&gt;&gt;&gt; <a href="http://sun.nio.ch.Net" target="_blank">sun.nio.ch.Net</a>, \
maybe isReusePortSupported or some such method. In<br> &gt;&gt;&gt; the \
implementation<br> &gt;&gt;&gt; (Net.c) then you can return true or false depending \
on the platform<br> &gt;&gt;&gt; and maybe kernel version.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; -Alan<br>
&gt;<o:p></o:p></p>
</blockquote>
</div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic