]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
3 years agoMEDIUM: peers: Balance applets across threads
Maciej Zdeb [Mon, 16 May 2022 15:27:28 +0000 (17:27 +0200)] 
MEDIUM: peers: Balance applets across threads

When creating a new applet for peer outgoing connection, we check
the load on each thread. Threads with least applet count are
preferred.

With this solution we avoid a situation when many outgoing
connections run on the same thread causing significant load on
single CPU core.

3 years agoMINOR: peers: Track number of applets run by thread
Maciej Zdeb [Mon, 16 May 2022 15:26:20 +0000 (17:26 +0200)] 
MINOR: peers: Track number of applets run by thread

Maintain number of peers applets run on all threads. It will be used
in next patch for least loaded thread selection.

3 years agoMEDIUM: applet: Add support for async appctx startup on a thread subset
Christopher Faulet [Mon, 16 May 2022 15:15:31 +0000 (17:15 +0200)] 
MEDIUM: applet: Add support for async appctx startup on a thread subset

It is now possible to start an appctx on a thread subset. Some controls were
added here and there. It is forbidden to start a backend appctx on another
thread than the local one. If a frontend appctx is started on another thread
or a thread subset, the applet .init callback function must be defined. This
callback function is responsible to finalize the appctx startup. It can be
performed synchornously. In this case, the appctx is started on the local
thread. It is not really useful but it is valid. Or it can be performed
asynchronously. In this case, .init callback function is called when the
appctx is woken up for the first time. When this happens, the appctx
affinity is set to the current thread to be able to start the session and
the stream.

3 years agoMINOR: applet: Add API to start applet on a thread subset
Christopher Faulet [Mon, 16 May 2022 15:09:48 +0000 (17:09 +0200)] 
MINOR: applet: Add API to start applet on a thread subset

In the same way than for the tasks, the applets api was changed to be able
to start a new appctx on a thread subset. For now the feature is
disabled. Only appctx_new_here() is working. But it will be possible to
start an appctx on a specific thread or a subset via a mask.

3 years agoMEDIUM: peers: Refactor peer appctx creation
Christopher Faulet [Thu, 12 May 2022 13:36:11 +0000 (15:36 +0200)] 
MEDIUM: peers: Refactor peer appctx creation

A .init callback function is defined for the peer_applet applet. This
function finishes the appctx startup by calling appctx_finalize_startup()
and its handles the stream customization.

3 years agoMINOR: peers: Add a ref to peers section in the peer structure
Christopher Faulet [Thu, 12 May 2022 12:47:52 +0000 (14:47 +0200)] 
MINOR: peers: Add a ref to peers section in the peer structure

This change is required to handle asynchrone init of the appctx. It is now
possible to directly get the peers section associated to a peer.

3 years agoMEDIUM: sink: Refactor sink forwarder appctx creation
Christopher Faulet [Thu, 12 May 2022 13:34:48 +0000 (15:34 +0200)] 
MEDIUM: sink: Refactor sink forwarder appctx creation

A .init callback function is defined for the sink_forward_applet applet.
This function finishes the appctx startup by calling
appctx_finalize_startup() and its handles the stream customization.

3 years agoMINOR: sink: Add a ref to sink in the sink_forward_target structure
Christopher Faulet [Thu, 12 May 2022 12:50:09 +0000 (14:50 +0200)] 
MINOR: sink: Add a ref to sink in the sink_forward_target structure

This change is required to be able to refactor the init stage of appctx. It
is now possible to directly get the sink from a forward target.

3 years agoMEDIUM: httpclient: Refactor http-client appctx creation
Christopher Faulet [Thu, 12 May 2022 13:33:14 +0000 (15:33 +0200)] 
MEDIUM: httpclient: Refactor http-client appctx creation

A .init callback function is defined for the httpclient_applet applet. This
function finishes the appctx startup by calling appctx_finalize_startup()
and its handles the stream customization.

3 years agoMEDIUM: lua: Refactor cosocket appctx creation
Christopher Faulet [Thu, 12 May 2022 13:31:05 +0000 (15:31 +0200)] 
MEDIUM: lua: Refactor cosocket appctx creation

A .init callback function is defined for the update_applet applet. This
function finishes the appctx startup by calling appctx_finalize_startup()
and its handles the stream customization.

3 years agoMEDIUM: spoe: Refactor SPOE appctx creation
Christopher Faulet [Thu, 12 May 2022 13:28:51 +0000 (15:28 +0200)] 
MEDIUM: spoe: Refactor SPOE appctx creation

A .init callback function is defined for the spoe_applet applet. This
function finishes the spoe_appctx initialization. It also finishes the
appctx startup by calling appctx_finalize_startup() and its handles the
stream customization.

3 years agoMEDIUM: dns: Refactor dns appctx creation
Christopher Faulet [Thu, 12 May 2022 13:24:46 +0000 (15:24 +0200)] 
MEDIUM: dns: Refactor dns appctx creation

A .init callback function is defined for the dns_session_applet applet. This
function finishes the appctx startup by calling appctx_finalize_startup()
and its handles the stream customization.

3 years agoMINOR: applet: Add function to release appctx on error during init stage
Christopher Faulet [Thu, 12 May 2022 13:18:48 +0000 (15:18 +0200)] 
MINOR: applet: Add function to release appctx on error during init stage

appctx_free_on_early_error() must be used to release a freshly created
frontend appctx if an error occurred during the init stage. It takes care to
release the stream instead of the appctx if it exists. For a backend appctx,
it just calls appctx_free().

3 years agoMINOR: applet: Add a function to finalize frontend appctx startup
Christopher Faulet [Thu, 12 May 2022 13:15:53 +0000 (15:15 +0200)] 
MINOR: applet: Add a function to finalize frontend appctx startup

appctx_finalize_startup() may be used to finalize the frontend appctx
startup. It is responsible to create the appctx's session and the frontend
conn-stream. On error, it is the caller responsibility to release the
appctx. However, the session is released if it was created. On success, if
an error is encountered in the caller function, the stream must be released
instead of the appctx.

This function should ease the init stage when new appctx is created.

3 years agoMINOR: applet: Add appctx_init() helper fnuction
Christopher Faulet [Thu, 12 May 2022 12:59:28 +0000 (14:59 +0200)] 
MINOR: applet: Add appctx_init() helper fnuction

It is just a helper function that call the .init applet callback function,
if it exists. This will simplify a bit the init stage when a new applet is
started. For now, this callback function is only used when a new service is
started.

3 years agoMINOR: stream: Export stream_free()
Christopher Faulet [Thu, 12 May 2022 12:56:55 +0000 (14:56 +0200)] 
MINOR: stream: Export stream_free()

The stream_free() function is now public. It is mandatory to properly handle
errors when a new applet is started.

3 years agoMINOR: applet: Change return value for .init callback function
Christopher Faulet [Thu, 12 May 2022 09:52:27 +0000 (11:52 +0200)] 
MINOR: applet: Change return value for .init callback function

0 is now returned on success and -1 on error.

3 years agoMINOR: applet: Let the frontend appctx release the session
Christopher Faulet [Wed, 11 May 2022 10:22:10 +0000 (12:22 +0200)] 
MINOR: applet: Let the frontend appctx release the session

The session created for frontend applets is now totally owns by the
corresponding appctx. It means the appctx is now responsible to release
it. This removes the hack in stream_free() about frontend applets to be sure
to release the session.

