lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4E1F0345.8020108@genband.com>
Date:	Thu, 14 Jul 2011 08:55:01 -0600
From:	Chris Friesen <chris.friesen@...band.com>
To:	Rick Jones <rick.jones2@...com>
CC:	Eric Dumazet <eric.dumazet@...il.com>, netdev@...r.kernel.org
Subject: Re: any way to let host act as TCP server OR client on same IP/port?

On 07/13/2011 01:16 PM, Chris Friesen wrote:
> On 07/13/2011 12:05 PM, Rick Jones wrote:
>> On 07/13/2011 10:52 AM, Eric Dumazet wrote:
>>> Le mercredi 13 juillet 2011 à 10:30 -0600, Chris Friesen a écrit :
>>>> I've been asked an interesting question about TCP. We have some people
>>>> that want to set up a TCP socket that can listen for connections on a
>>>> given IP/port, but also initiate connections from that same IP/port.
>>>> (Only one at a time, of course.)
>>>>
>>>> The TCP state machine seems to allow this (moving from LISTEN to
>>>> SYN_SENT) but it's not a normal transition.
>>>>
>>>> Is there any way to do this using the socket API?
>>>>
>>>> I thought up a hack whereby we could use NFQUEUE to detect an incoming
>>>> SYN and delay it while we call listen() on the socket. Is there any
>>>> better way to do this?
>>>
>>> Could you try SO_REUSEADDR, on both listener and connect attempt ?
>>
>> I was thinking the same thing, but it appears to not work under:


> In our case we don't need to actually be connected, just be listening
> and ready to either accept() a connection or connect() to someone else.

It turns out that the application people really do want the server side 
to be able to listen() at the same time as calling connect() from the 
same address/port, so Rick's testcase was accurate.

It would be interesting if linux were to allow this behaviour.  It 
doesn't seem to violate any specs, since we could still return an error 
if we try to connect() to an address that is already connected to us.

Chris


-- 
Chris Friesen
Software Developer
GENBAND
chris.friesen@...band.com
www.genband.com
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