History log of /haiku/src/add-ons/kernel/network/protocols/tcp/EndpointManager.h
Revision Date Author Comments
# fe8f7e31 28-Feb-2024 Augustin Cavalier <waddlesplash@gmail.com>

TCP: Let EndpointManager set Local and Peer addresses.

The Local address will apparently be set by the module->bind() call
in EndpointManager::_Bind(), while the Peer address will be set by
EndpointManager::SetConnection().

This means that if BindChild() fails for some reason, we will now not
be left in a state where the LocalAddress is set but we are unbound.
That could be the cause of #17058, as that panic occurs when
TCPEndpoint::IsBound() returns true, but we have not been added to
the bound hash.
Change-Id: I3121d0d99289d8cf83c7ed3c3e2d413feb6dad70
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7490
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 5147963d 26-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

headers/private/kernel/util/OpenHashTable.h, Hugo's version, is a bit nicer than
Tracker's OpenHashTable.h which it should eventually replace. We've renamed the
class to BOpenHashTable and changed the interface slightly so that HashTableLink
became superfluous.
Adapted all the code that used it. Since the OpenHashTables no longer clash,
this should fix the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f964cf07 15-Feb-2009 Axel Dörfler <axeld@pinc-software.de>

* No longer leaks the EndpointManagers at unload.
* Now uses an array instead of a doubly linked list to find the endpoint
manager for a domain.
* No longer locks the endpoint managers during TCP processing, which actually
made all TCP input serialized.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29210 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 276aa463 24-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced the useless InitCheck() method in {Open,Multi}HashTable (it
always returned B_OK) by a Init() method, which sets the initial size
and returns an error, if that fails.
* Adjusted code using the classes accordingly. Replaced a few
InitCheck() methods in the network code by Init().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26127 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 30a396ab 19-May-2008 Axel Dörfler <axeld@pinc-software.de>

* Made the endpoint manager wait on bind() if the existing connection is
local, and is about to close.
* This fixes several race conditions with the neon test suite that relied
on TCP sockets being gone after close, and their port being available again
(note, that is not what the TCP spec says, anyway, but it makes sense to
do so, since we already removed the time wait state for local connections).
* The endpoint manager is now using a mutex instead of a semaphore.
* TCPEndpoint::_Close() now notifies the senders/receivers instead of
_HandleReset().
* Besides ssl_closure(), all tests of the neon test suite seem to pass now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25564 a95241bf-73f2-0310-859d-f6bbb57e9c96