3 years agoMINOR: applet: Prepare appctx to own the session on frontend side
Christopher Faulet [Mon, 9 May 2022 06:08:26 +0000 (08:08 +0200)] 
MINOR: applet: Prepare appctx to own the session on frontend side

Applets were moved at the same level than multiplexers. Thus, gradually,
applets code is changed to be less dependent from the stream. With this
commit, the frontend appctx are ready to own the session. It means a
frontend appctx will be responsible to release the session.

3 years agoCLEANUP: conn-stream: Remove cs_applet_shut declaration from header file
Christopher Faulet [Wed, 11 May 2022 09:52:53 +0000 (11:52 +0200)] 
CLEANUP: conn-stream: Remove cs_applet_shut declaration from header file

This function was renamed and moved in applet code. cs_applet_shut() does
not exist anymore. Its declaration must be removed.

3 years agoBUG/MINOR: ssl: Fix crash when no private key is found in pem
Remi Tricot-Le Breton [Mon, 9 May 2022 09:07:13 +0000 (11:07 +0200)] 
BUG/MINOR: ssl: Fix crash when no private key is found in pem

If no private key can be found in a bind line's certificate and
ssl-load-extra-files is set to none we end up trying to call
X509_check_private_key with a NULL key, which crashes.

This fix should be backported to all stable branches.

3 years agoMINOR: tools: add get_exec_path implementation for solaris based systems.
David Carlier [Sat, 14 May 2022 16:15:49 +0000 (17:15 +0100)] 
MINOR: tools: add get_exec_path implementation for solaris based systems.

We can use getexecname() which fetches AT_SUN_EXECNAME from the auxiliary
vectors.

3 years agoBUILD: fix build warning on solaris based systems with __maybe_unused.
David Carlier [Sat, 14 May 2022 16:10:50 +0000 (17:10 +0100)] 
BUILD: fix build warning on solaris based systems with __maybe_unused.

__maybe_unused is already defined there.

3 years agoCLEANUP: Remove unused function hlua_get_top_error_string
Tim Duesterhus [Sat, 14 May 2022 20:15:28 +0000 (22:15 +0200)] 
CLEANUP: Remove unused function hlua_get_top_error_string

This function has no prototype defined in a header and is not used in hlua.c
either, thus it can be safely removed. Found with -Wmissing-prototypes.

3 years agoCLEANUP: Add missing header to hlua_fcn.c
Tim Duesterhus [Sat, 14 May 2022 20:17:25 +0000 (22:17 +0200)] 
CLEANUP: Add missing header to hlua_fcn.c

Found with -Wmissing-prototypes:

    src/hlua_fcn.c:53:5: fatal error: no previous prototype for function 'hlua_checkboolean' [-Wmissing-prototypes]
    int hlua_checkboolean(lua_State *L, int index)
        ^
    src/hlua_fcn.c:53:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
    int hlua_checkboolean(lua_State *L, int index)
    ^
    static
    1 error generated.

3 years agoCLEANUP: Add missing header to ssl_utils.c
Tim Duesterhus [Sat, 14 May 2022 20:15:26 +0000 (22:15 +0200)] 
CLEANUP: Add missing header to ssl_utils.c

Found with -Wmissing-prototypes:

    src/ssl_utils.c:22:5: fatal error: no previous prototype for function 'cert_get_pkey_algo' [-Wmissing-prototypes]
    int cert_get_pkey_algo(X509 *crt, struct buffer *out)
        ^
    src/ssl_utils.c:22:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
    int cert_get_pkey_algo(X509 *crt, struct buffer *out)
    ^
    static
    1 error generated.

3 years agoMINOR: ssl: Add 'ssl-provider' global option
Remi Tricot-Le Breton [Mon, 16 May 2022 14:24:33 +0000 (16:24 +0200)] 
MINOR: ssl: Add 'ssl-provider' global option

When HAProxy is linked to an OpenSSLv3 library, this option can be used
to load a provider during init. You can specify multiple ssl-provider
options, which will be loaded in the order they appear. This does not
prevent OpenSSL from parsing its own configuration file in which some
other providers might be specified.
A linked list of the providers loaded from the configuration file is
kept so that all those providers can be unloaded during cleanup. The
providers loaded directly by OpenSSL will be freed by OpenSSL.

3 years agoMINOR: ssl: Add 'ssl-propquery' global option
Remi Tricot-Le Breton [Mon, 16 May 2022 14:24:32 +0000 (16:24 +0200)] 
MINOR: ssl: Add 'ssl-propquery' global option

This option can be used to define a default property query used when
fetching algorithms in OpenSSL providers. It follows the format
described in https://www.openssl.org/docs/man3.0/man7/property.html.
It is only available when haproxy is built with SSL support and linked
to OpenSSLv3 libraries.

3 years agoMEDIUM: ssl: Delay random generator initialization after config parsing
Remi Tricot-Le Breton [Mon, 16 May 2022 14:24:31 +0000 (16:24 +0200)] 
MEDIUM: ssl: Delay random generator initialization after config parsing

The random generator initialization needs to be performed before the
chroot but it is not needed before. If we want to add provider
configuration option to the configuration file, they need to be
processed before any call to a crypto-related OpenSSL function.
We can then delay the initialization until after the configuration file
is parsed and processed.

3 years agoMEDIUM: http-ana: Add a proxy option to restrict chars in request header names
Christopher Faulet [Mon, 16 May 2022 09:43:10 +0000 (11:43 +0200)] 
MEDIUM: http-ana: Add a proxy option to restrict chars in request header names

The "http-restrict-req-hdr-names" option can now be set to restrict allowed
characters in the request header names to the "[a-zA-Z0-9-]" charset.

Idea of this option is to not send header names with non-alphanumeric or
hyphen character. It is especially important for FastCGI application because
all those characters are converted to underscore. For instance,
"X-Forwarded-For" and "X_Forwarded_For" are both converted to
"HTTP_X_FORWARDED_FOR". So, header names can be mixed up by FastCGI
applications. And some HAProxy rules may be bypassed by mangling header
names. In addition, some non-HTTP compliant servers may incorrectly handle
requests when header names contain characters ouside the "[a-zA-Z0-9-]"
charset.

When this option is set, the policy must be specify:

  * preserve: It disables the filtering. It is the default mode for HTTP
              proxies with no FastCGI application configured.

  * delete: It removes request headers with a name containing a character
            outside the "[a-zA-Z0-9-]" charset. It is the default mode for
            HTTP backends with a configured FastCGI application.

  * reject: It rejects the request with a 403-Forbidden response if it
            contains a header name with a character outside the
            "[a-zA-Z0-9-]" charset.

The option is evaluated per-proxy and after http-request rules evaluation.

This patch may be backported to avoid any secuirty issue with FastCGI
application (so as far as 2.2).

3 years agoMINOR: ncbuf: fix warnings for testing build
Amaury Denoyelle [Mon, 16 May 2022 09:09:05 +0000 (11:09 +0200)] 
MINOR: ncbuf: fix warnings for testing build

Using -Wall reveals several warning when building ncbuf testing API. One
of them was about the signedness mismatch. The other one was with an
incorrect print format.

