Listeners: socket options, several services on one address, connecting back

Only the -ol options which act when a socket is bound (SO_REUSEADDR,
SO_REUSEPORT, SO_EXCLUSIVEADDRUSE, SO_PORT_SCALABILITY,
SO_REUSE_UNICASTPORT, IP_TRANSPARENT, TCP_FASTOPEN) must be the same
for a socket to be taken over. The others are set on the socket taken
over, those no longer given turned off; TCP_MAXSEG, whose default is
not 0, still needs a new socket when it is dropped.

Several services may still share an address, in one configuration or
across reloads: each new one takes over a listener of its own, one of
an old service of its type first, or opens another.

A service connecting back (-r) has no socket to share, but now a
listener without one for the place it connects to: on a reload the new
service connecting to the same place takes it over, and the old
service's clients are re-authenticated as its clients, as a listening
service's are.

Nothing moves from srvparam to the listener: its socket is what accept
and UDP sessions use, and the rest is the service's configuration,
which the listener only copies to compare.

Tests: a live option changed keeps the socket, a bind-time one makes
another, two services on one address are both taken over, and a
download through a connect-back service goes on or is cut as its user
is kept or removed. 3proxy(8) describes the takeover and
re-authentication.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-15 11:09:57 +03:00
1 parent dfee08ded4
commit d33e2d76c0
5 files changed
+203 -25

No files matched your search

+13 -4
View File
@@ -120,10 +120,19 @@ it has an error, the configuration in force stays as it is, its services
running. Otherwise the new services start and the old ones stop accepting
within a second; connections already open finish under the old
configuration. A new service listening on the same address and port, in
the same network namespace and on the same device, with the same -ol
options, takes over the old service's TCP listening socket, so no
connection is refused or lost meanwhile; any other listening socket is
closed by the old service and opened by the new one. Settings left out of
the same network namespace and on the same device, takes over the old
service's TCP or UDP socket, so no connection is refused or lost
meanwhile, and UDP sessions go on through it; a service of the same type
is preferred where several share an address, as two services of one
configuration may. Of the -ol options only those acting when the socket is
bound must be the same (SO_REUSEADDR, SO_REUSEPORT, SO_EXCLUSIVEADDRUSE,
IP_TRANSPARENT, TCP_FASTOPEN); the others are set on the socket taken over,
those no longer given turned off. Otherwise the old service closes its
socket and the new one opens another. Connections of the old services are
re-authenticated as clients of the new service on their address, or on the
place a service connecting back (-r) connects to, unless noforce is set;
they are closed if their service was removed or is of another type, or if
the new one has no free slot of its maxconn. Settings left out of
the new file go back to their defaults.
.PP
Under Windows, if