login
Header Space

 
 

Re: SO_REUSEADDR not allowing server and client to use same port

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Nebojsa Miljanovic <neb@...>
Cc: <linux-kernel@...>, Kittlitz, Edward (Ned) <nkittlitz@...>, <asweeney@...>, Polhemus, William (Bart) <bpolhemus@...>, <netdev@...>
Date: Thursday, February 28, 2008 - 4:36 pm

[cc'd netdev]

On Thu, Feb 28, 2008 at 12:15:06PM -0600, Nebojsa Miljanovic wrote:

I've been encountering the need for SO_REUSEPORT as implemented on some BSD
for instance. It allows any process to explicitly permit another one to bind
to the same IP:port provided that it also sets its socket with SO_REUSEPORT.
This is a real requirement when you need to restart a service without any
service disruption.

In the end, I've written a trivial patch for 2.4 (but most likely 2.6 would
use nearly the same one). I noticed that the conflict detection logic already
distinguished between 3 cases: sk->reuse==0, sk->reuse==1, sk->reuse >1.
sk->reuse was set to 1 with SO_REUSEADDR. I simply had to make SO_REUSEPORT
do sk->reuse |= 2 to get everything working as expected.

I don't know yet if it is as easy to do in 2.6, but if there is a possible
acceptance of including this useful feature into mainline, I can try to
work a patch (possibly cleaner than my existing one for 2.4).

Regards,
Willy

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
SO_REUSEADDR not allowing server and client to use same port, Nebojsa Miljanovic, (Thu Feb 28, 2:15 pm)
Re: SO_REUSEADDR not allowing server and client to use same ..., Willy Tarreau, (Thu Feb 28, 4:36 pm)
speck-geostationary