]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
3 years agoDEV: flags: No longer dump SI flags
Christopher Faulet [Mon, 4 Apr 2022 09:28:27 +0000 (11:28 +0200)] 
DEV: flags: No longer dump SI flags

stream-interface API is no longer used. And there is no more SI flags. Thus,
the stream-interface's flags are no longer dumped by "flags" tool.

3 years agoMINOR: conn-stream: Remove the stream-interface from the conn-stream
Christopher Faulet [Mon, 4 Apr 2022 09:25:59 +0000 (11:25 +0200)] 
MINOR: conn-stream: Remove the stream-interface from the conn-stream

The stream-interface API is no longer used. Thus, it is removed from the
conn-stream. From now, stream-interfaces are now longer used !

3 years agoMEDIUM: stream: Don't use the stream-int anymore in process_stream()
Christopher Faulet [Mon, 4 Apr 2022 09:08:42 +0000 (11:08 +0200)] 
MEDIUM: stream: Don't use the stream-int anymore in process_stream()

process_stream() and all associated functions now manipulate conn-streams.
stream-interfaces are no longer used. In addition, function to dump info
about a stream no longer print info about stream-interfaces.

3 years agoMINOR: http-ana: Use CS to perform L7 retries
Christopher Faulet [Mon, 4 Apr 2022 09:07:08 +0000 (11:07 +0200)] 
MINOR: http-ana: Use CS to perform L7 retries

do_l7_retry function now manipulated a conn-stream instead of a
stream-interface.

3 years agoMINOR: stream: Use conn-stream to report server error
Christopher Faulet [Mon, 4 Apr 2022 09:06:31 +0000 (11:06 +0200)] 
MINOR: stream: Use conn-stream to report server error

the stream's srv_error callback function now manipulates a conn-stream
instead of a stream-interface.

3 years agoREORG: stream-int/conn-stream: Move remaining functions to conn-stream
Christopher Faulet [Mon, 4 Apr 2022 07:00:59 +0000 (09:00 +0200)] 
REORG: stream-int/conn-stream: Move remaining functions to conn-stream

functions to get or set blocking flags on a conn-stream are moved to
conn_stream.h.

3 years agoMEDIUM: stream-int/conn-stream: Move I/O functions to conn-stream
Christopher Faulet [Mon, 4 Apr 2022 06:58:34 +0000 (08:58 +0200)] 
MEDIUM: stream-int/conn-stream: Move I/O functions to conn-stream

cs_conn_io_cb(), cs_conn_sync_recv() and cs_conn_sync_send() are moved in
conn_stream.c. Associated functions are moved too (cs_notify, cs_conn_read0,
cs_conn_recv, cs_conn_send and cs_conn_process).

3 years agoMEDIUM: stream-int/conn-stream: Move blocking flags from SI to CS
Christopher Faulet [Mon, 4 Apr 2022 05:51:21 +0000 (07:51 +0200)] 
MEDIUM: stream-int/conn-stream: Move blocking flags from SI to CS

Remaining flags and associated functions are move in the conn-stream
scope. These flags are added on the endpoint and not the conn-stream
itself. This way it will be possible to get them from the mux or the
applet. The functions to get or set these flags are renamed accordingly with
the "cs_" prefix and updated to manipualte a conn-stream instead of a
stream-interface.

3 years agoCLEANUP: stream-int: Remove unused SI functions
Christopher Faulet [Fri, 1 Apr 2022 15:21:49 +0000 (17:21 +0200)] 
CLEANUP: stream-int:  Remove unused SI functions

Some stream-interface's functions are now unused and can safely be removed.

3 years agoMINOR: stream-int/conn-stream: Move si_alloc_ibuf() in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 15:19:36 +0000 (17:19 +0200)] 
MINOR: stream-int/conn-stream: Move si_alloc_ibuf() in the conn-stream scope

si_alloc_ibuf() is renamed as c_alloc_ibuf() and update to manipulate a
conn-stream instead of a stream-interface.

3 years agoMINOR: stream-int/conn-stream Move si_is_conn_error() in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 15:15:10 +0000 (17:15 +0200)] 
MINOR: stream-int/conn-stream Move si_is_conn_error() in the conn-stream scope

si_is_conn_error() is renamed as cs_is_conn_erro() and updated to manipulate
a conn-stream instead of a stream-interface.

3 years agoMINOR: conn-stream: Move si_conn_cb in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 15:06:32 +0000 (17:06 +0200)] 
MINOR: conn-stream: Move si_conn_cb in the conn-stream scope

si_conn_cb variable is renamed cs_data_conn_cb. In addtion, its associated
functions are also renamed. si_cs_recv(), si_cs_send() and si_cs_process() are
renamed cs_conn_recv(), cs_conn_send and cs_conn_process(). These functions are
updated to manipulate conn-streams instead of stream-interfaces.

3 years agoMINOR: stream-int/conn-stream: Move si_sync_recv/send() in conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 15:03:14 +0000 (17:03 +0200)] 
MINOR: stream-int/conn-stream: Move si_sync_recv/send() in conn-stream scope

si_sync_recv() and si_sync_send() are renamesd cs_conn_recv() and
cs_conn_send() and updated to manipulate conn-streams instead of
stream-interfaces.

3 years agoMINOR: stream-int/conn-stream: Move si_cs_io_cb() in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 14:58:52 +0000 (16:58 +0200)] 
MINOR: stream-int/conn-stream: Move si_cs_io_cb() in the conn-stream scope

si_cs_io_cb() is renamed cs_conn_io_cb(). In addition, the context of the
tasklet used to wake-up the conn-stream is now a conn-stream.

3 years agoMINOR: stream-int/conn-stream: Move stream_int_notify() in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 14:48:36 +0000 (16:48 +0200)] 
MINOR: stream-int/conn-stream: Move stream_int_notify() in the conn-stream scope

stream_int_notify() is renamed cs_notify() and is updated to manipulate a
conn-stream instead of a stream-interface.

3 years agoMINOR: stream-int/conn-stream: Move stream_int_read0() in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 14:38:32 +0000 (16:38 +0200)] 
MINOR: stream-int/conn-stream: Move stream_int_read0() in the conn-stream scope

stream_int_read0() is renamed cs_conn_read0() and is updated to manipulate a
conn-stream instead of a stream-interface.

3 years agoMEDIUM: conn-stream/applet: Add a data callback for applets
Christopher Faulet [Fri, 1 Apr 2022 14:34:53 +0000 (16:34 +0200)] 
MEDIUM: conn-stream/applet: Add a data callback for applets