3 years agoBUG/MEDIUM: ncbuf: fix null buffer usage
Amaury Denoyelle [Mon, 16 May 2022 09:09:29 +0000 (11:09 +0200)] 
BUG/MEDIUM: ncbuf: fix null buffer usage

ncbuf public API functions were not ready to deal with a NCBUF_NULL as
parameter. Strenghten these functions by handling it properly.

Most of the functions will consider the buffer as empty and silently
returns. The only exception is ncb_init(buf) which cannot be called
with a NCBUF_NULL. This seems legitimate to consider this as a bug and
not silently failed in this case.

3 years agoCI: determine actual LibreSSL version dynamically
Ilya Shipitsin [Fri, 13 May 2022 16:59:38 +0000 (21:59 +0500)] 
CI: determine actual LibreSSL version dynamically

this change introduce "LIBRESSL_VERSION=latest" semantic, which scans
http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/ and detects latest release.

LIBRESSL_VERSION=2.9.2 is removed from the matrix.

3 years ago[RELEASE] Released version 2.6-dev10 v2.6-dev10
Willy Tarreau [Sat, 14 May 2022 14:05:50 +0000 (16:05 +0200)] 
[RELEASE] Released version 2.6-dev10

Released version 2.6-dev10 with the following main changes :
    - MINOR: ssl: ignore dotfiles when loading a dir w/ ca-file
    - MEDIUM: ssl: ignore dotfiles when loading a dir w/ crt
    - BUG/MINOR: ssl: Fix typos in crl-file related CLI commands
    - MINOR: compiler: add a new macro to set an attribute on an enum when possible
    - BUILD: stats: conditionally mark obsolete stats states as deprecated
    - BUILD: ssl: work around bogus warning in gcc 12's -Wformat-truncation
    - BUILD: debug: work around gcc-12 excessive -Warray-bounds warnings
    - BUILD: listener: shut report of possible null-deref in listener_accept()
    - BUG/MEDIUM: ssl: fix the gcc-12 broken fix :-(
    - DOC: install: update gcc version requirements
    - BUILD: makefile: add -Wfatal-errors to the default flags
    - BUG/MINOR: server: Make SRV_STATE_LINE_MAXLEN value from 512 to 2kB (2000 bytes).
    - BUG/MAJOR: dns: multi-thread concurrency issue on UDP socket
    - BUG/MINOR: mux-h2: mark the stream as open before processing it not after
    - MINOR: mux-h2: report a trace event when failing to create a new stream
    - DOC: configuration: add the httpclient keywords to the global keywords index
    - MINOR: quic: Add a debug counter for sendto() errors
    - BUG/MINOR: quic: Dropped peer transport parameters
    - BUG/MINOR: quic: Wrong unit for ack delay for incoming ACK frames
    - MINOR: quic: Congestion controller event trace fix (loss)
    - MINOR: quic: Add correct ack delay values to ACK frames
    - MINOR: config: Add "cluster-secret" new global keyword
    - MINOR: quic-tls: Add quic_hkdf_extract_and_expand() for HKDF
    - MINOR: quic: new_quic_cid() code moving
    - MINOR: quic: Initialize stateless reset tokens with HKDF secrets
    - MINOR: qc_new_conn() rework for stateless reset
    - MINOR: quic: Stateless reset token copy to transport parameters
    - MINOR: quic: Send stateless reset tokens
    - MINOR: quic: Short packets always embed a trailing AEAD TAG
    - CLEANUP: quic: wrong use of eb*entry() macro
    - CLEANUP: quic: Useless use of pointer for quic_hkdf_extract()
    - CLEANUP: quic_tls: QUIC_TLS_IV_LEN defined two times
    - MINOR: ncbuf: define non-contiguous buffer
    - MINOR: ncbuf: complete API and define block interal abstraction
    - MINOR: ncbuf: optimize storage for the last gap
    - MINOR: ncbuf: implement insertion
    - MINOR: ncbuf: define various insertion modes
    - MINOR: ncbuf: implement advance
    - MINOR: ncbuf: write unit tests
    - BUG/MEDIUM: lua: fix argument handling in data removal functions
    - DOC/MINOR: fix typos in the lua-api document
    - BUG/MEDIUM: wdt: don't trigger the watchdog when p is unitialized
    - MINOR: mux-h1: Add global option accpet payload for any HTTP/1.0 requests
    - CLEANUP: mux-h1: Fix comments and error messages for global options
    - MINOR: conn_stream: make cs_set_error() work on the endpoint instead
    - CLEANUP: mux-h1: always take the endp from the h1s not the cs
    - CLEANUP: mux-h2: always take the endp from the h2s not the cs
    - CLEANUP: mux-pt: always take the endp from the context not the cs
    - CLEANUP: mux-fcgi: always take the endp from the fstrm not the cs
    - CLEANUP: mux-quic: always take the endp from the qcs not the cs
    - CLEANUP: applet: use the appctx's endp instead of cs->endp
    - MINOR: conn_stream: add a pointer back to the cs from the endpoint
    - MINOR: mux-h1: remove the now unneeded h1s->cs
    - MINOR: mux-h2: make sure any h2s always has an endpoint
    - MINOR: mux-h2: remove the now unneeded conn_stream from the h2s
    - MINOR: mux-fcgi: make sure any stream always has an endpoint
    - MINOR: mux-fcgi: remove the now unneeded conn_stream from the fcgi_strm
    - MINOR: mux-quic: remove the now unneeded conn_stream from the qcs
    - MINOR: mux-pt: remove the now unneeded conn_stream from the context
    - CLEANUP: muxes: make mux->attach/detach take a conn_stream endpoint
    - MINOR: applet: replace cs_applet_shut() with appctx_shut()
    - MINOR: applet: add appctx_strm() and appctx_cs() to access common fields
    - CLEANUP: applet: remove the unneeded appctx->owner
    - CLEANUP: conn_stream: merge cs_new_from_{mux,applet} into cs_new_from_endp()
    - MINOR: ext-check: indicate the transport and protocol of a server
    - BUG/MEDIUM: mux-quic: fix a thinko in the latest cs/endpoint cleanup
    - MINOR: tools: improve error message accuracy in str2sa_range
    - MINOR: config: make sure never to mix dgram and stream protocols on a bind line
    - BUG/MINOR: ncbuf: fix coverity warning on uninit sz_data
    - MINOR: xprt_quic: adjust flow-control according to bufsize
    - MEDIUM: mux-quic/h3/hq-interop: use ncbuf for bidir streams
    - MEDIUM: mux-quic/h3/qpack: use ncbuf for uni streams
    - CLEANUP: mux-quic: remove unused fields for Rx
    - CLEANUP: quic: remove unused quic_rx_strm_frm

3 years agoCLEANUP: quic: remove unused quic_rx_strm_frm
Amaury Denoyelle [Fri, 13 May 2022 13:42:19 +0000 (15:42 +0200)] 
CLEANUP: quic: remove unused quic_rx_strm_frm

quic_rx_strm_frm type was used to buffered STREAM frames received out of
order. Now the MUX is able to deal directly with these frames and
buffered it inside its ncbuf.

3 years agoCLEANUP: mux-quic: remove unused fields for Rx
Amaury Denoyelle [Fri, 13 May 2022 13:41:35 +0000 (15:41 +0200)] 
CLEANUP: mux-quic: remove unused fields for Rx

Rx has been simplified since the conversion of buffer to a ncbuf. The
old buffer can now be removed. The frms tree is also removed. It was
used previously to stored out-of-order received STREAM frames. Now the
MUX is able to buffer them directly into the ncbuf.

3 years agoMEDIUM: mux-quic/h3/qpack: use ncbuf for uni streams
Amaury Denoyelle [Fri, 13 May 2022 13:41:04 +0000 (15:41 +0200)] 
MEDIUM: mux-quic/h3/qpack: use ncbuf for uni streams

This commit is the equivalent for uni-streams of previous commit
  MEDIUM: mux-quic/h3/hq-interop: use ncbuf for bidir streams

All unidirectional streams data is now handle in MUX Rx ncbuf. The
obsolete buffer is not unused and will be cleared in the following
patches.

3 years agoMEDIUM: mux-quic/h3/hq-interop: use ncbuf for bidir streams
Amaury Denoyelle [Fri, 13 May 2022 12:49:05 +0000 (14:49 +0200)] 
MEDIUM: mux-quic/h3/hq-interop: use ncbuf for bidir streams

Add a ncbuf for data reception on qcs. Thanks to this, the MUX is able
to buffered all received frame directly into the buffer. Flow control
parameters will be used to ensure there is never an overflow.

This change will simplify Rx path with the future deletion of acked
frames tree previously used for frames out of order.

3 years agoMINOR: xprt_quic: adjust flow-control according to bufsize
Amaury Denoyelle [Fri, 13 May 2022 09:27:06 +0000 (11:27 +0200)] 
MINOR: xprt_quic: adjust flow-control according to bufsize

Redefine the initial local flow-control to enforce by us. Use bufsize as
the maximum offset allowed to be received.

This change is part of an adjustement on the Rx path. Mux buffer will be
converted to a ncbuf. Flow-control parameters must ensure that we never
receive a frame larger than the buffer. With this, all received frames
will be stored in the MUX buffer.

3 years agoBUG/MINOR: ncbuf: fix coverity warning on uninit sz_data
Amaury Denoyelle [Fri, 13 May 2022 13:33:50 +0000 (15:33 +0200)] 
BUG/MINOR: ncbuf: fix coverity warning on uninit sz_data

Coverity reports that data block generated by ncb_blk_first() has
sz_data field uninitialized. This has no real impact as it has no sense
for data block. Set to 0 to hide the warning.

This should fix github issue #1695.

3 years agoMINOR: config: make sure never to mix dgram and stream protocols on a bind line
Willy Tarreau [Tue, 26 Apr 2022 12:40:30 +0000 (14:40 +0200)] 
MINOR: config: make sure never to mix dgram and stream protocols on a bind line

It is absolutely not possible to use the same "bind" line to listen to
both quic and tcp for example, because no single transport layer would
fit both modes and we'll need the type to choose one then to choose a
mux. Let's make sure this does not happen. This may be relaxed in the
future if we manage to instantiate transport layers on the fly, but the
SSL vs quic part might be tricky to handle.

3 years agoMINOR: tools: improve error message accuracy in str2sa_range
Willy Tarreau [Mon, 9 May 2022 14:18:26 +0000 (16:18 +0200)] 
MINOR: tools: improve error message accuracy in str2sa_range

The error message when mixing stream and dgram protocols in an
address speaks about sockets while it ought to speak about addresses,
let's fix this as in some contexts it can be a bit confusing.

3 years agoBUG/MEDIUM: mux-quic: fix a thinko in the latest cs/endpoint cleanup
Willy Tarreau [Fri, 13 May 2022 14:31:23 +0000 (16:31 +0200)] 
BUG/MEDIUM: mux-quic: fix a thinko in the latest cs/endpoint cleanup

Fred & Amaury found that I messed up with qc_detach() in commit 4201ab791
("CLEANUP: muxes: make mux->attach/detach take a conn_stream endpoint"),
causing a segv in this case with endp->cs == NULL being passed to
__cs_mux(). It obviously ought to have been endp->target like in other
muxes.

No backport needed.

3 years agoMINOR: ext-check: indicate the transport and protocol of a server
Willy Tarreau [Fri, 13 May 2022 13:58:35 +0000 (15:58 +0200)] 
MINOR: ext-check: indicate the transport and protocol of a server

Valerio Pachera explained [1] that external checks would benefit from
having a variable indicating if SSL is being used or not on the server
being checked, and the discussion derived to also indicating the protocol
in use.

This patch adds two environment variables for external checks:
  - HAPROXY_SERVER_SSL: equals "0" when SSL is not used, "1" when it is
  - HAPROXY_SERVER_PROTO: contains one of the following words to describe
    the protocol used with this server:
      - "cli": the haproxy CLI. Normally not seen
      - "syslog": this is a syslog TCP server
      - "peers": this is a peers TCP server
      - "h1": this is an HTTP/1.x server
      - "h2": this is an HTTP/2 server
      - "tcp": this is any other TCP server

The patch is very simple, and may be backported to recent versions if
needed. This closes github issue #1692.

[1] https://www.mail-archive.com/haproxy@formilux.org/msg42233.html

3 years agoCLEANUP: conn_stream: merge cs_new_from_{mux,applet} into cs_new_from_endp()
Willy Tarreau [Wed, 11 May 2022 14:11:24 +0000 (16:11 +0200)] 
CLEANUP: conn_stream: merge cs_new_from_{mux,applet} into cs_new_from_endp()

The two functions became exact copies since there's no more special case
for the appctx owner. Let's merge them into a single one, that simplifies
the code.

3 years agoCLEANUP: applet: remove the unneeded appctx->owner
Willy Tarreau [Wed, 11 May 2022 12:09:57 +0000 (14:09 +0200)] 
CLEANUP: applet: remove the unneeded appctx->owner

This one is the pointer to the conn_stream which is always in the
endpoint that is always present in the appctx, thus it's not needed.
This patch removes it and replaces it with appctx_cs() instead. A
few occurences that were using __cs_strm(appctx->owner) were moved
directly to appctx_strm() which does the equivalent.

3 years agoMINOR: applet: add appctx_strm() and appctx_cs() to access common fields
Willy Tarreau [Wed, 11 May 2022 12:14:56 +0000 (14:14 +0200)] 
MINOR: applet: add appctx_strm() and appctx_cs() to access common fields

It's very common to have to access a stream or a conn_stream from the
appctx, let's add trivial accessors for that.

3 years agoMINOR: applet: replace cs_applet_shut() with appctx_shut()
Willy Tarreau [Tue, 10 May 2022 17:42:22 +0000 (19:42 +0200)] 
MINOR: applet: replace cs_applet_shut() with appctx_shut()

The former takes a conn_stream still attached to a valid appctx,
which also complicates the termination of the applet. Instead, let's
pass the appctx which already points to the endpoint, this allows us
to properly detach the conn_stream before the call, which is cleaner
and safer.

3 years agoCLEANUP: muxes: make mux->attach/detach take a conn_stream endpoint
Willy Tarreau [Tue, 10 May 2022 17:18:52 +0000 (19:18 +0200)] 
CLEANUP: muxes: make mux->attach/detach take a conn_stream endpoint

The mux ->detach() function currently takes a conn_stream. This causes
an awkward situation where the caller cs_detach_endp() has to partially
mark it as released but not completely so that ->detach() finds its
endpoint and context, and it cannot be done later since it's possible
that ->detach() deletes the endpoint. As such the endpoint link between
the conn_stream and the mux's stream is in a transient situation while
we'd like it to be clean so that the mux's ->detach() code can call any
regular function it wants that knows the regular semantics of the
relation between the CS and the endpoint.

A better approach consists in slightly modifying the detach() API to
better match the reality, which is that the endpoint is detached but
still alive and that it's the only part the function is interested in.

As such, this patch modifies the function to take an endpoint there,
and by analogy (or simplicity) does the same for ->attach(), even
though it looks less important there since we're always attaching an
endpoint to a conn_stream anyway. It is possible that in the future
the API could evolve to use more endpoints that provide a bit more
flexibility in the API, but at this point we don't need to go further.

3 years agoMINOR: mux-pt: remove the now unneeded conn_stream from the context
Willy Tarreau [Tue, 10 May 2022 17:23:39 +0000 (19:23 +0200)] 
MINOR: mux-pt: remove the now unneeded conn_stream from the context

Since we always have a valid endpoint we can safely use it to access
the conn_stream and stop using ctx->cs. That's one less pointer to
care about.

3 years agoMINOR: mux-quic: remove the now unneeded conn_stream from the qcs
Willy Tarreau [Tue, 10 May 2022 13:46:10 +0000 (15:46 +0200)] 
MINOR: mux-quic: remove the now unneeded conn_stream from the qcs

Since we always have a valid endpoint we can safely use it to access
the conn_stream and stop using qcs->cs. That's one less pointer to
care about.

3 years agoMINOR: mux-fcgi: remove the now unneeded conn_stream from the fcgi_strm
Willy Tarreau [Tue, 10 May 2022 13:30:53 +0000 (15:30 +0200)] 
MINOR: mux-fcgi: remove the now unneeded conn_stream from the fcgi_strm

Since we always have a valid endpoint we can safely use it to access
the conn_stream and stop using fstrm->cs. That's one less pointer to
care about.

3 years agoMINOR: mux-fcgi: make sure any stream always has an endpoint
Willy Tarreau [Tue, 10 May 2022 13:02:32 +0000 (15:02 +0200)] 
MINOR: mux-fcgi: make sure any stream always has an endpoint

The principle that each mux stream should have an endpoint is not
guaranteed for closed streams that map to the dummy static streams.
Let's have a dummy endpoint for use with such streams. It only has
the DETACHED flag and a NULL conn_stream, and is referenced by all
the closed streams so that we can afford not to test strm->endp when
trying to access the flags or the CS.

3 years agoMINOR: mux-h2: remove the now unneeded conn_stream from the h2s
Willy Tarreau [Tue, 10 May 2022 13:00:03 +0000 (15:00 +0200)] 
MINOR: mux-h2: remove the now unneeded conn_stream from the h2s

Since we always have a valid endpoint we can safely use it to access
the conn_stream and stop using h2s->cs. That's one less pointer to
care about.

3 years agoMINOR: mux-h2: make sure any h2s always has an endpoint
Willy Tarreau [Tue, 10 May 2022 12:57:16 +0000 (14:57 +0200)] 
MINOR: mux-h2: make sure any h2s always has an endpoint

The principle that each mux stream should have an endpoint is not
guaranteed for closed streams that map to the dummy static streams.
Let's have a dummy endpoint for use with such streams. It only has
the DETACHED flag and a NULL conn_stream, and is referenced by all
the closed streams so that we can afford not to test h2s->endp when
trying to access the flags or the CS.

3 years agoMINOR: mux-h1: remove the now unneeded h1s->cs
Willy Tarreau [Tue, 10 May 2022 08:25:41 +0000 (10:25 +0200)] 
MINOR: mux-h1: remove the now unneeded h1s->cs

There is always an endpoint link in a stream, and this endpoint link
contains a pointer to the conn_stream it's attached to, so the one in
the h1 stream is always duplicate now. Let's always use endp->cs
instead and get rid of it.

3 years agoMINOR: conn_stream: add a pointer back to the cs from the endpoint
Willy Tarreau [Tue, 10 May 2022 07:04:18 +0000 (09:04 +0200)] 
MINOR: conn_stream: add a pointer back to the cs from the endpoint

Muxes and applets need to have both a pointer to the endpoint and to the
conn_stream. It would seem more natural that they only have a pointer to
the endpoint (that is always there) and that this one has an optional
pointer to the conn_stream. This would reduce the number of elements to
manipulate in lower level code. In addition, the conn_stream is not much
used from the lower layers (wake and exceptional events mostly).

3 years agoCLEANUP: applet: use the appctx's endp instead of cs->endp
Willy Tarreau [Tue, 10 May 2022 09:32:31 +0000 (11:32 +0200)] 
CLEANUP: applet: use the appctx's endp instead of cs->endp

The few applets that set CS_EP_EOI or CS_EP_ERROR used to set it on the
endpoint retrieved from the conn_stream while it's already available on
the appctx itself. Better use the appctx one to limit the unneeded
interactions between the two sides.

3 years agoCLEANUP: mux-quic: always take the endp from the qcs not the cs
Willy Tarreau [Tue, 10 May 2022 09:24:26 +0000 (11:24 +0200)] 
CLEANUP: mux-quic: always take the endp from the qcs not the cs

At a few places the endpoint pointer was retrieved from the conn_stream
while it's safer and more long-term proof to take it from the qcs. Let's
just do that.

3 years agoCLEANUP: mux-fcgi: always take the endp from the fstrm not the cs
Willy Tarreau [Tue, 10 May 2022 09:22:50 +0000 (11:22 +0200)] 
CLEANUP: mux-fcgi: always take the endp from the fstrm not the cs

At a few places the endpoint pointer was retrieved from the conn_stream
while it's safer and more long-term proof to take it from the fstrm.
Let's just do that.

3 years agoCLEANUP: mux-pt: always take the endp from the context not the cs
Willy Tarreau [Tue, 10 May 2022 09:21:15 +0000 (11:21 +0200)] 
CLEANUP: mux-pt: always take the endp from the context not the cs

At a few places the endpoint pointer was retrieved from the conn_stream
while it's safer and more long-term proof to take it from the context.
Let's just do that.

3 years agoCLEANUP: mux-h2: always take the endp from the h2s not the cs
Willy Tarreau [Tue, 10 May 2022 08:31:08 +0000 (10:31 +0200)] 
CLEANUP: mux-h2: always take the endp from the h2s not the cs

At a few places the endpoint pointer was retrieved from the conn_stream
while it's safer and more long-term proof to take it from the h2s. Let's
just do that.

3 years agoCLEANUP: mux-h1: always take the endp from the h1s not the cs
Willy Tarreau [Tue, 10 May 2022 08:27:08 +0000 (10:27 +0200)] 
CLEANUP: mux-h1: always take the endp from the h1s not the cs

At a few places the endpoint pointer was retrieved from the conn_stream
while it's safer and more long-term proof to take it from the h1s. Let's
just do that.

3 years agoMINOR: conn_stream: make cs_set_error() work on the endpoint instead
Willy Tarreau [Tue, 10 May 2022 06:46:07 +0000 (08:46 +0200)] 
MINOR: conn_stream: make cs_set_error() work on the endpoint instead

Wherever we need to report an error, we have an even easier access to
the endpoint than the conn_stream. Let's first adjust the API to use
the endpoint and rename the function accordingly to cs_ep_set_error().

3 years agoCLEANUP: mux-h1: Fix comments and error messages for global options
Christopher Faulet [Fri, 13 May 2022 07:27:13 +0000 (09:27 +0200)] 
CLEANUP: mux-h1: Fix comments and error messages for global options

Wrong name was used in comments and error messages for
"h1-header-case-adjust" and "h1-headers-case-adjust-file" global options.

3 years agoMINOR: mux-h1: Add global option accpet payload for any HTTP/1.0 requests
Christopher Faulet [Fri, 13 May 2022 07:20:13 +0000 (09:20 +0200)] 
MINOR: mux-h1: Add global option accpet payload for any HTTP/1.0 requests

Since the 2.5, for security reason, HTTP/1.0 GET/HEAD/DELETE requests with a
payload are rejected (See e136bd12a "MEDIUM: mux-h1: Reject HTTP/1.0
GET/HEAD/DELETE requests with a payload" for details). However it may be an
issue for old clients.

To avoid any compatibility issue with such clients,
"h1-accept-payload-with-any-method" global option was added. It must only be
set if there is a good reason to do so because it may lead to a request
smuggling attack on some servers or intermediaries.

This patch should solve the issue #1691. it may be backported to 2.5.

3 years agoBUG/MEDIUM: wdt: don't trigger the watchdog when p is unitialized
William Lallemand [Fri, 13 May 2022 09:03:39 +0000 (11:03 +0200)] 
BUG/MEDIUM: wdt: don't trigger the watchdog when p is unitialized

In wdt_handler(), does not try to trigger the watchdog if the
prev_cpu_time wasn't initialized.

This prevents an unexpected trigger of the watchdog when it wasn't
initialized yet. This case could happen in the master just after loading
the configuration. This would show a trace where the <diff> value is equal
to the <now> value in the trace, and the <poll> value would be 0.

For example:

    Thread 1 is about to kill the process.
    *>Thread 1 : id=0x0 act=1 glob=1 wq=0 rq=0 tl=0 tlsz=0 rqsz=0
                  stuck=1 prof=0 harmless=0 wantrdv=0
                  cpu_ns: poll=0 now=6005541706 diff=6005541706
                  curr_task=0

Thanks to Christian Ruppert for repporting the problem.

Could be backported in every stable versions.

3 years agoDOC/MINOR: fix typos in the lua-api document
Boyang Li [Tue, 10 May 2022 18:11:00 +0000 (18:11 +0000)] 
DOC/MINOR: fix typos in the lua-api document

Fixes a few typos in the Lua API document.

3 years agoBUG/MEDIUM: lua: fix argument handling in data removal functions
Boyang Li [Tue, 10 May 2022 17:47:23 +0000 (17:47 +0000)] 
BUG/MEDIUM: lua: fix argument handling in data removal functions

Lua API Channel.remove() and HTTPMessage.remove() expects 1 to 3
arguments (counting the manipulated object), with offset and length
being the 2nd and 3rd argument, respectively.

hlua_{channel,http_msg}_del_data() incorrectly gets the 3rd argument as
offset, and 4th (nonexistent) as length. hlua_http_msg_del_data() also
improperly checks arguments. This patch fixes argument handling in both.

Must be backported to 2.5.

3 years agoMINOR: ncbuf: write unit tests
Amaury Denoyelle [Wed, 4 May 2022 14:51:19 +0000 (16:51 +0200)] 
MINOR: ncbuf: write unit tests

Implement a series of unit test to validate ncbuf. This is written with
a main function which can be compiled independently using the following
command-line :
 $ gcc -DSTANDALONE -lasan -I./include -o ncbuf src/ncbuf.c

The first part tests is used to test ncb_add()/ncb_advance(). After each
call a loop is done on the buffer blocks which should ensure that the
gap infos are correct.

The second part generates random offsets and insert them until the
buffer is full. The buffer is then resetted and all random offsets are
re-inserted in the reverse order : the buffer should be full once again.

The generated binary takes arguments to change the tests execution.
 "usage: ncbuf [-r] [-s bufsize] [-h bufhead] [-p <delay_msec>]"

3 years agoMINOR: ncbuf: implement advance
Amaury Denoyelle [Wed, 4 May 2022 14:47:09 +0000 (16:47 +0200)] 
MINOR: ncbuf: implement advance

A new function ncb_advance() is implemented. This is used to advance the
buffer head pointer. This will consume the front data while forming a
new gap at the end for future data.

On success NCB_RET_OK is returned. The operation can be rejected if a
too small new gap is formed in front of the buffer.

3 years agoMINOR: ncbuf: define various insertion modes
Amaury Denoyelle [Mon, 9 May 2022 09:59:15 +0000 (11:59 +0200)] 
MINOR: ncbuf: define various insertion modes

Define three different ways to proceed insertion. This configures how
overlapping data is treated.
- NCB_ADD_PRESERVE : in this mode, old data are kept during insertion.
- NCB_ADD_OVERWRT : new data will overwrite old ones.
- NCB_ADD_COMPARE : this mode adds a new test in check stage. The
  overlapping old and new data must be identical or else the insertion
  is not conducted. An error NCB_RET_DATA_REJ is used in this case.

The mode is specified with a new argument to ncb_add() function.

3 years agoMINOR: ncbuf: implement insertion
Amaury Denoyelle [Mon, 9 May 2022 07:43:11 +0000 (09:43 +0200)] 
MINOR: ncbuf: implement insertion

Implement a new function ncb_add() to insert data in ncbuf. This
operation is conducted in two stages. First, a simulation will be run to
ensure that insertion can be proceeded. If a gap is formed, either
before or after the new data, it must be big enough to store its header,
or else the insertion is aborted.

After this check stage, the insertion is conducted block by block with
the function pair ncb_fill_data_blk()/ncb_fill_gap_blk().

A new type ncb_ret is used as a return value. For the moment, only
success or gap-size error is used. It is planned to add new error types
in the future when insertion will be extended.

3 years agoMINOR: ncbuf: optimize storage for the last gap
Amaury Denoyelle [Wed, 4 May 2022 14:16:39 +0000 (16:16 +0200)] 
MINOR: ncbuf: optimize storage for the last gap

Relax the constraint for gap storage when this is the last block.
ncb_blk API functions will consider that if a gap is stored near the end
of the buffer, without the space to store its header, the gap will cover
entirely the buffer end.

For these special cases, the gap size/data size are not write/read
inside the gap to prevent an overflow. Such a gap is designed in
functions as "reduced gap" and will be flagged with the value
NCB_BK_F_FIN.

This should reduce the rejection on future add operation when receiving
data in-order. Without reduced gap handling, an insertion would be
rejected if it covers only partially the last buffer bytes, which can be
a very common case.

3 years agoMINOR: ncbuf: complete API and define block interal abstraction
Amaury Denoyelle [Mon, 9 May 2022 07:38:45 +0000 (09:38 +0200)] 
MINOR: ncbuf: complete API and define block interal abstraction

Implement two new functions to report the total data stored accross the
whole buffer and the data stored at a specific offset until the next gap
or the buffer end.

To facilitate implementation of these new functions and also future
add/delete operations, a new abstraction is introduced : ncb_blk. This
structure represents a block of either data or gap in the buffer. It
simplifies operation when moving forward in the buffer. The first buffer
block can be retrieved via ncb_blk_first(buf). The block at a specific
offset is accessed via ncb_blk_find(buf, off).

This abstraction is purely used in functions but not stored in the ncbuf
structure per-se. This is necessary to keep the minimal memory
footprint.

3 years agoMINOR: ncbuf: define non-contiguous buffer
Amaury Denoyelle [Mon, 9 May 2022 07:37:27 +0000 (09:37 +0200)] 
MINOR: ncbuf: define non-contiguous buffer

Define the new type ncbuf. It can be used as a buffer with
non-contiguous data and wrapping support.

To reduce as much as possible the memory footprint, size of data and
gaps are stored in the gaps themselves. This put some limitation on the
buffer usage. A reserved space is present just before the head to store
the size of the first data block. Also, add and delete operations will
be constrained to ensure minimal gap sizes are preserved.

The sizes stored in the gaps are represented by a custom type named
ncb_sz_t. This type is a typedef to easily change it : this has a
direct impact on the maximum buffer size (MAX(ncb_sz_t) - sizeof(ncb_sz_t))
and the minimal gap sizes (sizeof(ncb_sz_t) * 2)).
Currently, it is set to uint32_t.

3 years agoCLEANUP: quic_tls: QUIC_TLS_IV_LEN defined two times
Frédéric Lécaille [Wed, 11 May 2022 08:56:07 +0000 (10:56 +0200)] 
CLEANUP: quic_tls: QUIC_TLS_IV_LEN defined two times

Hopefully with the same value!

3 years agoCLEANUP: quic: Useless use of pointer for quic_hkdf_extract()
Frédéric Lécaille [Tue, 10 May 2022 16:40:19 +0000 (18:40 +0200)] 
CLEANUP: quic: Useless use of pointer for quic_hkdf_extract()

There is no need to use a pointer to the output buffer length.

3 years agoCLEANUP: quic: wrong use of eb*entry() macro
Frédéric Lécaille [Tue, 10 May 2022 13:15:24 +0000 (15:15 +0200)] 
CLEANUP: quic: wrong use of eb*entry() macro

This wrong use has no consequence because the ->node member fields of
eb*node structs are the first.

3 years agoMINOR: quic: Short packets always embed a trailing AEAD TAG
Frédéric Lécaille [Mon, 9 May 2022 16:08:13 +0000 (18:08 +0200)] 
MINOR: quic: Short packets always embed a trailing AEAD TAG

We must drop as soon as possible too small 1-RTT packets to be valid QUIC
packets to avoid replying with stateless reset packets.

3 years agoMINOR: quic: Send stateless reset tokens
Frédéric Lécaille [Mon, 9 May 2022 14:30:55 +0000 (16:30 +0200)] 
MINOR: quic: Send stateless reset tokens

Add send_stateless_reset() to send a stateless reset packet. It prepares
a packet to build a 1-RTT packet with quic_stateless_reset_token_cpy()
to copy a stateless reset token derived from the cluster secret with
the destination connection ID received as salt.
Also add QUIC_EV_STATELESS_RST new trace event to at least to have a trace
of the connection which are reset.

3 years agoMINOR: quic: Stateless reset token copy to transport parameters
Frédéric Lécaille [Mon, 9 May 2022 14:22:29 +0000 (16:22 +0200)] 
MINOR: quic: Stateless reset token copy to transport parameters

A server may send the stateless reset token associated to the current
connection from its transport parameters. So, let's copy it from
qc_lstnt_params_init().

3 years agoMINOR: qc_new_conn() rework for stateless reset
Frédéric Lécaille [Mon, 9 May 2022 13:42:26 +0000 (15:42 +0200)] 
MINOR: qc_new_conn() rework for stateless reset

The stateless reset token of a connection is generated from qc_new_conn() when
allocating the first connection ID. A QUIC server can copy it into its transport
parameters to allow the peer to reset the associated connection.
This latter is not easily reachable after having returned from qc_new_conn().
We want to be able to initialize the transport parameters from this function which
has an access to all the information to do so.

Extract the code used to initialize the transport parameters from qc_lstnr_pkt_rcv()
and make it callable from qc_new_conn(). qc_lstnr_params_init() is implemented
to accomplish this task for a haproxy listener.
Modify qc_new_conn() to reduce its the number of parameters.
The source address coming from Initial packets is also copied from qc_new_conn().

3 years agoMINOR: quic: Initialize stateless reset tokens with HKDF secrets
Frédéric Lécaille [Fri, 6 May 2022 13:07:20 +0000 (15:07 +0200)] 
MINOR: quic: Initialize stateless reset tokens with HKDF secrets

Add quic_stateless_reset_token_init() wrapper function around
quic_hkdf_extract_and_expand() function to derive the stateless reset tokens
attached to the connection IDs from "cluster-secret" configuration setting
and call it each time we instantiate a QUIC connection ID.

3 years agoMINOR: quic: new_quic_cid() code moving
Frédéric Lécaille [Fri, 6 May 2022 12:18:53 +0000 (14:18 +0200)] 
MINOR: quic: new_quic_cid() code moving

This function will have to call another one from quic_tls.[ch] soon.
As we do not want to include quic_tls.h from xprt_quic.h because
quic_tls.h already includes xprt_quic.h, let's moving it into
xprt_quic.c.

3 years agoMINOR: quic-tls: Add quic_hkdf_extract_and_expand() for HKDF
Frédéric Lécaille [Fri, 6 May 2022 07:54:48 +0000 (09:54 +0200)] 
MINOR: quic-tls: Add quic_hkdf_extract_and_expand() for HKDF

This is a wrapper function around OpenSSL HKDF API functions to
use the "extract-then-expand" HKDF mode as defined by rfc5869.
This function will be used to derived stateless reset tokens
from secrets ("cluster-secret" conf. keyword) and CIDs (as salts).

3 years agoMINOR: config: Add "cluster-secret" new global keyword
Frédéric Lécaille [Fri, 6 May 2022 06:53:16 +0000 (08:53 +0200)] 
MINOR: config: Add "cluster-secret" new global keyword

It could be usefull to set a ASCII secret which could be used for different
usages. For instance, it will be used to derive QUIC stateless reset tokens.

3 years agoMINOR: quic: Add correct ack delay values to ACK frames
Frédéric Lécaille [Thu, 5 May 2022 10:04:28 +0000 (12:04 +0200)] 
MINOR: quic: Add correct ack delay values to ACK frames

A ->time_received new member is added to quic_rx_packet to store the time the
packet are received. ->largest_time_received is added the the packet number
space structure to store this timestamp for the packet with a new largest
packet number to be acknowledged. QUIC_FL_PKTNS_NEW_LARGEST_PN new flag is
added to mark a packet number space as having to acknowledged a packet wih a
new largest packet number. In this case, the packet number space ack delay
must be recalculated.
Add quic_compute_ack_delay_us() function to compute the ack delay from the value
of the time a packet was received. Used only when a packet with a new largest
packet number.

3 years agoMINOR: quic: Congestion controller event trace fix (loss)
Frédéric Lécaille [Wed, 4 May 2022 13:24:50 +0000 (15:24 +0200)] 
MINOR: quic: Congestion controller event trace fix (loss)

Missing event type (loss).

3 years agoBUG/MINOR: quic: Wrong unit for ack delay for incoming ACK frames
Frédéric Lécaille [Tue, 3 May 2022 14:09:08 +0000 (16:09 +0200)] 
BUG/MINOR: quic: Wrong unit for ack delay for incoming ACK frames

This ACK frame field value is in microseconds. Everything is interpreted
and stored in milliseconds in our QUIC implementation.

3 years agoBUG/MINOR: quic: Dropped peer transport parameters
Frédéric Lécaille [Tue, 3 May 2022 13:55:17 +0000 (15:55 +0200)] 
BUG/MINOR: quic: Dropped peer transport parameters

The call to quic_dflt_transport_params_cpy() is already first done by
quic_transport_params_init() which is a good thing. But this function was also
called each time we parsed a transport parameters with quic_transport_param_decode(),
re-initializing to default values some of them. The transport parameters concerned
by this bug are the following:
   - max_udp_payload_size
   - ack_delay_exponent
   - max_ack_delay
   - active_connection_id_limit
So, let's remove this call to quic_dflt_transport_params_cpy() which has nothing
to do here!

3 years agoMINOR: quic: Add a debug counter for sendto() errors
Frédéric Lécaille [Tue, 3 May 2022 08:32:21 +0000 (10:32 +0200)] 
MINOR: quic: Add a debug counter for sendto() errors

As we do not have any task to be wake up by the poller after sendto() error,
we add an sendto() error counter to the quic_conn struct.
Dump its values from qc_send_ppkts().

3 years agoDOC: configuration: add the httpclient keywords to the global keywords index
William Lallemand [Thu, 12 May 2022 08:51:15 +0000 (10:51 +0200)] 
DOC: configuration: add the httpclient keywords to the global keywords index

    - httpclient.ssl.verify
    - httpclient.ssl.ca-file
    - httpclient.resolvers.id
    - httpclient.resolvers.prefer

3 years agoMINOR: mux-h2: report a trace event when failing to create a new stream
Willy Tarreau [Thu, 12 May 2022 07:24:41 +0000 (09:24 +0200)] 
MINOR: mux-h2: report a trace event when failing to create a new stream

There are two reasons we can reject the creation of an h2 stream on the
frontend:
  - its creation would violate the MAX_CONCURRENT_STREAMS setting
  - there's no more memory available

And on the backend it's almost the same except that the setting might
have be negotiated after trying to set up the stream.

Let's add traces for such a sitaution so that it's possible to know why
the stream was rejected (currently we only know it was rejected).

It could be nice to backport this to the most recent versions.

3 years agoBUG/MINOR: mux-h2: mark the stream as open before processing it not after
Willy Tarreau [Thu, 12 May 2022 07:08:51 +0000 (09:08 +0200)] 
BUG/MINOR: mux-h2: mark the stream as open before processing it not after

When a client doesn't respect the h2 MAX_CONCURRENT_STREAMS setting, we
rightfully send RST_STREAM to it so that the client closes. But the
max_id is only updated on the successful path of h2c_handle_stream_new(),
which may be reentered for partial frames or CONTINUATION frames, and as
a result we don't increment it if an extraneous stream ID is rejected.

Normally it doesn't have any consequence. But on a POST it can have some
if the DATA frame immediately follows the faulty HEADERS frame: with
max_id not incremented, the stream remains in IDLE state, and the DATA
frame now lands in an invalid state from a protocol's perspective, which
must lead to a connection error instead of a stream error.

This can be tested by modifying the code to send an arbitrarily large
MAX_CONCURRENT_STREAM setting and using h2load to send more concurrent
streams than configured: with a GET, only a tiny fraction of them will
report an error (e.g. 101 streams for 100 accepted will result in ~1%
failure), but when sending data, most of the streams will be reported
as failed because the connection will be closed. By updating the max_id
earlier, the stream is now considered as closed when the DATA frame
arrives and it's silently discarded.

This must be backported to all versions but only if the code is exactly
the same. Under no circumstance this ID may be updated for a partial frame
(i.e. only update it before or just after calling h2c_frt_steam_new()).

3 years agoBUG/MAJOR: dns: multi-thread concurrency issue on UDP socket
Emeric Brun [Tue, 10 May 2022 09:35:48 +0000 (11:35 +0200)] 
BUG/MAJOR: dns: multi-thread concurrency issue on UDP socket

This patch adds a lock on the struct dgram_conn to ensure
that an other thread cannot trash a fd or alter its status
while the current thread processing it on for send/receive/connect
operations.

Starting with the 2.4 version this could cause a crash when a DNS
request is failing, setting the FD of the dgram structure to -1. If the
dgram structure is reused after that, a read access to fdtab[-1] is
attempted. The crash was only triggered when compiled with ASAN.

In previous versions the concurrency issue also exists but is less
likely to crash.

This patch must be backported until v2.4 and should be
adapt for v < 2.4.

3 years agoBUG/MINOR: server: Make SRV_STATE_LINE_MAXLEN value from 512 to 2kB (2000 bytes).
vigneshsp [Mon, 9 May 2022 17:06:39 +0000 (22:36 +0530)] 
BUG/MINOR: server: Make SRV_STATE_LINE_MAXLEN value from 512 to 2kB (2000 bytes).

The statefile before this patch can only parse lines within 512
characters, now as we made the value to 2000, it can support a
line of length of 2kB.

This patch fixes GitHub issue #1530.
It should be backported to all stable releases.

3 years agoBUILD: makefile: add -Wfatal-errors to the default flags
Willy Tarreau [Wed, 11 May 2022 09:32:41 +0000 (11:32 +0200)] 
BUILD: makefile: add -Wfatal-errors to the default flags

Some error reports are misleading on some recent versions of gcc because
it goes on to build for a very long time after it meets an error. Not
only this makes it hard to scroll back to the beginning of the error,
but it also hides the cause of the error when it's prominently printed
in a "#error" statement. This typically happens when building with QUIC
and without OPENSSL where there can be 4 pages of unknown types and such
errors after the "Must define USE_OPENSSL" suggestion.

The flag -Wfatal-errors serves exactly this purpose, to stop after the
first error, and it's supported on all the compilers we support, so let's
enable this now.

3 years agoDOC: install: update gcc version requirements
Willy Tarreau [Wed, 11 May 2022 09:29:54 +0000 (11:29 +0200)] 
DOC: install: update gcc version requirements

It turns out that gcc-3.4 doesn't build anymore (and it has probably been
the case since 2.4 or so). gcc-4.2 does build fine though, let's mark it
as the oldest supported one. Now that gcc-12 works, also update the most
recently known-to-work version.

3 years agoBUG/MEDIUM: ssl: fix the gcc-12 broken fix :-(
Willy Tarreau [Mon, 9 May 2022 19:14:04 +0000 (21:14 +0200)] 
BUG/MEDIUM: ssl: fix the gcc-12 broken fix :-(

... or how a bogus warning forces you to do tricky changes in your code
and fail on a length test condition! Fortunately it changed in the right
direction that immediately broke, due to a missing "> sizeof(path)" that
had to be added to the already ugly condition.

This fixes recent commit 393e42ae5 ("BUILD: ssl: work around bogus warning
in gcc 12's -Wformat-truncation"). It may have to be backported if that
one is backported.