ephemeral ports and port re-use for socket_wrapper emulated TCP bind()
Douglas Bagnall
douglas.bagnall at catalyst.net.nz
Thu Aug 20 04:32:38 UTC 2026
I think I really do want to be able to test ephemeral[1] port ranges,
and I came across this thread.
If you/your mail client doesn't remember, it starts here:
https://lists.samba.org/archive/samba-technical/2016-October/116808.html
On 20/10/2016 19:54, Andreas Schneider wrote:
> On Thursday, 20 October 2016 12:08:55 CEST Andrew Bartlett wrote:
>> I've found an interesting issue while working our Samba's RPC server.
>>
>> I wanted to change Samba from listening only on 1024 to listening on
>> many ports for ncacn_ip_tcp so that I could multi-thread our netlogon
>> server.
>>
>> The most practical way to do that is to have it listen on a distinct
>> socket.
>>
>> However, because swrap_bind has the (new, at that point)
>> check_addr_port_in_use() function removed with an #if 0 by commit
>> 064592d9cb6349e625b881cfcfab37b19d141ebe, no check is made to see if a
>> socket is available.
>
> This is code is commented out because
>
> a) it is incomplete
> b) it doesn't have tests
>
> The way to fix this is to start working on a) and b). Well, implement b) first
> ... :)
It is still commented out...
> However this is limited to one process, the process socket_wrapper is
> preloaded. It will be possible to check that as soon as socket_wrapper has a
> database. This is the work being done do make it thread safe and support fd-
> passing.
>
> https://git.samba.org/?p=obnox/cwrap/socket_wrapper.git;a=shortlog;h=refs/heads/fd-passing-threadsafe
This branch has a number of new commits, all the way up to 2016-11-18,
while this one has had another year of work, with promising commit messages:
https://git.samba.org/?p=obnox/cwrap/socket_wrapper.git;a=shortlog;h=refs/heads/threadsafe-rework-wip
Is there a current state-of-the-art branch? I also see this one:
https://git.samba.org/?p=anoopcs/socket_wrapper.git;a=shortlog;h=refs/heads/fd-passing-final
[1] when we say "ephemeral", we mean actually quite long-lasting and
sort of predictable, but multiple processes want to compete for the same
ports.
cheers,
Douglas
More information about the samba-technical
mailing list