data callbacks were only used for streams attached to a connection and
for health-checks. However there is a callback used by task_run_applet. So,
si_applet_wake_cb() is first renamed to cs_applet_process() and it is
defined as the data callback for streams attached to an applet. This way,
this part now manipulates a conn-stream instead of a stream-interface. In
addition, applets are no longer handled as an exception for this part.

3 years agoMINOR: stream-int/stream: Move si_update_both in stream scope
Christopher Faulet [Fri, 1 Apr 2022 12:48:06 +0000 (14:48 +0200)] 
MINOR: stream-int/stream: Move si_update_both in stream scope

si_update_both() is renamed stream_update_both_cs() and moved in stream.c.
The function is slightly changed to manipulate the stream instead the front
and back conn-streams.

3 years agoMINOR: stream-int-conn-stream: Move si_update_* in conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 12:23:38 +0000 (14:23 +0200)] 
MINOR: stream-int-conn-stream: Move si_update_* in conn-stream scope

si_update_rx(), si_update_tx() and si_update() are renamed cs_update_rx(),
cs_upate_tx() and cs_update() and updated to manipulate a conn-stream
instead of a stream-interface.

3 years agoREORG: conn-stream: Move cs_app_ops in conn_stream.c
Christopher Faulet [Fri, 1 Apr 2022 12:04:29 +0000 (14:04 +0200)] 
REORG: conn-stream: Move cs_app_ops in conn_stream.c

Callback functions to perform shutdown for reads and writes and to trigger
I/O calls are now moved in conn_stream.c.

3 years agoREORG: conn-stream: Move cs_shut* and cs_chk* in cs_utils
Christopher Faulet [Fri, 1 Apr 2022 11:58:09 +0000 (13:58 +0200)] 
REORG: conn-stream: Move cs_shut* and cs_chk* in cs_utils

cs_shutr(), cs_shutw(), cs_chk_rcv() and cs_chk_snd() are moved in
cs_utils.h

3 years agoREORG: stream-int: Move si_is_conn_error() in the header file
Christopher Faulet [Fri, 1 Apr 2022 11:56:30 +0000 (13:56 +0200)] 
REORG: stream-int: Move si_is_conn_error() in the header file

To ease next changes, this function is moved in the header file. It is a
transient commit.

3 years agoREORG: stream-int: Export si_cs_recv(), si_cs_send() and si_cs_process()
Christopher Faulet [Fri, 1 Apr 2022 11:48:39 +0000 (13:48 +0200)] 
REORG: stream-int: Export si_cs_recv(), si_cs_send() and si_cs_process()

It is a transient commit. It should ease next changes about the conn-stream
refactoring. At the end these functions will be moved in the conn-stream
scope.

3 years agoMINOR: stream-int/connection: Move conn_si_send_proxy() in the connection scope
Christopher Faulet [Fri, 1 Apr 2022 11:22:50 +0000 (13:22 +0200)] 
MINOR: stream-int/connection: Move conn_si_send_proxy() in the connection scope

conn_si_send_proxy() function is renamed conn_send_proxy() and moved in
connection.c

3 years agoMINOR: connection: unconst mux's get_fist_cs() callback function
Christopher Faulet [Fri, 1 Apr 2022 11:21:41 +0000 (13:21 +0200)] 
MINOR: connection: unconst mux's get_fist_cs() callback function

This change is mandatory for next commits.

3 years agoMINOR: applet: Use the CS to register and release applets instead of SI
Christopher Faulet [Fri, 1 Apr 2022 09:36:58 +0000 (11:36 +0200)] 
MINOR: applet: Use the CS to register and release applets instead of SI

si_register_applet() and si_applet_release() are renamed
cs_register_applet() and cs_applet_release() and now manipulate a
conn-stream instead of a stream-inteface.

3 years agoMEDIUM: stream-int/conn-stream: Move si_ops in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 06:58:29 +0000 (08:58 +0200)] 
MEDIUM: stream-int/conn-stream: Move si_ops in the conn-stream scope

The si_ops structure is renamed to cs_app_ops and the callback functions are
changed to manipulate a conn-stream instead of a stream-interface..

3 years agoMINOR: stream-int/conn-stream: Move si_shut* and si_chk* in conn-stream scope
Christopher Faulet [Thu, 31 Mar 2022 15:44:45 +0000 (17:44 +0200)] 
MINOR: stream-int/conn-stream: Move si_shut* and si_chk* in conn-stream scope

si_shutr(), si_shutw(), si_chk_rcv() and si_chk_snd() are moved in the
conn-stream scope and renamed, respectively, cs_shutr(), cs_shutw(),
cs_chk_rcv(), cs_chk_snd() and manipulate a conn-stream instead of a
stream-interface.

3 years agoMINOR: conn-stream: Rename CS functions dedicated to connections
Christopher Faulet [Thu, 31 Mar 2022 12:20:00 +0000 (14:20 +0200)] 
MINOR: conn-stream: Rename CS functions dedicated to connections

Some conn-stream functions are only used when there is a connection. Thus,
they was renamed with "cs_conn_" prefix. In addition, we expect to have a
connection, so a BUG_ON is added to be sure the functions are never called
in another context.

3 years agoMEDIUM: stream-int/conn-stream: Handle I/O subscriptions in the conn-stream
Christopher Faulet [Thu, 31 Mar 2022 09:09:28 +0000 (11:09 +0200)] 
MEDIUM: stream-int/conn-stream: Handle I/O subscriptions in the conn-stream

wait_event structure is moved in the conn-stream. The tasklet is only
created if the conn-stream is attached to a mux and released when the mux is
detached. This implies a subtle change. In stream_int_chk_rcv() function,
the wakeup of the tasklet was removed because there is no longer tasklet at
this stage (stream_int_chk_rcv() is a callback function of si_embedded_ops).

3 years agoMEDIUM: conn-stream: Be prepared to fail to attach a cs to a mux
Christopher Faulet [Thu, 31 Mar 2022 17:27:18 +0000 (19:27 +0200)] 
MEDIUM: conn-stream: Be prepared to fail to attach a cs to a mux

To be able to move wait_event from the stream-interface to the conn-stream,
we must be prepare to handle errors when a mux is attached to a conn-stream.
Indeed, the wait_event's tasklet will be allocated when both a mux and a
stream will be both attached to a stream. So, we must be prepared to handle
allocation errors.