# db4b6bc4 28-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Merged _Receive() and _SegmentReceived().
* Cleanup, shuffled methods around, renamed methods, etc. - no functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 42759f56 27-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* _BindToEphemeral() now remembers the last port it used, and tries a higher
one next. This should work around the problem Ingo observed with the OpenSSH
tests (not tested, though).
* The only TCP compliant fix for this problem would be to not enter time wait
for local connections at all (which I will do soon).
* Another work around other implementations use is to accept incoming
connections for time wait endpoints (the connection will then be replaced).
I'm not yet sure if I want that behaviour, though.
* Added tracing for unbinding endpoints (with stack trace) to investigate
another bug (sometimes closed connections aren't actually closed).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25218 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 84052230 31-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

axeld+bonefish: Got rid of the ParentType in the HashTableDefinition; it doesn't really
belong there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21766 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 15945a11 29-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added 'tcp_endpoints' and 'tcp_endpoint' debugger commands.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20909 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9cd3b980 27-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed a long standing binding issue with spawned sockets and TCP. also fixed bind() address checking rules.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20866 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 342444bc 27-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

replaced TCP's Endpoint Manager manual handling of endpoint lists with MultiHashTable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20865 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 77e70865 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

moved the storage requirements (i.e. ParentType *) to OpenHashTable's Definition which we now instantiate per OpenHashTable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20824 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2586c25e 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

use Chaining in OpenHashTable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20822 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 585195c2 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

introduced SocketAddress wrappers and use them in TCP.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20818 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53f23f85 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

partially rewrote TCP's endpoint manager. Fixes #1173


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20814 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03d7f17e 15-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

made TCP handle multiple domains.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20718 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7664bcb5 09-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

A couple more TCP fixes.

- ipv4_bind() was broken when binding to addresses not INADDR_ANY, as it wasn't copying the address to the socket, fixed.
- fixed a small issue in TCP's BindToEphemeral where the correct address might not have been bound to the socket.
- some assorted TCP wait lists fixes.
- fixed TCP's Connect() over the loopback interface, we might already be ESTABLISHED after _SendQueue() returns.
- fixed the amount of time we wait in TCP's Accept().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20629 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 442c0979 04-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Renamed class TCPConnection to TCPEndpoint.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19418 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9cbe6ce2 04-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Rewrote how bind() works:
* there are now two hash tables: one for connections, and one for ports
* the first one is used to find the endpoint for incoming connections
* the latter is used to check if the address to bind() to is still available
(incl. support for SO_REUSEADDR, and SO_REUSEPORT). Specialising an existing
socket is not allowed, though; wildcard sockets need to be started last.
* the TCPConnection class now has a pointer to the next endpoint with the
same port number - this list is scanned for the existing bound sockets
on that port.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5147963dcd57fefa4f63c484eb88e9eaf4002976 26-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

headers/private/kernel/util/OpenHashTable.h, Hugo's version, is a bit nicer than
Tracker's OpenHashTable.h which it should eventually replace. We've renamed the
class to BOpenHashTable and changed the interface slightly so that HashTableLink
became superfluous.
Adapted all the code that used it. Since the OpenHashTables no longer clash,
this should fix the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f964cf077283ad2f5b381de0c0374dac760bd615 15-Feb-2009 Axel Dörfler <axeld@pinc-software.de>

* No longer leaks the EndpointManagers at unload.
* Now uses an array instead of a doubly linked list to find the endpoint
manager for a domain.
* No longer locks the endpoint managers during TCP processing, which actually
made all TCP input serialized.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29210 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 276aa463efb0cc5b6562c46b540c01df679f77ba 24-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced the useless InitCheck() method in {Open,Multi}HashTable (it
always returned B_OK) by a Init() method, which sets the initial size
and returns an error, if that fails.
* Adjusted code using the classes accordingly. Replaced a few
InitCheck() methods in the network code by Init().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26127 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 30a396ab4211fe07b7d90e6c48a3eadd301a78db 19-May-2008 Axel Dörfler <axeld@pinc-software.de>

* Made the endpoint manager wait on bind() if the existing connection is
local, and is about to close.
* This fixes several race conditions with the neon test suite that relied
on TCP sockets being gone after close, and their port being available again
(note, that is not what the TCP spec says, anyway, but it makes sense to
do so, since we already removed the time wait state for local connections).
* The endpoint manager is now using a mutex instead of a semaphore.
* TCPEndpoint::_Close() now notifies the senders/receivers instead of
_HandleReset().
* Besides ssl_closure(), all tests of the neon test suite seem to pass now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25564 a95241bf-73f2-0310-859d-f6bbb57e9c96


# db4b6bc46caaeb073a5e176a89ea695c0b52b70e 28-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Merged _Receive() and _SegmentReceived().
* Cleanup, shuffled methods around, renamed methods, etc. - no functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 42759f5626995ede0699d0b3eb9caef2ef3d17d8 27-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* _BindToEphemeral() now remembers the last port it used, and tries a higher
one next. This should work around the problem Ingo observed with the OpenSSH
tests (not tested, though).
* The only TCP compliant fix for this problem would be to not enter time wait
for local connections at all (which I will do soon).
* Another work around other implementations use is to accept incoming
connections for time wait endpoints (the connection will then be replaced).
I'm not yet sure if I want that behaviour, though.
* Added tracing for unbinding endpoints (with stack trace) to investigate
another bug (sometimes closed connections aren't actually closed).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25218 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 84052230379abf8e556e20e499d9a6040157f4a6 31-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

axeld+bonefish: Got rid of the ParentType in the HashTableDefinition; it doesn't really
belong there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21766 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 15945a11c67002b10f04a6207eea5637e6c17b45 29-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added 'tcp_endpoints' and 'tcp_endpoint' debugger commands.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20909 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9cd3b980fd431d2fc4cabfdae2b572b866686ee9 27-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed a long standing binding issue with spawned sockets and TCP. also fixed bind() address checking rules.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20866 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 342444bc95a45142c5e6fa824c96ca1c1343c84f 27-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

replaced TCP's Endpoint Manager manual handling of endpoint lists with MultiHashTable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20865 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 77e70865e17399a31813cca47bcaca80f271b341 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

moved the storage requirements (i.e. ParentType *) to OpenHashTable's Definition which we now instantiate per OpenHashTable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20824 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2586c25e318e1f71ff45889b9b0d047ce03043d1 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

use Chaining in OpenHashTable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20822 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 585195c28d3d06ee7726b04a420145dda0bd875a 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

introduced SocketAddress wrappers and use them in TCP.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20818 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53f23f85a2725c8fc31c7a874256084c7c623d86 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

partially rewrote TCP's endpoint manager. Fixes #1173


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20814 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03d7f17e07da19253587845073315010febc031a 15-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

made TCP handle multiple domains.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20718 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7664bcb5c42ce2e8b1324de100aeabba4cfac81f 09-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

A couple more TCP fixes.

- ipv4_bind() was broken when binding to addresses not INADDR_ANY, as it wasn't copying the address to the socket, fixed.
- fixed a small issue in TCP's BindToEphemeral where the correct address might not have been bound to the socket.
- some assorted TCP wait lists fixes.
- fixed TCP's Connect() over the loopback interface, we might already be ESTABLISHED after _SendQueue() returns.
- fixed the amount of time we wait in TCP's Accept().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20629 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 442c0979467981e68c45820d6e5d931a13c2ad82 04-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Renamed class TCPConnection to TCPEndpoint.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19418 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9cbe6ce20025d6de096cbd167bb1f83669d1032a 04-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Rewrote how bind() works:
* there are now two hash tables: one for connections, and one for ports
* the first one is used to find the endpoint for incoming connections
* the latter is used to check if the address to bind() to is still available
(incl. support for SO_REUSEADDR, and SO_REUSEPORT). Specialising an existing
socket is not allowed, though; wildcard sockets need to be started last.
* the TCPConnection class now has a pointer to the next endpoint with the
same port number - this list is scanned for the existing bound sockets
on that port.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19416 a95241bf-73f2-0310-859d-f6bbb57e9c96