3 years agoMINOR: conn-stream/connection: Move SHR/SHW modes in the connection scope
Christopher Faulet [Thu, 31 Mar 2022 09:05:05 +0000 (11:05 +0200)] 
MINOR: conn-stream/connection: Move SHR/SHW modes in the connection scope

These flags only concerns the connection part. In addition, it is required
for a next commit, to avoid circular deps. Thus CS_SHR_* and CS_SHW_* were
renamed with the "CO_" prefix.

3 years agoMINOR: stream-int/conn-stream: Move si_conn_ready() in the conn-stream scope
Christopher Faulet [Thu, 31 Mar 2022 07:58:41 +0000 (09:58 +0200)] 
MINOR: stream-int/conn-stream: Move si_conn_ready() in the conn-stream scope

si_conn_ready() is renamed cs_conn_ready() and handle a conn-stream insted
of a stream-interface. The function is now in cs_utils.h.

3 years agoMINOR: stream-int/backend: Move si_connect() in the backend scope
Christopher Faulet [Thu, 31 Mar 2022 07:53:38 +0000 (09:53 +0200)] 
MINOR: stream-int/backend: Move si_connect() in the backend scope

si_connect() is moved in backend.c and renamed as do_connect_server(). In
addition, the function now manipulate a stream instead of a
stream-interface.

3 years agoMINOR: stream-int/stream: Move si_retnclose() in the stream scope
Christopher Faulet [Thu, 31 Mar 2022 07:47:24 +0000 (09:47 +0200)] 
MINOR: stream-int/stream: Move si_retnclose() in the stream scope

si_retnclose() is used to send a reply to a client before closing. There is
no use on the server side, in spite of the function is generic. Thus, it is
renamed stream_retnclose() and moved into the stream scope. The function now
handle a stream and explicitly send a message to the client.

3 years agoMEDIUM: stream-int/conn-stream: Move stream-interface state in the conn-stream
Christopher Faulet [Thu, 31 Mar 2022 07:16:34 +0000 (09:16 +0200)] 
MEDIUM: stream-int/conn-stream: Move stream-interface state in the conn-stream

The stream-interface state (SI_ST_*) is now in the conn-stream. It is a
mechanical replacement for now. Nothing special. SI_ST_* and SI_SB_* were
renamed accordingly. Utils functions to manipulate these infos were moved
under the conn-stream scope.

But it could be good to keep in mind that this part should be
reworked. Indeed, at the CS level, we only need to know if it is ready to
receive or to send. The state of conn-stream from INI to EST is only used on
the server side. The client CS is immediately set to EST. Thus current
SI_ST_* states should probably be moved to the stream to reflect the server
connection state during the establishment stage.

3 years agoMEDIUM: stream-int: Move SI err_type in the stream
Christopher Faulet [Wed, 30 Mar 2022 17:39:30 +0000 (19:39 +0200)] 
MEDIUM: stream-int: Move SI err_type in the stream

Only the server side is concerned by the stream-interface error type. It is
useless to have an err_type field on the client side. So, it is now move to
the stream. SI_ET_* are renames STRM_ET_* and moved in stream-t.h header
file.

3 years agoMINOR: stream: Only save previous connection state for the server side
Christopher Faulet [Wed, 30 Mar 2022 15:13:02 +0000 (17:13 +0200)] 
MINOR: stream: Only save previous connection state for the server side

The previous connection state on the client side was only used for debugging
purpose to report client close. But this may be handled when the client
stream-interface is switched from SI_ST_DIS to SI_ST_CLO.

So, there only remains the previous connection state on the server side that
is used by the stream, in process_stream(), to be able to set the correct
termination flags. Thus, instead of keeping this info in the
stream-interface for only one side, the info is now stored in the stream
itself.

3 years agoCLEANUP: stream-int: Remove unused SI_FL_CLEAN_ABRT flag
Christopher Faulet [Wed, 30 Mar 2022 14:31:41 +0000 (16:31 +0200)] 
CLEANUP: stream-int: Remove unused SI_FL_CLEAN_ABRT flag

This flag is unused. So remove it to be able to remove the stream-interface.

3 years agoMINOR: stream-int: Remove SI_FL_SRC_ADDR to rely on stream flags instead
Christopher Faulet [Wed, 30 Mar 2022 14:26:39 +0000 (16:26 +0200)] 
MINOR: stream-int: Remove SI_FL_SRC_ADDR to rely on stream flags instead

Flag to get the source ip/port with getsockname is now handled at the stream
level. Thus SI_FL_SRC_ADDR stream-int flag is replaced by SF_SRC_ADDR stream
flag.

3 years agoMINOR: stream-int: Remove SI_FL_INDEP_STR to rely on CS flags instead
Christopher Faulet [Wed, 30 Mar 2022 13:43:23 +0000 (15:43 +0200)] 
MINOR: stream-int: Remove SI_FL_INDEP_STR to rely on CS flags instead

Flag to consider a stream as indepenent is now handled at the conn-stream
level. Thus SI_FL_INDEP_STR stream-int flag is replaced by CS_FL_INDEP_STR
conn-stream flags.

3 years agoMINOR: stream-int: Remove SI_FL_DONT_WAKE to rely on CS flags instead
Christopher Faulet [Wed, 30 Mar 2022 13:30:03 +0000 (15:30 +0200)] 
MINOR: stream-int: Remove SI_FL_DONT_WAKE to rely on CS flags instead

Flag to not wake the stream up on I/O is now handled at the conn-stream
level. Thus SI_FL_DONT_WAKE stream-int flag is replaced by CS_FL_DONT_WAKE
conn-stream flags.

3 years agoMINOR: stream-int: Remove SI_FL_NOLINGER/NOHALF to rely on CS flags instead
Christopher Faulet [Wed, 30 Mar 2022 13:10:18 +0000 (15:10 +0200)] 
MINOR: stream-int: Remove SI_FL_NOLINGER/NOHALF to rely on CS flags instead

Flags to disable lingering and half-close are now handled at the conn-stream
level. Thus SI_FL_NOLINGER and SI_FL_NOHALF stream-int flags are replaced by
CS_FL_NOLINGER and CS_FL_NOHALF conn-stream flags.

3 years agoMINOR: mux-h2/mux-fcgi: Fully rely on CS_EP_KILL_CONN
Christopher Faulet [Wed, 30 Mar 2022 12:48:10 +0000 (14:48 +0200)] 
MINOR: mux-h2/mux-fcgi: Fully rely on CS_EP_KILL_CONN

Instead of using a internal flag to kill the connection with the stream, we
now fully rely on CS_EP_KILL_CONN flag.

3 years agoMINOR: stream-int: Remove SI_FL_KILL_CON to rely on conn-stream endpoint only
Christopher Faulet [Wed, 30 Mar 2022 12:42:50 +0000 (14:42 +0200)] 
MINOR: stream-int: Remove SI_FL_KILL_CON to rely on conn-stream endpoint only

Instead of setting a stream-interface flag to then set the corresponding
conn-stream endpoint flag, we now only rely the conn-stream endoint. Thus
SI_FL_KILL_CON is replaced by CS_EP_KILL_CONN.

In addition si_must_kill_conn() is replaced by cs_must_kill_conn().

3 years agoMINOR: channel: Use conn-streams as channel producer and consumer
Christopher Faulet [Wed, 30 Mar 2022 12:37:49 +0000 (14:37 +0200)] 
MINOR: channel: Use conn-streams as channel producer and consumer

chn_prod() and chn_cons() now return a conn-stream instead of a
stream-interface.

3 years agoMEDIUM: conn-stream: Use endpoint error instead of conn-stream error
Christopher Faulet [Wed, 30 Mar 2022 08:47:32 +0000 (10:47 +0200)] 
MEDIUM: conn-stream: Use endpoint error instead of conn-stream error

Instead of relying on the conn-stream error, via CS_FL_ERR flags, we now
directly use the error at the endpoint level with the flag CS_EP_ERROR. It
should be safe to do so. But we must be careful because it is still possible
that an error is processed too early. Anyway, a conn-stream has always a
valid endpoint, maybe detached from any endpoint, but valid.

3 years agoMINOR: stream-int/conn-stream: Report error to the CS instead of the SI
Christopher Faulet [Wed, 30 Mar 2022 08:06:11 +0000 (10:06 +0200)] 
MINOR: stream-int/conn-stream: Report error to the CS instead of the SI

SI_FL_ERR is removed and replaced by CS_FL_ERROR. It is a transient patch
because the idea is to rely on the endpoint to handle errors at this
level. But if for any reason it is not possible, the stream-interface flags
will still be replaced.

3 years agoMEDIUM: stream-int/stream: Use connect expiration instead of SI expiration
Christopher Faulet [Tue, 29 Mar 2022 17:02:31 +0000 (19:02 +0200)] 
MEDIUM: stream-int/stream: Use connect expiration instead of SI expiration

The expiration date in the stream-interface was only used on the server side
to set the connect, queue or turn-around timeout. It was checked on the
frontend stream-interface, but never used concretely. So it was removed and
replaced by a connect expiration date in the stream itself. Thus, SI_FL_EXP
flag in stream-interfaces is replaced by a stream flag, SF_CONN_EXP.

3 years agoMINOR: stream-int/conn-stream: Move half-close timeout in the conn-stream
Christopher Faulet [Tue, 29 Mar 2022 16:03:35 +0000 (18:03 +0200)] 
MINOR: stream-int/conn-stream: Move half-close timeout in the conn-stream

The half-close timeout (hcto) is now part of the conn-stream. It is a step
closer to the stream-interface removal.

3 years agoMEDIUM: stream-int/conn-stream: Move src/dst addresses in the conn-stream
Christopher Faulet [Tue, 29 Mar 2022 15:53:09 +0000 (17:53 +0200)] 
MEDIUM: stream-int/conn-stream: Move src/dst addresses in the conn-stream

The source and destination addresses at the applicative layer are moved from
the stream-interface to the conn-stream. This simplifies a bit the code and
it is a logicial step to remove the stream-interface.

3 years agoMINOR: stream: Simplify retries counter calculation
Christopher Faulet [Tue, 29 Mar 2022 14:08:44 +0000 (16:08 +0200)] 
MINOR: stream: Simplify retries counter calculation

The conn_retries counter was set to the max value and decremented at each
connection retry. Thus the counter reflected the number of retries left and
not the real number of retries. All calculations of redispatch or reporting
of number of retries experienced were made using subtracts from the
configured retries, which was complicated and didn't bring any benefit.

Now, this counter is set to 0 and incremented at each retry. We know we've
reached the maximum allowed connection retries by comparing it to the
configured value. In all other cases, we directly use the counter.

This patch should address the feature request #1608.

3 years agoMINOR: stream-int/stream: Move conn_retries counter in the stream
Christopher Faulet [Tue, 29 Mar 2022 13:42:09 +0000 (15:42 +0200)] 
MINOR: stream-int/stream: Move conn_retries counter in the stream

The conn_retries counter may be moved into the stream structure. It only
concerns the connection establishment. The frontend stream-interface does not
use it. So it is a logical change.

3 years agoCLEANUP: http-ana: Remove http_alloc_txn() function
Christopher Faulet [Tue, 29 Mar 2022 13:27:32 +0000 (15:27 +0200)] 
CLEANUP: http-ana: Remove http_alloc_txn() function

Since the 2.4, this function is no longer used. Thus we can remove it.

3 years agoMINOR: stream-int/txn: Move buffer for L7 retries in the HTTP transaction
Christopher Faulet [Tue, 29 Mar 2022 13:23:40 +0000 (15:23 +0200)] 
MINOR: stream-int/txn: Move buffer for L7 retries in the HTTP transaction

The L7 retries only concerns the stream when a server connection is
established. Thus instead of storing the L7 buffer into the
stream-interface, it may be moved to the stream. And because it is only
available for HTTP streams, it may be moved in the HTTP transaction.

Associated flags are also moved into the HTTP transaction.

3 years agoMEDIUM: tree-wide: Use CS util functions instead of SI ones
Christopher Faulet [Fri, 25 Mar 2022 15:43:49 +0000 (16:43 +0100)] 
MEDIUM: tree-wide: Use CS util functions instead of SI ones

At many places, we now use the new CS functions to get a stream or a channel
from a conn-stream instead of using the stream-interface API. It is the
first step to reduce the scope of the stream-interfaces. The main change
here is about the applet I/O callback functions. Before the refactoring, the
stream-interface was the appctx owner. Thus, it was heavily used. Now, as
far as possible,the conn-stream is used. Of course, it remains many calls to
the stream-interface API.

3 years agoMINOR: conn-stream: Add header file with util functions related to conn-streams
Christopher Faulet [Fri, 25 Mar 2022 14:21:46 +0000 (15:21 +0100)] 
MINOR: conn-stream: Add header file with util functions related to conn-streams

cs_utils.h header file will contain all util functions related to the
conn_streams. For now, few functions were added, all are equivalent to SI
functions. Idea is to progressively replace SI functions by CS ones.

3 years agoMINOR: conn-stream: Add ISBACK conn-stream flag
Christopher Faulet [Fri, 25 Mar 2022 14:32:38 +0000 (15:32 +0100)] 
MINOR: conn-stream: Add ISBACK conn-stream flag

CS_FL_ISBACK is a new flag, set on backend conn-streams. We must just be
careful to preserve this flag when the endpoint is detached from the
conn-stream.

3 years agoMINOR: mux-pt: Rely on the endpoint instead of the conn-stream when possible
Christopher Faulet [Thu, 24 Mar 2022 09:51:08 +0000 (10:51 +0100)] 
MINOR: mux-pt: Rely on the endpoint instead of the conn-stream when possible

Instead of testing if a conn-stream exists or not, we rely on CS_EP_ORPHAN
endpoint flag. In addition, if possible, we access the endpoint from the
mux_pt context. Finally, the endpoint flags are now reported in trace
messages.

3 years agoMEDIUM: conn-stream: Move remaning flags from CS to endpoint
Christopher Faulet [Thu, 24 Mar 2022 09:27:02 +0000 (10:27 +0100)] 
MEDIUM: conn-stream: Move remaning flags from CS to endpoint

All old flags CS_FL_* are now moved in the endpoint scope and renamed
CS_EP_* accordingly. It is a systematic replacement. There is no true change
except for the health-check and the endpoint reset. Here it is a bit special
because the same conn-stream is reused. Thus, we must handle endpoint
allocation errors. To do so, cs_reset_endp() has been adapted.

Thanks to this last change, it will now be possible to simplify the
multiplexer and probably the applets too. A review must also be performed to
remove some flags in the channel or the stream-interface. The HTX will
probably be simplified too. Finally, there is now some place in the
conn-stream to move info from the stream-interface.

3 years agoMAJOR: conn-stream: Share endpoint struct between the CS and the mux/applet
Christopher Faulet [Wed, 23 Mar 2022 14:15:29 +0000 (15:15 +0100)] 
MAJOR: conn-stream: Share endpoint struct between the CS and the mux/applet

The conn-stream endpoint is now shared between the conn-stream and the
applet or the multiplexer. If the mux or the applet is created first, it is
responsible to also create the endpoint and share it with the conn-stream.
If the conn-stream is created first, it is the opposite.

When the endpoint is only owned by an applet or a mux, it is called an
orphan endpoint (there is no conn-stream). When it is only owned by a
conn-stream, it is called a detached endpoint (there is no mux/applet).

The last entity that owns an endpoint is responsible to release it. When a
mux or an applet is detached from a conn-stream, the conn-stream
relinquishes the endpoint to recreate a new one. This way, the endpoint
state is never lost for the mux or the applet.

3 years agoREORG: applet: Uninline appctx_new function
Christopher Faulet [Wed, 23 Mar 2022 10:46:56 +0000 (11:46 +0100)] 
REORG: applet: Uninline appctx_new function

appctx_new() is moved in the C file and appctx_init() is now private.

3 years agoMEDIUM: conn-stream: Pre-allocate endpoint to create CS from muxes and applets
Christopher Faulet [Wed, 23 Mar 2022 10:01:09 +0000 (11:01 +0100)] 
MEDIUM: conn-stream: Pre-allocate endpoint to create CS from muxes and applets

It is a transient commit to prepare next changes. Now, when a conn-stream is
created from an applet or a multiplexer, an endpoint is always provided. In
addition, the API to create a conn-stream was specialized to have one
function per type.

The next step will be to share the endpoint structure.

3 years agoMEDIUM: conn-stream: Be able to pass endpoint to create a conn-stream
Christopher Faulet [Tue, 22 Mar 2022 17:37:19 +0000 (18:37 +0100)] 
MEDIUM: conn-stream: Be able to pass endpoint to create a conn-stream

It is a transient commit to prepare next changes. It is possible to pass a
pre-allocated endpoint to create a new conn-stream. If it is NULL, a new
endpoint is created, otherwise the existing one is used. There no more
change at the conn-stream level.

In the applets, all conn-stream are created with no pre-allocated
endpoint. But for multiplexers, an endpoint is systematically created before
creating the conn-stream.

3 years agoMINOR: conn-stream: Move some CS flags to the endpoint
Christopher Faulet [Tue, 22 Mar 2022 17:13:29 +0000 (18:13 +0100)] 
MINOR: conn-stream: Move some CS flags to the endpoint

Some CS flags, only related to the endpoint, are moved into the endpoint
struct. More will probably moved later. Those ones are not critical. So it
is pretty safe to move them now and this will ease next changes.

3 years agoMEDIUM: conn-stream: Add an endpoint structure in the conn-stream
Christopher Faulet [Tue, 22 Mar 2022 15:06:25 +0000 (16:06 +0100)] 
MEDIUM: conn-stream: Add an endpoint structure in the conn-stream

Group the endpoint target of a conn-stream, its context and the associated
flags in a dedicated structure in the conn-stream. It is not inlined in the
conn-stream structure. There is a dedicated pool.

For now, there is no complexity. It is just an indirection to get the
endpoint or its context. But the purpose of this structure is to be able to
share a refcounted context between the mux and the conn-stream. This way, it
will be possible to preserve it when the mux is detached from the
conn-stream.

3 years agoREORG: Initialize the conn-stream by hand in cs_init()
Christopher Faulet [Tue, 22 Mar 2022 14:28:36 +0000 (15:28 +0100)] 
REORG: Initialize the conn-stream by hand in cs_init()

The function cs_init() is only called by cs_new(). The conn-stream
initialization will be reviewed. It is easier to do it in cs_new() instead
of using a dedicated function. cs_new() is pretty simple, there is no reason
to split the code in this case.

3 years agoMAJOR: conn-stream: Invert conn-stream endpoint and its context
Christopher Faulet [Wed, 19 Jan 2022 13:56:50 +0000 (14:56 +0100)] 
MAJOR: conn-stream: Invert conn-stream endpoint and its context

This change is only significant for the multiplexer part. For the applets,
the context and the endpoint are the same. Thus, there is no much change. For
the multiplexer part, the connection was used to set the conn-stream
endpoint and the mux's stream was the context. But it is a bit strange
because once a mux is installed, it takes over the connection. In a
wonderful world, the connection should be totally hidden behind the mux. The
stream-interface and, in a lesser extent, the stream, still access the
connection because that was inherited from the pre-multiplexer era.

Now, the conn-stream endpoint is the mux's stream (an opaque entity for the
conn-stream) and the connection is the context. Dedicated functions have
been added to attached an applet or a mux to a conn-stream.

3 years agoMEDIUM: applet: Set the appctx owner during allocation
Christopher Faulet [Wed, 19 Jan 2022 13:50:11 +0000 (14:50 +0100)] 
MEDIUM: applet: Set the appctx owner during allocation

The appctx owner is now always a conn-stream. Thus, it can be set during the
appctx allocation. But, to do so, the conn-stream must be created first. It
is not a problem on the server side because the conn-stream is created with
the stream. On the client side, we must take care to create the conn-stream
first.

This change should ease other changes about the applets bootstrapping.

3 years agoMINOR: conn-stream: Add flags to set the type of the endpoint
Christopher Faulet [Tue, 18 Jan 2022 09:43:02 +0000 (10:43 +0100)] 
MINOR: conn-stream: Add flags to set the type of the endpoint

This patch is mandatory to invert the endpoint and the context in the
conn-stream. There is no common type (at least for now) for the entity
representing a mux (h1s, h2s...), thus we must set its type when the
endpoint is attached to a conn-stream. There is 2 types for the conn-stream
endpoints: the mux (CS_FL_ENDP_MUX) and the applet (CS_FL_ENDP_APP).

3 years agoMINOR: applet: Make .init callback more generic
Christopher Faulet [Thu, 13 Jan 2022 15:01:35 +0000 (16:01 +0100)] 
MINOR: applet: Make .init callback more generic

For now there is no much change. Only the appctx is passed as argument when
the .init callback function is called. And it is not possible to yield at
this stage. It is not a problem because the feature is not used. Only the
lua defines this callback function for the lua TCP/HTTP services. The idea
is to be able to use it for all applets to initialize the appctx context.

3 years agoBUG/MINOR: mux-h1: Don't release unallocated CS on error path
Christopher Faulet [Tue, 22 Mar 2022 17:45:55 +0000 (18:45 +0100)] 
BUG/MINOR: mux-h1: Don't release unallocated CS on error path

cs_free() must not be called when we fail to allocate the conn-stream in
h1s_new_cs() function. This bug was introduced by the commit cda94accb
("MAJOR: stream/conn_stream: Move the stream-interface into the
conn-stream").

It is 2.6-specific, no backport is needed.

3 years agoBUG/MINOR: cache: do not display expired entries in "show cache"
Willy Tarreau [Wed, 13 Apr 2022 09:21:39 +0000 (11:21 +0200)] 
BUG/MINOR: cache: do not display expired entries in "show cache"

It was mentioned in issue #12 that expired entries would appear with a
negative expire delay in "show cache". Instead of listing them, let's
just evict them.

This could be backported to all versions since this was reported on
1.8 already.

3 years agoBUG/MINOR: mux-h2: do not send GOAWAY if SETTINGS were not sent
Willy Tarreau [Wed, 13 Apr 2022 07:40:52 +0000 (09:40 +0200)] 
BUG/MINOR: mux-h2: do not send GOAWAY if SETTINGS were not sent

It was reported in issue #13 that a GOAWAY frame was sent on timeout even
if no SETTINGS frame was sent. The approach imagined by then was to track
the fact that a SETTINGS frame was already sent to avoid this, but that's
already what is done through the state, though it doesn't stand due to the
fact that we switch the frame to the error state. Thus instead what we're
doing here is to instead set the GOAWAY_FAILED flag in h2c_error() before
switching to the ERROR state when the state indicates we've not yet sent
settings, and refrain from sending anything from the h2c_send_goaway_error()
function for such states.

This could be backported to all versions where it applies well.

3 years agoBUG/MINOR: h3: fix build with DEBUG_H3
Amaury Denoyelle [Tue, 12 Apr 2022 14:40:52 +0000 (16:40 +0200)] 
BUG/MINOR: h3: fix build with DEBUG_H3

qcs by_id field has been replaced by a new field named "id". Adjust the
h3_debug_printf traces. This is the case since the introduction of the
qc_stream_desc type.

3 years agoBUILD: halog: fix some incorrect signs in printf formats for integers
Willy Tarreau [Tue, 12 Apr 2022 06:37:22 +0000 (08:37 +0200)] 
BUILD: halog: fix some incorrect signs in printf formats for integers

In issue #1184, cppcheck found several issues in the printf formats
used to display integers, some of which are unsigned but which used to
still rely on "%d".

3 years agoBUILD/DEBUG: hpack: use unsigned int in printf format in debug code
Willy Tarreau [Tue, 12 Apr 2022 06:39:33 +0000 (08:39 +0200)] 
BUILD/DEBUG: hpack: use unsigned int in printf format in debug code

In issue #1184 cppcheck found that the debug code incorrectly uses %d
to print an unsigned value.

3 years agoBUILD/DEBUG: hpack-tbl: fix format string in standalone debug code
Willy Tarreau [Tue, 12 Apr 2022 06:30:08 +0000 (08:30 +0200)] 
BUILD/DEBUG: hpack-tbl: fix format string in standalone debug code

In issue #1184, cppcheck reports that an incorrect format "%d" was
used to print an unsigned in the debug code, though values are always
very small and this will never be an issue.

3 years agoBUILD: peers: adjust some printf format to silence cppcheck
Willy Tarreau [Tue, 12 Apr 2022 06:28:18 +0000 (08:28 +0200)] 
BUILD: peers: adjust some printf format to silence cppcheck

In issue #1184, cppcheck complains about some inconsistent printf
formats. At least the one in peer_prepare_hellomsg() that uses "%u"
for the int "min_ver" is wrong. Let's force other types to make it
happy, though constants cannot cause trouble.

3 years agoBUILD/DEBUG: lru: fix printf format in debug code
Willy Tarreau [Tue, 12 Apr 2022 06:16:54 +0000 (08:16 +0200)] 
BUILD/DEBUG: lru: fix printf format in debug code

cppcheck reports in issue #1184 a type mismatch between "%d" and the
unsigned int "misses" in the standalone debug code of lru.c. Let's
switch to "%u".

3 years agoMINOR: log: add '~' to frontend when the transport layer provides SSL
Willy Tarreau [Tue, 12 Apr 2022 06:08:33 +0000 (08:08 +0200)] 
MINOR: log: add '~' to frontend when the transport layer provides SSL

We used to check if the transport layer was ssl_sock to decide to log
"~" after a frontend's name. Now that QUIC is present, this doesn't work
anymore. Better rely on the transport layer's get_ssl_sock_ctx() method.

3 years agoCI: cirrus: switch to FreeBSD-13.0
Ilya Shipitsin [Mon, 11 Apr 2022 17:25:35 +0000 (22:25 +0500)] 
CI: cirrus: switch to FreeBSD-13.0

we use outdated FreeBSD-12.2, which is outdated, let us update
to the actual release

3 years agoBUG/MINOR: sock: do not double-close the accepted socket on the error path
Willy Tarreau [Tue, 12 Apr 2022 05:49:11 +0000 (07:49 +0200)] 
BUG/MINOR: sock: do not double-close the accepted socket on the error path

Coverity found in issue #1646 that I added a double-close bug in last
commit e4d09cedb ("MINOR: sock: check configured limits at the sock layer,
not the listener's") because the error path already closes the FD. No
backport needed.

3 years agoMINOR: ssl: refine the error testing for fc_err and fc_err_str
Willy Tarreau [Tue, 12 Apr 2022 05:40:42 +0000 (07:40 +0200)] 
MINOR: ssl: refine the error testing for fc_err and fc_err_str

In issue #1645, coverity suspects some dead code due to a pair of
remaining tests on "if (!ctx)". While all other functions test the
context earlier, these ones used to only test the connection and the
transport. It's still not very clear to me if there are certain error
cases that can lead to no SSL being initially set while the rest is
ready, and the SSL arriving later, but better preserve this original
construct by testing first the connection and only later the context.

3 years agoBUILD: ssl: add an unchecked version of __conn_get_ssl_sock_ctx()
Willy Tarreau [Tue, 12 Apr 2022 05:31:06 +0000 (07:31 +0200)] 
BUILD: ssl: add an unchecked version of __conn_get_ssl_sock_ctx()

First gcc, then now coverity report possible null derefs in situations
where we know these cannot happen since we call the functions in
contexts that guarantee the existence of the connection and the method
used. Let's introduce an unchecked version of the function for such
cases, just like we had to do with objt_*. This allows us to remove the
ALREADY_CHECKED() statements (which coverity doesn't see), and addresses
github issues #1643, #1644, #1647.

3 years agoBUILD: ssl: fix build warning with previous changes to ssl_sock_ctx
Willy Tarreau [Mon, 11 Apr 2022 17:47:31 +0000 (19:47 +0200)] 
BUILD: ssl: fix build warning with previous changes to ssl_sock_ctx

Some compilers see a possible null deref after conn_get_ssl_sock_ctx()
in ssl_sock_parse_heartbeat, which cannot happen there, so let's mark
it as safe. No backport needed.

3 years agoMEDIUM: quic: move conn->qc into conn->handle
Willy Tarreau [Mon, 11 Apr 2022 12:18:10 +0000 (14:18 +0200)] 
MEDIUM: quic: move conn->qc into conn->handle

It was supposed to be there, and probably was not placed there due to
historic limitations in listener_accept(), but now there does not seem
to be a remaining valid reason for keeping the quic_conn out of the
handle. In addition in new_quic_cli_conn() the handle->fd was incorrectly
set to the listener's FD.

3 years agoMEDIUM: xprt-quic: implement get_ssl_sock_ctx()
Willy Tarreau [Mon, 11 Apr 2022 09:57:35 +0000 (11:57 +0200)] 
MEDIUM: xprt-quic: implement get_ssl_sock_ctx()

By being able to return the ssl_sock_ctx, we're now enabling the whole
set of SSL sample fetch methods to work on the current SSL context of
the QUIC connection, as seen in the following test showing a request
forwarded to an HTTP/1 server with plenty of SSL headers filled:

00000001:decrypt.clireq[000f:ffffffff]: GET / HTTP/1.1
00000001:decrypt.clihdr[000f:ffffffff]: host: localhost
00000001:decrypt.clihdr[000f:ffffffff]: user-agent: nghttp3/ngtcp2 client
00000001:decrypt.clihdr[000f:ffffffff]: x-src: 127.0.0.1
00000001:decrypt.clihdr[000f:ffffffff]: x-dst: 127.0.0.4
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_f_serial: D16197E7D3E634E9
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_f_key_alg: rsaEncryption
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_f_sig_alg: RSA-SHA1
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_fc: 1
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_fc_has_sni: 1
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_fc_sni: blah
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_fc_alpn: h3
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_fc_protocol: TLSv1.3
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_fc_cipher: TLS_AES_256_GCM_SHA384
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_fc_alg_keysize: 256
00000001:decrypt.clihdr[000f:ffffffff]: x-ssl_fc_use_keysize: 256
00000001:decrypt.clihdr[000f:ffffffff]: x-forwarded-for: 127.0.0.1

The code is trivial, but this is marked as medium as there's always
the risk that some of the callable functions do not like being called
on such SSL contexts.

3 years agoMEDIUM: ssl: stop using conn->xprt_ctx to access the ssl_sock_ctx
Willy Tarreau [Mon, 11 Apr 2022 09:29:11 +0000 (11:29 +0200)] 
MEDIUM: ssl: stop using conn->xprt_ctx to access the ssl_sock_ctx

The SSL functions must not use conn->xprt_ctx anymore but find the context
by calling conn_get_ssl_sock_ctx(), which will properly pass through the
transport layers to retrieve the desired information. Otherwise when the
functions are called on a QUIC connection, they refuse to work for not
being called on the proper transport.

3 years agoMEDIUM: ssl: improve retrieval of ssl_sock_ctx and SSL detection
Willy Tarreau [Mon, 11 Apr 2022 08:43:28 +0000 (10:43 +0200)] 
MEDIUM: ssl: improve retrieval of ssl_sock_ctx and SSL detection

Historically there was a single way to have an SSL transport on a
connection, so detecting if the transport layer was SSL and a context
was present was sufficient to detect SSL. With QUIC, things have changed
because QUIC also relies on SSL, but the context is embedded inside the
quic_conn and the transport layer doesn't match expectations outside,
making it difficult to detect that SSL is in use over the connection.

The approach taken here to improve this consists in adding a new method
at the transport layer, get_ssl_sock_ctx(), to retrieve this often needed
ssl_sock_ctx, and to use this to detect the presence of SSL. This will
even allow some simplifications and cleanups to be made in the SSL code
itself, and QUIC will be able to provide one to export its ssl_sock_ctx.

3 years agoMINOR: quic-sock: provide a pair of get_src/get_dst functions
Willy Tarreau [Mon, 11 Apr 2022 14:20:00 +0000 (16:20 +0200)] 
MINOR: quic-sock: provide a pair of get_src/get_dst functions

These functions will allow the connection layer to retrieve a quic_conn's
source or destination when possible. The quic_conn holds the peer's address
but not the local one, and the sockets API doesn't always makes that easy
for datagrams. Thus for frontend connection what we're doing here is to
retrieve the listener's address when the destination address is desired.

Now it finally becomes possible to fetch the source and destination using
"src" and "dst", and to pass an incoming connection's endpoints via the
proxy protocol.

3 years agoMINOR: protocol: add get_src() and get_dst() at the protocol level
Willy Tarreau [Fri, 8 Apr 2022 11:49:17 +0000 (13:49 +0200)] 
MINOR: protocol: add get_src() and get_dst() at the protocol level

Right now the proto_fam descriptor provides a family-specific
get_src() and get_dst() pair of calls to retrieve a socket's source
or destination address. However this only works for connected mode
sockets. QUIC provides its own stream protocol, which relies on a
datagram protocol underneath, so the get_src()/get_dst() at that
protocol's family will not work, and QUIC would need to provide its
own.

This patch implements get_src() and get_dst() at the protocol level
from a connection, and makes sure that conn_get_src()/conn_get_dst()
will automatically use them if defined before falling back to the
family's pair of functions.

3 years agoMINOR: connection: rearrange conn_get_src/dst to be a bit more extensible
Willy Tarreau [Fri, 8 Apr 2022 16:05:41 +0000 (18:05 +0200)] 
MINOR: connection: rearrange conn_get_src/dst to be a bit more extensible

We'll want conn_get_src/dst to support other means of retrieving these
respective IP addresses, but the functions as they're designed are a bit
too restrictive for now.

This patch arranges them to have a default error fallback allowing to
test different mechanisms. In addition we now make sure the underlying
protocol is of type stream before calling the family's get_src/dst as
it makes no sense to do that on dgram sockets for example.

3 years agoMINOR: mux-quic: properly set the flags and name fields
Willy Tarreau [Mon, 11 Apr 2022 07:29:21 +0000 (09:29 +0200)] 
MINOR: mux-quic: properly set the flags and name fields

The mux didn't have its flags nor name set, as seen in this output of
"haproxy -vv":

 Available multiplexer protocols :
 (protocols marked as <default> cannot be specified using 'proto' keyword)
   quic : mode=HTTP  side=FE     mux=      flags=
     h2 : mode=HTTP  side=FE|BE  mux=H2    flags=HTX|CLEAN_ABRT|HOL_RISK|NO_UPG

This might have random impacts at certain points like forcing some
connections to close instead of aborting a stream, or not always
handling certain streams as fully HTX-compliant.

3 years agoMEDIUM: connection: panic when calling FD-specific functions on FD-less conns
Willy Tarreau [Mon, 11 Apr 2022 16:07:03 +0000 (18:07 +0200)] 
MEDIUM: connection: panic when calling FD-specific functions on FD-less conns

Certain functions cannot be called on an FD-less conn because they are
normally called as part of the protocol-specific setup/teardown sequence.
Better place a few BUG_ON() to make sure none of them is called in other
situations. If any of them would trigger in ambiguous conditions, it would
always be possible to replace it with an error.

3 years agoMINOR: connection: skip FD-based syscalls for FD-less connections
Willy Tarreau [Mon, 11 Apr 2022 16:04:33 +0000 (18:04 +0200)] 
MINOR: connection: skip FD-based syscalls for FD-less connections

Some syscalls at the TCP level act directly on the FD. Some of them
are used by TCP actions like set-tos, set-mark, silent-drop, others
try to retrieve TCP info, get the source or destination address. These
ones must not be called with an invalid FD coming from an FD-less
connection, so let's add the relevant tests for this. It's worth
noting that all these ones already have fall back plans (do nothing,
error, or switch to alternate implementation).

3 years agoMINOR: connection: use conn_fd() when displaying connection errors
Willy Tarreau [Mon, 11 Apr 2022 16:01:28 +0000 (18:01 +0200)] 
MINOR: connection: use conn_fd() when displaying connection errors

The SSL connection errors and socks4 proxy errors used to blindly dump
the FD, now it's sanitized via conn_fd().

3 years agoMINOR: stream: only dump connections' FDs when they are valid
Willy Tarreau [Mon, 11 Apr 2022 15:58:06 +0000 (17:58 +0200)] 
MINOR: stream: only dump connections' FDs when they are valid

The "show sess" output and the debugger outputs will now use conn_fd()
to retrieve the file descriptor instead of dumping incorrect data.

3 years agoMINOR: connection: add conn_fd() to retrieve the FD only when it exists
Willy Tarreau [Mon, 11 Apr 2022 15:54:46 +0000 (17:54 +0200)] 
MINOR: connection: add conn_fd() to retrieve the FD only when it exists

There are plenty of places (particularly in debug code) where we try to
dump the connection's FD only when the connection is defined. That's
already a pain but now it gets one step further with QUIC because we do
*not* want to dump this FD in this case.

conn_fd() checks if the connection exists, is ready and is not fd-less,
and returns the FD only in this case, otherwise returns -1. This aims at
simplifying most of these conditions.

3 years agoMINOR: connection: add a new flag CO_FL_FDLESS on fd-less connections
Willy Tarreau [Mon, 11 Apr 2022 15:26:56 +0000 (17:26 +0200)] 
MINOR: connection: add a new flag CO_FL_FDLESS on fd-less connections

QUIC connections do not use a file descriptor, instead they use the
quic equivalent which is the quic_conn. A number of our historical
functions at the connection level continue to unconditionally touch
the file descriptor and this may have consequences once QUIC starts
to be used.

This patch adds a new flag on QUIC connections, CO_FL_FDLESS, to
mention that the connection doesn't have a file descriptor, hence the
FD-based API must never be used on them.

From now on it will be possible to intrument existing functions to
panic when this flag is present.