]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
4 weeks agoMINOR: quic-be: Make the secret derivation works for QUIC backends (USE_QUIC_OPENSSL_...
Frederic Lecaille [Wed, 28 May 2025 14:30:41 +0000 (16:30 +0200)] 
MINOR: quic-be: Make the secret derivation works for QUIC backends (USE_QUIC_OPENSSL_COMPAT)

quic_tls_compat_keylog_callback() is the callback used by the QUIC OpenSSL
compatibility module to derive the TLS secrets from other secrets provided
by keylog. The <write> local variable to this function is initialized to denote
the direction (write to send, read to receive) the secret is supposed to be used
for. That said, as the QUIC cryptographic algorithms are symmetrical, the
direction is inversed between the peer: a secret which is used to write/send/cipher
data from a peer point of view is also the secret which is used to
read/receive/decipher data. This was confirmed by the fact that without this
patch, the TLS stack first provides the peer with Handshake to send/cipher
data. The client could not use such secret to decipher the Handshake packets
received from the server. This patch simply reverse the direction stored by
<write> variable to make the secrets derivation works for the QUIC client.

4 weeks agoMINOR: quic-be: Missing callbacks initializations (USE_QUIC_OPENSSL_COMPAT)
Frederic Lecaille [Wed, 28 May 2025 13:58:44 +0000 (15:58 +0200)] 
MINOR: quic-be: Missing callbacks initializations (USE_QUIC_OPENSSL_COMPAT)

quic_tls_compat_init() function is called from OpenSSL QUIC compatibility module
(USE_QUIC_OPENSSL_COMPAT) to initialize the keylog callback and the callback
which stores the QUIC transport parameters as a TLS extensions into the stack.
These callbacks must also be initialized for QUIC backends.

4 weeks agoMINOR: quic-be: Store the remote transport parameters asap
Frederic Lecaille [Wed, 17 Jan 2024 14:30:04 +0000 (15:30 +0100)] 
MINOR: quic-be: Store the remote transport parameters asap

This is done from TLS secrets derivation callback at Application level (the last
encryption level) calling SSL_get_peer_quic_transport_params() to have an access
to the TLS transport paremeters extension embedded into the Server Hello TLS message.
Then, quic_transport_params_store() is called to store a decoded version of
these transport parameters.

4 weeks agoMINOR: quic-be: I/O handler switch adaptation
Frederic Lecaille [Tue, 16 Jan 2024 09:30:13 +0000 (10:30 +0100)] 
MINOR: quic-be: I/O handler switch adaptation

For connection to QUIC servers, this patch modifies the moment where the I/O
handler callback is switched to quic_conn_app_io_cb(). This is no more
done as for listener just after the handshake has completed but just after
it has been confirmed.

4 weeks agoMINOR: quic-be: Initial packet number space discarding.
Frederic Lecaille [Fri, 12 Jan 2024 16:03:02 +0000 (17:03 +0100)] 
MINOR: quic-be: Initial packet number space discarding.

Discard the Initial packet number space as soon as possible. This is done
during handshakes in quic_conn_io_cb() as soon as an Handshake packet could
be successfully sent.

4 weeks agoMINOR: quic-be: Add the conn object to the server SSL context
Frederic Lecaille [Tue, 27 May 2025 09:29:30 +0000 (11:29 +0200)] 
MINOR: quic-be: Add the conn object to the server SSL context

The initialization of <ssl_app_data_index> SSL user data index is required
to make all the SSL sessions to QUIC servers work as this is done for TCP
servers. The conn object notably retrieve for SSL callback which are
server specific (e.g. ssl_sess_new_srv_cb()).

4 weeks agoMINOR: quic-be: Build post handshake frames
Frederic Lecaille [Fri, 12 Jan 2024 15:23:55 +0000 (16:23 +0100)] 
MINOR: quic-be: Build post handshake frames

This action is not specific to listeners. A QUIC client also have to send
NEW_CONNECTION_ID frames.

4 weeks agoMINOR: quic-be: Store asap the DCID
Frederic Lecaille [Fri, 12 Jan 2024 13:39:08 +0000 (14:39 +0100)] 
MINOR: quic-be: Store asap the DCID

Store the peer connection ID (SCID) as the connection DCID as soon as an Initial
packet is received.
Stop comparing the packet to QUIC_PACKET_TYPE_0RTT is already match as
QUIC_PACKET_TYPE_INITIAL.
A QUIC server must not send too short datagram with ack-eliciting packets inside.
This cannot be done from quic_rx_pkt_parse() because one does not know if
there is ack-eliciting frame into the Initial packets. If the packet must be
dropped, this is after having parsed it!

4 weeks agoMINOR: h3-be: Correctly retrieve h3 counters
Frederic Lecaille [Thu, 11 Jan 2024 18:17:56 +0000 (19:17 +0100)] 
MINOR: h3-be: Correctly retrieve h3 counters

This is done using qc_counters() function which supports also QUIC servers.

4 weeks agoMINOR: quic-be: Handshake packet number space discarding
Frederic Lecaille [Thu, 11 Jan 2024 18:12:20 +0000 (19:12 +0100)] 
MINOR: quic-be: Handshake packet number space discarding

This is done for QUIC clients (or haproxy QUIC servers) when the handshake is
confirmed.

4 weeks agoMINOR: quic-be: Datagrams and packet parsing support
Frederic Lecaille [Wed, 10 Jan 2024 15:48:51 +0000 (16:48 +0100)] 
MINOR: quic-be: Datagrams and packet parsing support

Modify quic_dgram_parse() to stop passing it a listener as third parameter.
In place the object type address of the connection socket owner is passed
to support the haproxy servers with QUIC as transport protocol.
qc_owner_obj_type() is implemented to return this address.
qc_counters() is also implemented to return the QUIC specific counters of
the proxy of owner of the connection.
quic_rx_pkt_parse() called by quic_dgram_parse() is also modify to use
the object type address used by this latter as last parameter. It is
also modified to send Retry packet only from listeners. A QUIC client
(connection to haproxy QUIC servers) must drop the Initial packets with
non null token length. It is also not supposed to receive O-RTT packets
which are dropped.

4 weeks agoMINOR: quic-be: Do not redispatch the datagrams
Frederic Lecaille [Wed, 10 Jan 2024 10:10:36 +0000 (11:10 +0100)] 
MINOR: quic-be: Do not redispatch the datagrams

The QUIC datagram redispatch is there to counter the race condition which
exists only for QUIC connections to listener where datagrams may arrive
on the wrong socket between the bind() and connect() calls.
Run this code part only for listeners.

4 weeks agoMINOR: quic-be: add field for max_udp_payload_size into quic_conn
Frederic Lecaille [Thu, 5 Jun 2025 12:58:50 +0000 (14:58 +0200)] 
MINOR: quic-be: add field for max_udp_payload_size into quic_conn

Add ->max_udp_payload_size new member to quic_conn struct.
Initialize it from qc_new_conn().
Adapt qc_snd_buf() to use it.

4 weeks agoMINOR: quic-be: xprt ->init() adapatations
Frederic Lecaille [Tue, 19 Dec 2023 06:58:48 +0000 (07:58 +0100)] 
MINOR: quic-be: xprt ->init() adapatations

Allocate a connection to connect to QUIC servers from qc_conn_init() which is the
->init() QUIC xprt callback.
Also initialize ->prepare_srv and ->destroy_srv callback as this done for TCP
servers.

4 weeks agoMINOR: quic-be: QUIC connection allocation adaptation (qc_new_conn())
Frederic Lecaille [Fri, 5 Jan 2024 15:32:42 +0000 (16:32 +0100)] 
MINOR: quic-be: QUIC connection allocation adaptation (qc_new_conn())

For haproxy QUIC servers (or QUIC clients), the peer is considered as validated.
This is a property which is more specific to QUIC servers (haproxy QUIC listeners).
No <odcid> is used for the QUIC client connection. It is used only on the QUIC server side.
The <token_odcid> is also not used on the QUIC client side. It must be embedded into
the transport parameters only on the QUIC server side.
The quic_conn is created before the socket allocation. So, the local address is
zeroed.
Initilize the transport parameter with qc_srv_params_init().
Stop hardcoding the <server> parameter passed value to qc_new_isecs() to correctly
initialize the Initial secrets.

4 weeks agoMINOR: quic-be: ->connect() protocol callback adaptations
Frederic Lecaille [Fri, 5 Jan 2024 15:23:33 +0000 (16:23 +0100)] 
MINOR: quic-be: ->connect() protocol callback adaptations

Modify quic_connect_server() which is the ->connect() callback for QUIC protocol:
    - add a BUG_ON() run when entering this funtion: the <fd> socket must equal -1
    - conn->handle is a union. conn->handle.qc is use for QUIC connection,
      conn->handle.fd must not be used to store the fd.
    - code alignment fix for setsockopt(fd, SOL_SOCKET, (SO_SNDBUF|SO_RCVBUF))
  statements
    - remove the section of code which was duplicated from ->connect() TCP callback
    - fd_insert() the new socket file decriptor created to connect to the QUIC
      server with quic_conn_sock_fd_iocb() as callback for read event.

4 weeks agoMINOR: sock: Add protocol and socket types parameters to sock_create_server_socket()
Frederic Lecaille [Tue, 3 Jun 2025 14:25:53 +0000 (16:25 +0200)] 
MINOR: sock: Add protocol and socket types parameters to sock_create_server_socket()

This patch only adds <proto_type> new proto_type enum parameter and <sock_type>
socket type parameter to sock_create_server_socket() and adapts its callers.
This is to prepare the use of this function by QUIC servers/backends.

4 weeks agoMINOR: quic-be: Add a function to initialize the QUIC client transport parameters
Frederic Lecaille [Wed, 3 Jan 2024 13:36:44 +0000 (14:36 +0100)] 
MINOR: quic-be: Add a function to initialize the QUIC client transport parameters

Implement qc_srv_params_init() to initialize the QUIC client transport parameters
in relation with connections to haproxy servers/backends.

4 weeks agoMINOR: quic-be: SSL sessions initializations
Frederic Lecaille [Tue, 19 Dec 2023 07:16:42 +0000 (08:16 +0100)] 
MINOR: quic-be: SSL sessions initializations

Modify qc_alloc_ssl_sock_ctx() to pass the connection object as parameter. It is
NULL for a QUIC listener, not NULL for a QUIC server. This connection object is
set as value for ->conn quic_conn struct member. Initialise the SSL session object from
this function for QUIC servers.
qc_ssl_set_quic_transport_params() is also modified to pass the SSL object as parameter.
This is the unique parameter this function needs. <qc> parameter is used only for
the trace.
SSL_do_handshake() must be calle as soon as the SSL object is initialized for
the QUIC backend connection. This triggers the TLS CRYPTO data delivery.
tasklet_wakeup() is also called to send asap these CRYPTO data.
Modify the QUIC_EV_CONN_NEW event trace to dump the potential errors returned by
SSL_do_handshake().

4 weeks agoMINOR: quic-be: ssl_sock contexts allocation and misc adaptations
Frederic Lecaille [Mon, 18 Dec 2023 16:26:01 +0000 (17:26 +0100)] 
MINOR: quic-be: ssl_sock contexts allocation and misc adaptations

Implement ssl_sock_new_ssl_ctx() to allocate a SSL server context as this is currently
done for TCP servers and also for QUIC servers depending on the <is_quic> boolean value
passed as new parameter. For QUIC servers, this function calls ssl_quic_srv_new_ssl_ctx()
which is specific to QUIC.

4 weeks agoMINOR: quic-be: Correct the QUIC protocol lookup
Frederic Lecaille [Mon, 18 Dec 2023 16:11:27 +0000 (17:11 +0100)] 
MINOR: quic-be: Correct the QUIC protocol lookup

From connect_server(), QUIC protocol could not be retreived by protocol_lookup()
because of the PROTO_TYPE_STREAM default passed as argument. In place to support
QUIC srv->addr_type.proto_type may be safely passed.

4 weeks agoMINOR: quic-be: Add a function for the TLS context allocations
Frederic Lecaille [Mon, 18 Dec 2023 16:06:40 +0000 (17:06 +0100)] 
MINOR: quic-be: Add a function for the TLS context allocations

Implement ssl_quic_srv_new_ssl_ctx() whose aim is to allocate a TLS context
for QUIC servers.

4 weeks agoMINOR: quic-be: QUIC server xprt already set when preparing their CTXs
Frederic Lecaille [Mon, 18 Dec 2023 13:25:53 +0000 (14:25 +0100)] 
MINOR: quic-be: QUIC server xprt already set when preparing their CTXs

The QUIC servers xprts have already been set at server line parsing time.
This patch prevents the QUIC servers xprts to be reset to <ssl_sock> value which is
the value used for SSL/TCP connections.

4 weeks agoMINOR: quic-be: QUIC backend XPRT and transport parameters init during parsing
Frederic Lecaille [Mon, 18 Dec 2023 10:18:45 +0000 (11:18 +0100)] 
MINOR: quic-be: QUIC backend XPRT and transport parameters init during parsing

Add ->quic_params new member to server struct.
Also set the ->xprt member of the server being initialized and initialize asap its
transport parameters from _srv_parse_init().

4 weeks agoMINOR: quic-be: Call ->prepare_srv() callback at parsing time
Frederic Lecaille [Mon, 18 Dec 2023 09:59:15 +0000 (10:59 +0100)] 
MINOR: quic-be: Call ->prepare_srv() callback at parsing time

This XPRT callback is called from check_config_validity() after the configuration
has been parsed to initialize all the SSL server contexts.

This patch implements the same thing for the QUIC servers.

4 weeks agoMINOR: quic-be: Version Information transport parameter check
Frederic Lecaille [Wed, 17 Jan 2024 17:14:44 +0000 (18:14 +0100)] 
MINOR: quic-be: Version Information transport parameter check

Add a little check to verify that the version chosen by the server matches
with the client one. Initiliazes local transport parameters ->negotiated_version
value with this version if this is the case. If not, return 0;

4 weeks agoMINOR: quic-be: Correct Version Information transp. param encoding
Frederic Lecaille [Wed, 17 Jan 2024 16:17:26 +0000 (17:17 +0100)] 
MINOR: quic-be: Correct Version Information transp. param encoding

According to the RFC, a QUIC client must encode the QUIC version it supports
into the "Available Versions" of "Version Information" transport parameter
order by descending preference.

This is done defining <quic_version_2> and <quic_version_draft_29> new variables
pointers to the corresponding version of <quic_versions> array elements.
A client announces its available versions as follows: v1, v2, draft29.

4 weeks agoMINOR: mux-quic-be: allow QUIC proto on backend side
Amaury Denoyelle [Wed, 11 Jun 2025 15:38:21 +0000 (17:38 +0200)] 
MINOR: mux-quic-be: allow QUIC proto on backend side

Activate QUIC protocol support for MUX-QUIC on the backend side,
additionally to current frontend support. This change is mandatory to be
able to implement QUIC on the backend side.

Without this modification, it is impossible to activate explicitely QUIC
protocol on a server line, hence an error is reported :
  config : proxy 'xxxx' : MUX protocol 'quic' is not usable for server 'yyyy'

4 weeks agoMINOR: server: mark QUIC support as experimental
Amaury Denoyelle [Wed, 11 Jun 2025 15:26:44 +0000 (17:26 +0200)] 
MINOR: server: mark QUIC support as experimental

Mark QUIC address support for servers as experimental on the backend
side. Previously, it was allowed but wouldn't function as expected. As
QUIC backend support requires several changes, it is better to declare
it as experimental first.

4 weeks agoMINOR: server: implement helper to identify QUIC servers
Amaury Denoyelle [Wed, 11 Jun 2025 15:28:46 +0000 (17:28 +0200)] 
MINOR: server: implement helper to identify QUIC servers

Define srv_is_quic() which can be used to quickly identified if a server
uses QUIC protocol.

4 weeks agoBUG/MINOR: config/server: reject QUIC addresses
Amaury Denoyelle [Wed, 11 Jun 2025 16:26:10 +0000 (18:26 +0200)] 
BUG/MINOR: config/server: reject QUIC addresses

QUIC is not implemented on the backend side. To prevent any issue, it is
better to reject any server configured which uses it. This is done via
_srv_parse_init() which is used both for static and dynamic servers.

This should be backported up to all stable versions.

4 weeks ago[RELEASE] Released version 3.3-dev1 v3.3-dev1
Christopher Faulet [Wed, 11 Jun 2025 12:31:33 +0000 (14:31 +0200)] 
[RELEASE] Released version 3.3-dev1

Released version 3.3-dev1 with the following main changes :
    - BUILD: tools: properly define ha_dump_backtrace() to avoid a build warning
    - DOC: config: Fix a typo in 2.7 (Name format for maps and ACLs)
    - REGTESTS: Do not use REQUIRE_VERSION for HAProxy 2.5+ (5)
    - REGTESTS: Remove REQUIRE_VERSION=2.3 from all tests
    - REGTESTS: Remove REQUIRE_VERSION=2.4 from all tests
    - REGTESTS: Remove tests with REQUIRE_VERSION_BELOW=2.4
    - REGTESTS: Remove support for REQUIRE_VERSION and REQUIRE_VERSION_BELOW
    - MINOR: server: group postinit server tasks under _srv_postparse()
    - MINOR: stats: add stat_col flags
    - MINOR: stats: add ME_NEW_COMMON() helper
    - MINOR: proxy: collect per-capability stat in proxy_cond_disable()
    - MINOR: proxy: add a true list containing all proxies
    - MINOR: log: only run postcheck_log_backend() checks on backend
    - MEDIUM: proxy: use global proxy list for REGISTER_POST_PROXY_CHECK() hook
    - MEDIUM: server: automatically add server to proxy list in new_server()
    - MEDIUM: server: add and use srv_init() function
    - BUG/MAJOR: leastconn: Protect tree_elt with the lbprm lock
    - BUG/MEDIUM: check: Requeue healthchecks on I/O events to handle check timeout
    - CLEANUP: applet: Update comment for applet_put* functions
    - DEBUG: check: Add the healthcheck's expiration date in the trace messags
    - BUG/MINOR: mux-spop: Fix null-pointer deref on SPOP stream allocation failure
    - CLEANUP: sink: remove useless cleanup in sink_new_from_logger()
    - MAJOR: counters: add shared counters base infrastructure
    - MINOR: counters: add shared counters helpers to get and drop shared pointers
    - MINOR: counters: add common struct and flags to {fe,be}_counters_shared
    - MEDIUM: counters: manage shared counters using dedicated helpers
    - CLEANUP: counters: merge some common counters between {fe,be}_counters_shared
    - MINOR: counters: add local-only internal rates to compute some maxes
    - MAJOR: counters: dispatch counters over thread groups
    - BUG/MEDIUM: cli: Properly parse empty lines and avoid crashed
    - BUG/MINOR: config: emit warning for empty args only in discovery mode
    - BUG/MINOR: config: fix arg number reported on empty arg warning
    - BUG/MINOR: quic: Missing SSL session object freeing
    - MINOR: applet: Add API functions to manipulate input and output buffers
    - MINOR: applet: Add API functions to get data from the input buffer
    - CLEANUP: applet: Simplify a bit comments for applet_put* functions
    - MEDIUM: hlua: Update TCP applet functions to use the new applet API
    - BUG/MEDIUM: fd: Use the provided tgid in fd_insert() to get tgroup_info
    - BUG/MINIR: h1: Fix doc of 'accept-unsafe-...-request' about URI parsing

4 weeks agoBUG/MINIR: h1: Fix doc of 'accept-unsafe-...-request' about URI parsing
Christopher Faulet [Tue, 10 Jun 2025 17:03:44 +0000 (19:03 +0200)] 
BUG/MINIR: h1: Fix doc of 'accept-unsafe-...-request' about URI parsing

The description of tests performed on the URI in H1 when
'accept-unsafe-violations-in-http-request' option is wrong. It states that
only characters below 32 and 127 are blocked when this option is set,
suggesting that otherwise, when it is not set, all invalid characters in the
URI, according to the RFC3986, are blocked.

But in fact, it is not true. By default all character below 32 and above 127
are blocked. And when 'accept-unsafe-violations-in-http-request' option is
set, characters above 127 (excluded) are accepted. But characters in
(33..126) are never checked, independently of this option.

This patch should fix the issue #2906. It should be backported as far as
3.0. For older versions, the docuementation could also be clarified because
this part is not really clear.

Note the request URI validation is still under discution because invalid
characters in (33.126) are never checked and some users request a stricter
parsing.

4 weeks agoBUG/MEDIUM: fd: Use the provided tgid in fd_insert() to get tgroup_info
Olivier Houchard [Tue, 10 Jun 2025 12:39:22 +0000 (12:39 +0000)] 
BUG/MEDIUM: fd: Use the provided tgid in fd_insert() to get tgroup_info

In fd_insert(), use the provided tgid to ghet the thread group info,
instead of using the one of the current thread, as we may call
fd_insert() from a thread of another thread group, that will happen at
least when binding the listeners. Otherwise we'd end up accessing the
thread mask containing enabled thread of the wrong thread group, which
can lead to crashes if we're binding on threads not present in the
thread group.
This should fix Github issue #2991.

This should be backported up to 2.8.

4 weeks agoMEDIUM: hlua: Update TCP applet functions to use the new applet API
Christopher Faulet [Thu, 5 Jun 2025 13:45:42 +0000 (15:45 +0200)] 
MEDIUM: hlua: Update TCP applet functions to use the new applet API

The functions responsible to extract data from the applet input buffer or to
push data into the applet output buffer are now relying on the newly added
functions in the applet API. This simplifies a bit the code.

4 weeks agoCLEANUP: applet: Simplify a bit comments for applet_put* functions
Christopher Faulet [Thu, 5 Jun 2025 13:43:53 +0000 (15:43 +0200)] 
CLEANUP: applet: Simplify a bit comments for applet_put* functions

Instead of repeating which buffer is used depending on the API used by the
applet, a reference to applet_get_outbuf() was added.

4 weeks agoMINOR: applet: Add API functions to get data from the input buffer
Christopher Faulet [Thu, 5 Jun 2025 13:28:45 +0000 (15:28 +0200)] 
MINOR: applet: Add API functions to get data from the input buffer

There was already functions to pushed data from the applet to the stream by
inserting them in the right buffer, depending the applet was using or not
the legacy API. Here, functions to retreive data pushed to the applet by the
stream were added:

  * applet_getchar   : Gets one character

  * applet_getblk    : Copies a full block of data

  * applet_getword   : Copies one text block representing a word using a
                       custom separator as delimiter

  * applet_getline   : Copies one text line

  * applet_getblk_nc : Get one or two blocks of data

  * applet_getword_nc: Gets one or two blocks of text representing a word
                       using a custom separator as delimiter

  * applet_getline_nc: Gets one or two blocks of text representing a line

4 weeks agoMINOR: applet: Add API functions to manipulate input and output buffers
Christopher Faulet [Thu, 5 Jun 2025 13:01:43 +0000 (15:01 +0200)] 
MINOR: applet: Add API functions to manipulate input and output buffers

In this patch, some functions were added to ease input and output buffers
manipulation, regardless the corresponding applet is using its own buffers
or it is relying on channels buffers. Following functions were added:

  * applet_get_inbuf  : Get the buffer containing data pushed to the applet
                        by the stream

  * applet_get_outbuf : Get the buffer containing data pushed by the applet
                        to the stream

  * applet_input_data : Return the amount of data in the input buffer

  * applet_skip_input : Skips <len> bytes from the input buffer

  * applet_reset_input: Skips all bytes from the input buffer

  * applet_output_room: Returns the amout of space available at the output
                        buffer

  * applet_need_room  : Indicates that the applet have more data to deliver
                        and it needs more room in the output buffer to do
so

5 weeks agoBUG/MINOR: quic: Missing SSL session object freeing
Frederic Lecaille [Wed, 4 Jun 2025 09:49:14 +0000 (11:49 +0200)] 
BUG/MINOR: quic: Missing SSL session object freeing

qc_alloc_ssl_sock_ctx() allocates an SSL_CTX object for each connection. It also
allocates an SSL object. When this function failed, it freed only the SSL_CTX object.
The correct way to free both of them is to call qc_free_ssl_sock_ctx().

Must be backported as far as 2.6.

5 weeks agoBUG/MINOR: config: fix arg number reported on empty arg warning
Amaury Denoyelle [Wed, 4 Jun 2025 13:36:13 +0000 (15:36 +0200)] 
BUG/MINOR: config: fix arg number reported on empty arg warning

If an empty argument is used in configuration, for example due to an
undefined environment variable, the rest of the line is not parsed. As
such, a warning is emitted to report this.

The warning was not totally correct as it reported the wrong argument
index. Fix this by this patch. Note that there is still an issue with
the "^" indicator, but this is not as easy to fix yet.

This is related to github issue #2995.

This should be backported up to 3.2.

5 weeks agoBUG/MINOR: config: emit warning for empty args only in discovery mode
Amaury Denoyelle [Wed, 4 Jun 2025 09:26:27 +0000 (11:26 +0200)] 
BUG/MINOR: config: emit warning for empty args only in discovery mode

Hide warning about empty argument outside of discovery mode. This is
necessary, else the message will be displayed twice, which hampers
haproxy output lisibility.

This should fix github isue #2995.

This should be backported up to 3.2.

5 weeks agoBUG/MEDIUM: cli: Properly parse empty lines and avoid crashed
Christopher Faulet [Thu, 5 Jun 2025 08:41:46 +0000 (10:41 +0200)] 
BUG/MEDIUM: cli: Properly parse empty lines and avoid crashed

Empty lines was not properly parsed and could lead to crashes because the
last argument was parsed outside of the cmdline buffer. Indeed, the last
argument is parsed to look for an eventual payload pattern. It is started
one character after the newline at the end of the command line. But it is
only valid for an non-empty command line.

So, now, this case is properly detected when we leave if an empty line is
detected.

This patch must be backported to 3.2.

5 weeks agoMAJOR: counters: dispatch counters over thread groups
Aurelien DARRAGON [Thu, 15 May 2025 17:55:11 +0000 (19:55 +0200)] 
MAJOR: counters: dispatch counters over thread groups

Most fe and be counters are good candidates for being shared between
processes. They are now grouped inside "shared" struct sub member under
be_counters and fe_counters.

Now they are properly identified, they would greatly benefit from being
shared over thread groups to reduce the cost of atomic operations when
updating them. For this, we take the current tgid into account so each
thread group only updates its own counters. For this to work, it is
mandatory that the "shared" member from {fe,be}_counters is initialized
AFTER global.nbtgroups is known, because each shared counter causes the stat
to be allocated lobal.nbtgroups times. When updating a counter without
concurrency, the first counter from the array may be updated.

To consult the shared counters (which requires aggregation of per-tgid
individual counters), some helper functions were added to counter.h to
ease code maintenance and avoid computing errors.

5 weeks agoMINOR: counters: add local-only internal rates to compute some maxes
Aurelien DARRAGON [Wed, 28 May 2025 10:00:49 +0000 (12:00 +0200)] 
MINOR: counters: add local-only internal rates to compute some maxes

cps_max (max new connections received per second), sps_max (max new
sessions per second) and http.rps_max (maximum new http requests per
second) all rely on shared counters (namely conn_per_sec, sess_per_sec and
http.req_per_sec). The problem is that shared counters are about to be
distributed over thread groups, and we cannot afford to compute the
total (for all thread groups) each time we update the max counters.

Instead, since such max counters (relying on shared counters) are a very
few exceptions, let's add internal (sess,conn,req) per sec freq counters
that are dedicated to cps_max, sps_max and http.rps_max computing.

Thanks to that, related *_max counters shouldn't be negatively impacted
by the thread-group distribution, yet they will not benefit from it
either. Related internal freq counters are prefixed with "_" to emphasize
the fact that they should not be used for other purpose (the shared ones,
which are about to be distributed over thread groups in upcoming commits
are still available and must be used instead). The internal ones could
eventually be removed at any time if we find another way to compute the
{cps,sps,http.rps)_max counters.

5 weeks agoCLEANUP: counters: merge some common counters between {fe,be}_counters_shared
Aurelien DARRAGON [Fri, 9 May 2025 09:42:37 +0000 (11:42 +0200)] 
CLEANUP: counters: merge some common counters between {fe,be}_counters_shared

Now that we have a common struct between fe and be shared counters struct
let's perform some cleanup to merge duplicate members into the common
struct part. This will ease code maintenance.

5 weeks agoMEDIUM: counters: manage shared counters using dedicated helpers
Aurelien DARRAGON [Wed, 7 May 2025 21:42:04 +0000 (23:42 +0200)] 
MEDIUM: counters: manage shared counters using dedicated helpers

proxies, listeners and server shared counters are now managed via helpers
added in one of the previous commits.

When guid is not set (ie: when not yet assigned), shared counters pointer
is allocated using calloc() (local memory) and a flag is set on the shared
counters struct to know how to manipulate (and free it). Else if guid is
set, then it means that the counters may be shared so while for now we
don't actually use a shared memory location the API is ready for that.

The way it works, for proxies and servers (for which guid is not known
during creation), we first call counters_{fe,be}_shared_get with guid not
set, which results in local pointer being retrieved (as if we just
manually called calloc() to retrieve a pointer). Later (during postparsing)
if guid is set we try to upgrade the pointer from local to shared.

Lastly, since the memory location for some objects (proxies and servers
counters) may change from creation to postparsing, let's update
counters->last_change member directly under counters_{fe,be}_shared_get()
so we don't miss it.

No change of behavior is expected, this is only preparation work.

5 weeks agoMINOR: counters: add common struct and flags to {fe,be}_counters_shared
Aurelien DARRAGON [Fri, 9 May 2025 08:42:49 +0000 (10:42 +0200)] 
MINOR: counters: add common struct and flags to {fe,be}_counters_shared

fe_counters_shared and be_counters_shared may share some common members
since they are quite similar, so we add a common struct part shared
between the two. struct counters_shared is added for convenience as
a generic pointer to manipulate common members from fe or be shared
counters pointer.

Also, the first common member is added: shared fe and be counters now
have a flags member.

5 weeks agoMINOR: counters: add shared counters helpers to get and drop shared pointers
Aurelien DARRAGON [Tue, 6 May 2025 18:45:40 +0000 (20:45 +0200)] 
MINOR: counters: add shared counters helpers to get and drop shared pointers

create include/haproxy/counters.h and src/counters.c files to anticipate
for further helpers as some counters specific tasks needs to be carried
out and since counters are shared between multiple object types (ie:
listener, proxy, server..) we need generic helpers.

Add some shared counters helper which are not yet used but will be updated
in upcoming commits.

5 weeks agoMAJOR: counters: add shared counters base infrastructure
Aurelien DARRAGON [Tue, 8 Apr 2025 16:16:38 +0000 (18:16 +0200)] 
MAJOR: counters: add shared counters base infrastructure

Shareable counters are not tagged as shared counters and are dynamically
allocated in separate memory area as a prerequisite for being stored
in shared memory area. For now, GUID and threads groups are not taken into
account, this is only a first step.

also we ensure all counters are now manipulated using atomic operations,
namely, "last_change" counter is now read from and written to using atomic
ops.

Despite the numerous changes caused by the counters being moved away from
counters struct, no change of behavior should be expected.

5 weeks agoCLEANUP: sink: remove useless cleanup in sink_new_from_logger()
Aurelien DARRAGON [Wed, 4 Jun 2025 14:51:04 +0000 (16:51 +0200)] 
CLEANUP: sink: remove useless cleanup in sink_new_from_logger()

As reported by Ilya in GH #2994, some cleanup parts in
sink_new_from_logger() function are not used.

We can actually simplify the cleanup logic to remove dead code, let's
do that by renaming "error_final" label to "error" and only making use
of the "error" label, because sink_free() already takes care of proper
cleanup for all sink members.

5 weeks agoBUG/MINOR: mux-spop: Fix null-pointer deref on SPOP stream allocation failure
Christopher Faulet [Wed, 4 Jun 2025 06:48:48 +0000 (08:48 +0200)] 
BUG/MINOR: mux-spop: Fix null-pointer deref on SPOP stream allocation failure

When we try to allocate a new SPOP stream, if an error is encountered,
spop_strm_destroy() is called to released the eventually allocated
stream. But, it must only be called if a stream was allocated. If the
reported error is an SPOP stream allocation failure, we must just leave to
avoid null-pointer dereference.

This patch should fix point 1 of the issue #2993. It must be backported as
far as 3.1.

5 weeks agoDEBUG: check: Add the healthcheck's expiration date in the trace messags
Christopher Faulet [Tue, 3 Jun 2025 13:06:11 +0000 (15:06 +0200)] 
DEBUG: check: Add the healthcheck's expiration date in the trace messags

It could help to diagnose some issues about timeout processing. So let's add
it !

5 weeks agoCLEANUP: applet: Update comment for applet_put* functions
Christopher Faulet [Tue, 3 Jun 2025 09:06:09 +0000 (11:06 +0200)] 
CLEANUP: applet: Update comment for applet_put* functions

These functions were copied from the channel API and modified to work with
applets using the new API or the legacy one. However, the comments were
updated accordingly. It is the purpose of this patch.

5 weeks agoBUG/MEDIUM: check: Requeue healthchecks on I/O events to handle check timeout
Christopher Faulet [Tue, 3 Jun 2025 12:50:38 +0000 (14:50 +0200)] 
BUG/MEDIUM: check: Requeue healthchecks on I/O events to handle check timeout

When a healthchecks is processed, once the first wakeup passed to start the
check, and as long as the expiration timer is not reached, only I/O events
are able to wake it up. It is an issue when there is a check timeout
defined.  Especially if the connect timeout is high and the check timeout is
low. In that case, the healthcheck's task is never requeue to handle any
timeout update. When the connection is established, the check timeout is set
to replace the connect timeout. It is thus possible to report a success
while a timeout should be reported.

So, now, when an I/O event is handled, the healthcheck is requeue, except if
an success or an abort is reported.

Thanks to Thierry Fournier for report and the reproducer.

This patch must be backported to all stable versions.

5 weeks agoBUG/MAJOR: leastconn: Protect tree_elt with the lbprm lock
Olivier Houchard [Tue, 3 Jun 2025 02:37:26 +0000 (02:37 +0000)] 
BUG/MAJOR: leastconn: Protect tree_elt with the lbprm lock

In fwlc_srv_reposition(), set the server's tree_elt while we still hold
the lbprm read lock. While it was protected from concurrent
fwlc_srv_reposition() calls by the server's lb_lock, it was not from
dequeuing/requeuing that could occur if the server gets down/up or its
weight is changed, and that would lead to inconsistencies, and the
watchdog killing the process because it is stuck in an infinite loop in
fwlc_get_next_server().

This hopefully fixes github issue #2990.

This should be backported to 3.2.

5 weeks agoMEDIUM: server: add and use srv_init() function
Aurelien DARRAGON [Fri, 9 May 2025 18:27:29 +0000 (20:27 +0200)] 
MEDIUM: server: add and use srv_init() function

rename _srv_postparse() internal function to srv_init() function and group
srv_init_per_thr() plus idle conns list init inside it. This way we can
perform some simplifications as srv_init() performs multiple server
init steps after parsing.

SRV_F_CHECKED flag was added, it is automatically set when srv_init()
runs successfully. If the flag is already set and srv_init() is called
again, nothing is done. This permis to manually call srv_init() earlier
than the default POST_CHECK hook when needed without risking to do things
twice.

5 weeks agoMEDIUM: server: automatically add server to proxy list in new_server()
Aurelien DARRAGON [Fri, 9 May 2025 17:24:55 +0000 (19:24 +0200)] 
MEDIUM: server: automatically add server to proxy list in new_server()

while new_server() takes the parent proxy as argument and even assigns
srv->proxy to the parent proxy, it didn't actually inserted the server
to the parent proxy server list on success.

The result is that sometimes we add the server to the list after
new_server() is called, and sometimes we don't.

This is really error-prone and because of that hooks such as
REGISTER_POST_SERVER_CHECK() which as run for all servers listed in
all proxies may not be relied upon for servers which are not actually
inserted in their parent proxy server list. Plus it feels very strange
to have a server that points to a proxy, but then the proxy doesn't know
about it because it cannot find it in its server list.

To prevent errors and make proxy->srv list reliable, we move the insertion
logic directly under new_server(). This requires to know if we are called
during parsing or during runtime to either insert or append the server to
the parent proxy list. For that we use PR_FL_CHECKED flag from the parent
proxy (if the flag is set, then the proxy was checked so we are past the
init phase, thus we assume we are called during runtime)

This implies that during startup if new_server() has to be cancelled on
error paths we need to call srv_detach() (which is now exposed in server.h)
before srv_drop().

The consequence of this commit is that REGISTER_POST_SERVER_CHECK() should
not run reliably on all servers created using new_server() (without having
to manually loop on global servers_list)

5 weeks agoMEDIUM: proxy: use global proxy list for REGISTER_POST_PROXY_CHECK() hook
Aurelien DARRAGON [Fri, 9 May 2025 14:41:30 +0000 (16:41 +0200)] 
MEDIUM: proxy: use global proxy list for REGISTER_POST_PROXY_CHECK() hook

REGISTER_POST_PROXY_CHECK() used to iterate over "main" proxies to run
registered callbacks. This means hidden proxies (and their servers) did
not get a chance to get post-checked and could cause issues if some post-
checks are expected to be executed on all proxies no matter their type.

Instead we now rely on the global proxies list. Another side effect is that
the REGISTER_POST_SERVER_CHECK() now runs as well for servers from proxies
that are not part of the main proxies list.

5 weeks agoMINOR: log: only run postcheck_log_backend() checks on backend
Aurelien DARRAGON [Fri, 9 May 2025 14:34:27 +0000 (16:34 +0200)] 
MINOR: log: only run postcheck_log_backend() checks on backend

postcheck_log_backend() checks are executed no matter if the proxy
actually has the backend capability while the checks actually depend
on this.

Let's fix that by adding an extra condition to ensure that the BE
capability is set.

This issue is not tagged as a bug because for now it remains impossible
to have a syslog proxy without BE capability in the main proxy list, but
this may change in the future.

5 weeks agoMINOR: proxy: add a true list containing all proxies
Aurelien DARRAGON [Fri, 9 May 2025 14:02:09 +0000 (16:02 +0200)] 
MINOR: proxy: add a true list containing all proxies

We have global proxies_list pointer which is announced as the list of
"all existing proxies", but in fact it only represents regular proxies
declared on the config file through "listen, frontend or backend" keywords

It is ambiguous, and we currently don't have a straightforwrd method to
iterate over all proxies (either public or internal ones) within haproxy

Instead we still have to manually iterate over multiple lists (main
proxies, log-forward proxies, peer proxies..) which is error-prone.

In this patch we add a struct list member (8 bytes) inside struct proxy
in order to store every proxy (except default ones) within a global
"proxies" list which is actually representative for all proxies existing
under haproxy process, like we already have for servers.

5 weeks agoMINOR: proxy: collect per-capability stat in proxy_cond_disable()
Aurelien DARRAGON [Mon, 12 May 2025 15:12:49 +0000 (17:12 +0200)] 
MINOR: proxy: collect per-capability stat in proxy_cond_disable()

proxy_cond_disable() collects and prints cumulated connections for be and
fe proxies no matter their type. With shared stats it may cause issues
because depending on the proxy capabilities only fe or be counters may
be allocated.

In this patch we add some checks to ensure we only try to read from
valid memory locations, else we rely on default values (0).

5 weeks agoMINOR: stats: add ME_NEW_COMMON() helper
Aurelien DARRAGON [Tue, 8 Apr 2025 13:18:21 +0000 (15:18 +0200)] 
MINOR: stats: add ME_NEW_COMMON() helper

Split ME_NEW_* helper into COMMON part and specific part so it becomes
easier to add alternative helpers without code duplication.

5 weeks agoMINOR: stats: add stat_col flags
Aurelien DARRAGON [Tue, 8 Apr 2025 09:56:23 +0000 (11:56 +0200)] 
MINOR: stats: add stat_col flags

Add stat_col flags member to store .generic bit and prepare for upcoming
flags. No functional change expected.

5 weeks agoMINOR: server: group postinit server tasks under _srv_postparse()
Aurelien DARRAGON [Thu, 8 May 2025 17:15:24 +0000 (19:15 +0200)] 
MINOR: server: group postinit server tasks under _srv_postparse()

init_srv_requeue() and init_srv_slowstart() functions are called after
initial server parsing via REGISTER_POST_SERVER_CHECK() hook, and they
are also manually called for dynamic server after the server is
initialized.

This may conflict with _srv_postparse() which is also registered via
REGISTER_POST_SERVER_CHECK() and called during dynamic server creation

To ensure functions don't conflict with each other, let's ensure they
are executed in proper order by calling init_srv_requeue and
init_srv_slowstart() from _srv_postparse() which now becomes the parent
function for server related postparsing stuff. No change of behavior is
expected.

5 weeks agoREGTESTS: Remove support for REQUIRE_VERSION and REQUIRE_VERSION_BELOW
Tim Duesterhus [Sun, 1 Jun 2025 13:26:40 +0000 (15:26 +0200)] 
REGTESTS: Remove support for REQUIRE_VERSION and REQUIRE_VERSION_BELOW

This is no longer used since the migration to the native `haproxy -cc
'version_atleast(X)'` functionality.

see 8727614dc4046e91997ecce421bcb6a5537cac93
see 5efc48dcf1b133dd415c759e83b21d52dc303786

5 weeks agoREGTESTS: Remove tests with REQUIRE_VERSION_BELOW=2.4
Tim Duesterhus [Sun, 1 Jun 2025 13:26:39 +0000 (15:26 +0200)] 
REGTESTS: Remove tests with REQUIRE_VERSION_BELOW=2.4

HAProxy 2.4 is the lowest supported version, thus this never matches.

see 18cd4746e5aff9da78d16220b0412947ceba24f3

5 weeks agoREGTESTS: Remove REQUIRE_VERSION=2.4 from all tests
Tim Duesterhus [Sun, 1 Jun 2025 13:26:38 +0000 (15:26 +0200)] 
REGTESTS: Remove REQUIRE_VERSION=2.4 from all tests

HAProxy 2.4 is the lowest supported version, thus this always matches.

see 7aff1bf6b90caadfa95f6b43b526275191991d6f

5 weeks agoREGTESTS: Remove REQUIRE_VERSION=2.3 from all tests
Tim Duesterhus [Sun, 1 Jun 2025 13:26:37 +0000 (15:26 +0200)] 
REGTESTS: Remove REQUIRE_VERSION=2.3 from all tests

HAProxy 2.4 is the lowest supported version, thus this always matches.

see 7aff1bf6b90caadfa95f6b43b526275191991d6f

5 weeks agoREGTESTS: Do not use REQUIRE_VERSION for HAProxy 2.5+ (5)
Tim Duesterhus [Sun, 1 Jun 2025 13:26:36 +0000 (15:26 +0200)] 
REGTESTS: Do not use REQUIRE_VERSION for HAProxy 2.5+ (5)

Introduced in:

25bcdb1d9 BUG/MAJOR: h1: Be stricter on request target validation during message parsing

see also:

fbbbc33df REGTESTS: Do not use REQUIRE_VERSION for HAProxy 2.5+

5 weeks agoDOC: config: Fix a typo in 2.7 (Name format for maps and ACLs)
Christopher Faulet [Mon, 2 Jun 2025 07:18:08 +0000 (09:18 +0200)] 
DOC: config: Fix a typo in 2.7 (Name format for maps and ACLs)

"identified" was used instead of "identifier". May be backported as far as
3.0

6 weeks agoBUILD: tools: properly define ha_dump_backtrace() to avoid a build warning
Willy Tarreau [Fri, 30 May 2025 15:13:21 +0000 (17:13 +0200)] 
BUILD: tools: properly define ha_dump_backtrace() to avoid a build warning

In resolve_sym_name() we declare a few symbols that we want to be able
to resolve. ha_dump_backtrace() was declared with a struct buffer instead
of a pointer to such a struct, which has no effect since we only want to
get the function's pointer, but produces a build warning with LTO, so
let's fix it.

This can be backported to 3.0.

6 weeks ago[RELEASE] Released version 3.3-dev0 v3.3-dev0
Willy Tarreau [Wed, 28 May 2025 14:46:34 +0000 (16:46 +0200)] 
[RELEASE] Released version 3.3-dev0

Released version 3.3-dev0 with the following main changes :
    - MINOR: version: mention that it's development again

6 weeks agoMINOR: version: mention that it's development again
Willy Tarreau [Wed, 28 May 2025 14:41:45 +0000 (16:41 +0200)] 
MINOR: version: mention that it's development again

This essentially reverts a6458fd4269.

6 weeks ago[RELEASE] Released version 3.2.0 v3.2.0
Willy Tarreau [Wed, 28 May 2025 14:35:14 +0000 (16:35 +0200)] 
[RELEASE] Released version 3.2.0

Released version 3.2.0 with the following main changes :
    - MINOR: promex: Add agent check status/code/duration metrics
    - MINOR: ssl: support strict-sni in ssl-default-bind-options
    - MINOR: ssl: also provide the "tls-tickets" bind option
    - MINOR: server: define CLI I/O handler for "add server"
    - MINOR: server: implement "add server help"
    - MINOR: server: use stress mode for "add server help"
    - BUG/MEDIUM: server: fix crash after duplicate GUID insertion
    - BUG/MEDIUM: server: fix potential null-deref after previous fix
    - MINOR: config: list recently added sections with -dKcfg
    - BUG/MAJOR: cache: Crash because of wrong cache entry deleted
    - DOC: configuration: fix the example in crt-store
    - DOC: config: clarify the wording around single/double quotes
    - DOC: config: clarify the legacy cookie and header captures
    - DOC: config: fix alphabetical ordering of layer 7 sample fetch functions
    - DOC: config: fix alphabetical ordering of layer 6 sample fetch functions
    - DOC: config: fix alphabetical ordering of layer 5 sample fetch functions
    - DOC: config: fix alphabetical ordering of layer 4 sample fetch functions
    - DOC: config: fix alphabetical ordering of internal sample fetch functions
    - BUG/MINOR: h3: Set HTX flags corresponding to the scheme found in the request
    - BUG/MEDIUM: h3: Declare absolute URI as normalized when a :authority is found
    - DOC: config: mention in bytes_in and bytes_out that they're read on input
    - DOC: config: clarify the basics of ACLs (call point, multi-valued etc)
    - REGTESTS: Make the script testing conditional set-var compatible with Vtest2
    - REGTESTS: Explicitly allow failing shell commands in some scripts
    - MINOR: listeners: Add support for a label on bind line
    - BUG/MEDIUM: cli/ring: Properly handle shutdown in "show event" I/O handler
    - BUG/MEDIUM: hlua: Properly detect shudowns for TCP applets based on the new API
    - BUG/MEDIUM: hlua: Fix getline() for TCP applets to work with applet's buffers
    - BUG/MEDIUM: hlua: Fix receive API for TCP applets to properly handle shutdowns
    - CI: vtest: Rely on VTest2 to run regression tests
    - CI: vtest: Fix the build script to properly work on MaOS
    - CI: combine AWS-LC and AWS-LC-FIPS by template
    - BUG/MEDIUM: httpclient: Throw an error if an lua httpclient instance is reused
    - DOC: hlua: Add a note to warn user about httpclient object reuse
    - DOC: hlua: fix a few typos in HTTPMessage.set_body_len() documentation
    - DEV: patchbot: prepare for new version 3.3-dev
    - MINOR: version: mention that it's 3.2 LTS now.

6 weeks agoMINOR: version: mention that it's 3.2 LTS now.
Willy Tarreau [Wed, 28 May 2025 14:31:27 +0000 (16:31 +0200)] 
MINOR: version: mention that it's 3.2 LTS now.

The version will be maintained up to around Q2 2030. Let's
also update the INSTALL file to mention this.

6 weeks agoDEV: patchbot: prepare for new version 3.3-dev
Willy Tarreau [Wed, 29 May 2024 12:38:21 +0000 (14:38 +0200)] 
DEV: patchbot: prepare for new version 3.3-dev

The bot will now load the prompt for the upcoming 3.2 version so we have
to rename the files and update their contents to match the current version.

6 weeks agoDOC: hlua: fix a few typos in HTTPMessage.set_body_len() documentation
Willy Tarreau [Tue, 27 May 2025 17:31:12 +0000 (19:31 +0200)] 
DOC: hlua: fix a few typos in HTTPMessage.set_body_len() documentation

A few typos were noticed while gathering info for the 3.2 announce
messages, this fixes them, and will probably constitute the last
commit of this release. There's no need to backport it unless commit
94055a5e7 ("MEDIUM: hlua: Add function to change the body length of
an HTTP Message") is backported.

6 weeks agoDOC: hlua: Add a note to warn user about httpclient object reuse
Christopher Faulet [Tue, 27 May 2025 16:48:21 +0000 (18:48 +0200)] 
DOC: hlua: Add a note to warn user about httpclient object reuse

It is not supported to reuse an lua httpclient instance to process several
requests. A new object must be created for each request. Thanks to the
previous patch ("BUG/MEDIUM: httpclient: Throw an error if an lua httpclient
instance is reused"), an error is now reported if this happens. But it is
not obvious for users. So the lua-api docuementation was updated accordingly.

This patch is related to issue #2986. It should be backported with the
commit above.

6 weeks agoBUG/MEDIUM: httpclient: Throw an error if an lua httpclient instance is reused
Christopher Faulet [Tue, 27 May 2025 16:35:30 +0000 (18:35 +0200)] 
BUG/MEDIUM: httpclient: Throw an error if an lua httpclient instance is reused

It is not expected/supported to reuse an httpclient instance to process
several requests. A new instance must be created for each request. However,
in lua, there is nothing to prevent a user to create an httpclient object
and use it in a loop to process requests.

That's unfortunate because this will apparently work, the requests will be
sent and a response will be received and processed. However internally some
ressources will be allocated and never released. When the next response is
processed, the ressources allocated for the previous one are definitively
lost.

In this patch we take care to check that the httpclient object was never
used when a request is sent from a lua script by checking
HTTPCLIENT_FS_STARTED flags. This flag is set when a httpclient applet is
spawned to process a request and never removed after that. In lua, the
httpclient applet is created when the request is sent. So, it is the right
place to do this test.

This patch should fix the issue #2986. It should be backported as far as
2.6.

6 weeks agoCI: combine AWS-LC and AWS-LC-FIPS by template
Ilya Shipitsin [Mon, 26 May 2025 21:47:13 +0000 (23:47 +0200)] 
CI: combine AWS-LC and AWS-LC-FIPS by template

let's reduce code duplication by involving workflow templates

6 weeks agoCI: vtest: Fix the build script to properly work on MaOS
Christopher Faulet [Tue, 27 May 2025 12:48:48 +0000 (14:48 +0200)] 
CI: vtest: Fix the build script to properly work on MaOS

"config.h" header file is new in VTest2 and includes must be adapted to be
able to build VTest on MacOS. Let's add "-I." to make it work.

6 weeks agoCI: vtest: Rely on VTest2 to run regression tests
Christopher Faulet [Tue, 27 May 2025 12:32:34 +0000 (14:32 +0200)] 
CI: vtest: Rely on VTest2 to run regression tests

VTest2 (https://github.com/vtest/VTest2) was released and is a remplacement
for VTest. VTest was archived. So let's use the new version now.

If this commit is backported, the 2 following commits must also be
backported:

 * 2808e3577 ("REGTESTS: Explicitly allow failing shell commands in some scripts")
 * 82c291124 ("REGTESTS: Make the script testing conditional set-var compatible with Vtest2")

6 weeks agoBUG/MEDIUM: hlua: Fix receive API for TCP applets to properly handle shutdowns
Christopher Faulet [Mon, 26 May 2025 16:11:19 +0000 (18:11 +0200)] 
BUG/MEDIUM: hlua: Fix receive API for TCP applets to properly handle shutdowns

An optional timeout was added to AppletTCP.receive() to interrupt calls after a
delay. It was mandatory to be able to implement interactive applets (like
trisdemo). However, this broke the API and it made impossible to differentiate
the shutdowns from the delays expirations. Indeed, in both cases, an empty
string was returned.

Because historically an empty string was used to notify a connection shutdown,
it should not be changed. So now, 'nil' value is returned when no data was
available before the delay expiration.

The new AppletTCP:try_receive() function was also affected. To fix it, instead
of stating there is no delay when a receive is tried, an expired delay is
set. Concretely TICK_ETERNITY was replaced by now_ms.

Finally, AppletTCP:getline() function is not concerned for now because there
is no way to interrupt it after some delay.

The documentation and trisdemo lua script were updated accordingly.

This patch depends on "BUG/MEDIUM: hlua: Properly detect shudowns for TCP
applets based on the new API". However, it is a 3.2-specific issue, so no
backport is needed.

6 weeks agoBUG/MEDIUM: hlua: Fix getline() for TCP applets to work with applet's buffers
Christopher Faulet [Tue, 27 May 2025 05:46:44 +0000 (07:46 +0200)] 
BUG/MEDIUM: hlua: Fix getline() for TCP applets to work with applet's buffers

The commit e5e36ce09 ("BUG/MEDIUM: hlua/cli: Fix lua CLI commands to work
with applet's buffers") fixed the TCP applets API to work with applets using
its own buffers. Howver the getline() function was not updated. It could be
an issue for anyone registering a CLI commands reading lines.

This patch should be backported as far as 3.0.

6 weeks agoBUG/MEDIUM: hlua: Properly detect shudowns for TCP applets based on the new API
Christopher Faulet [Mon, 26 May 2025 16:24:53 +0000 (18:24 +0200)] 
BUG/MEDIUM: hlua: Properly detect shudowns for TCP applets based on the new API

The internal function responsible to receive data for TCP applets with
internal buffers is buggy. Indeed, for these applets, the buffer API is used
to get data. So there is no tests on the SE to properly detect connection
shutdowns. So, it must be performed by hand after the call to b_getblk_nc().

This patch must be backported as far as 3.0.

6 weeks agoBUG/MEDIUM: cli/ring: Properly handle shutdown in "show event" I/O handler
Christopher Faulet [Mon, 26 May 2025 12:25:16 +0000 (14:25 +0200)] 
BUG/MEDIUM: cli/ring: Properly handle shutdown in "show event" I/O handler

The commit 03dc54d802 ("BUG/MINOR: ring: Fix I/O handler of "show event"
command to not rely on the SC") introduced a regression. By removing
dependencies on the SC, a test to detect client shutdowns was removed. So
now, the CLI applet is no longer released when the client shut the
connection during a "show event -w".

So of course, we should not use the SC to detect the shutdowns. But the SE
must be used insteead.

It is a 3.2-specific issue, so no backport needed.

6 weeks agoMINOR: listeners: Add support for a label on bind line
Christopher Faulet [Mon, 26 May 2025 05:38:11 +0000 (07:38 +0200)] 
MINOR: listeners: Add support for a label on bind line

It is now possile to set a label on a bind line. All sockets attached to
this bind line inherits from this label. The idea is to be able to groud of
sockets. For now, there is no mechanism to create these groups, this must be
done by hand.

6 weeks agoREGTESTS: Explicitly allow failing shell commands in some scripts
Christopher Faulet [Mon, 26 May 2025 05:57:21 +0000 (07:57 +0200)] 
REGTESTS: Explicitly allow failing shell commands in some scripts

Vtest2, that should replaced Vtest in few months, will reject any failing
commands in shell blocks. However, some scripts are executing some commands,
expecting an error to be able to parse the error output. So, now use "set
+e" in those scripts to explicitly state failing commads are expected.

It is just used for non-final commands. At the end, the shell block must
still report a success.

6 weeks agoREGTESTS: Make the script testing conditional set-var compatible with Vtest2
Christopher Faulet [Mon, 26 May 2025 05:49:50 +0000 (07:49 +0200)] 
REGTESTS: Make the script testing conditional set-var compatible with Vtest2

VTest2 will replaced VTest in few months. There is not so much change
expected. One of them is that a User-Agent header is added by default in all
requests, except if an custom one is already set or if "-nouseragent" option
is used. To still be compatible with VTest, it is not possible to use the
option to avoid the header addition. So, a custom user-agent is added in the
last test of "sample_fetches/cond_set_var.vtc" to be sure it will pass with
Vtest and Vtest2. It is mandatory because the request length is tested.

6 weeks agoDOC: config: clarify the basics of ACLs (call point, multi-valued etc)
Willy Tarreau [Mon, 26 May 2025 14:25:22 +0000 (16:25 +0200)] 
DOC: config: clarify the basics of ACLs (call point, multi-valued etc)

This is essentially in order to address the concerns expressed in
issue #2226 where it is mentioned that the moment they are called is
not clear enough. Admittedly, re-reading the paragraph doesn't make
it obvious on a quick read that they behave like functions. This patch
adds an extra paragraph that makes the parallel with programming
languages' boolean functions and explains the fact that they can be
multi-valued. Hoping this is clearer now.

6 weeks agoDOC: config: mention in bytes_in and bytes_out that they're read on input
Willy Tarreau [Mon, 26 May 2025 13:51:14 +0000 (15:51 +0200)] 
DOC: config: mention in bytes_in and bytes_out that they're read on input

Issue #2267 suggests that it's unclear what exactly the byte counts mean
(particularly when compression is involved). Let's clarify that the counts
are read on data input and that they also cover headers and a bit of
internal overhead.

6 weeks agoBUG/MEDIUM: h3: Declare absolute URI as normalized when a :authority is found
Christopher Faulet [Mon, 26 May 2025 09:20:24 +0000 (11:20 +0200)] 
BUG/MEDIUM: h3: Declare absolute URI as normalized when a :authority is found

Since commit 2c3d656f8 ("MEDIUM: h3: use absolute URI form with
:authority"), the absolute URI form is used when a ':authority'
pseudo-header is found. However, this URI was not declared as normalized
internally.  So, when the request is reformated to be sent to an h1 server,
the absolute-form is used instead of the origin-form. It is unexpected and
may be an issue for some servers that could reject the request.

So, now, we take care to set HTX_SL_F_HAS_AUTHORITY flag on the HTX message
when an authority was found and HTX_SL_F_NORMALIZED_URI flag is set for
"http" or "https" schemes.

No backport needed because the commit above must not be backported. It
should fix a regression reported on the 3.2-dev17 in issue #2977.

This commit depends on "BUG/MINOR: h3: Set HTX flags corresponding to the
scheme found in the request".

6 weeks agoBUG/MINOR: h3: Set HTX flags corresponding to the scheme found in the request
Christopher Faulet [Mon, 26 May 2025 09:28:04 +0000 (11:28 +0200)] 
BUG/MINOR: h3: Set HTX flags corresponding to the scheme found in the request

When a ":scheme" pseudo-header is found in a h3 request, the
HTX_SL_F_HAS_SCHM flag must be set on the HTX message. And if the scheme is
'http' or 'https', the corresponding HTX flag must also be set. So,
respectively, HTX_SL_F_SCHM_HTTP or HTX_SL_F_SCHM_HTTPS.

It is mainly used to send the right ":scheme" pseudo-header value to H2
server on backend side.

This patch could be backported as far as 2.6.

6 weeks agoDOC: config: fix alphabetical ordering of internal sample fetch functions
Willy Tarreau [Mon, 26 May 2025 07:36:23 +0000 (09:36 +0200)] 
DOC: config: fix alphabetical ordering of internal sample fetch functions

Some misordering has been accumulating over time, making some of them
hard to spot. Also "uptime" was not indexed.

6 weeks agoDOC: config: fix alphabetical ordering of layer 4 sample fetch functions
Willy Tarreau [Mon, 26 May 2025 07:33:17 +0000 (09:33 +0200)] 
DOC: config: fix alphabetical ordering of layer 4 sample fetch functions

Some misordering has been accumulating over time, making some of them
hard to spot.

6 weeks agoDOC: config: fix alphabetical ordering of layer 5 sample fetch functions
Willy Tarreau [Mon, 26 May 2025 07:21:36 +0000 (09:21 +0200)] 
DOC: config: fix alphabetical ordering of layer 5 sample fetch functions

Some misordering has been accumulating over time, making some of them
hard to spot.

6 weeks agoDOC: config: fix alphabetical ordering of layer 6 sample fetch functions
Willy Tarreau [Mon, 26 May 2025 07:10:39 +0000 (09:10 +0200)] 
DOC: config: fix alphabetical ordering of layer 6 sample fetch functions

Some misordering has been accumulating over time, making some of them
hard to spot.

6 weeks agoDOC: config: fix alphabetical ordering of layer 7 sample fetch functions
Willy Tarreau [Mon, 26 May 2025 07:07:54 +0000 (09:07 +0200)] 
DOC: config: fix alphabetical ordering of layer 7 sample fetch functions

Some misordering has been accumulating over time, making some of them
hard to spot.

6 weeks agoDOC: config: clarify the legacy cookie and header captures
Willy Tarreau [Mon, 26 May 2025 06:56:33 +0000 (08:56 +0200)] 
DOC: config: clarify the legacy cookie and header captures

As reported in issue #2195, cookie captures and header captures are no
longer the recommended way to proceed. Let's mention that this is the
legacy way and provide a few pointers to the recommended functions and
actions to use the modern methods.

6 weeks agoDOC: config: clarify the wording around single/double quotes
Willy Tarreau [Mon, 26 May 2025 06:34:50 +0000 (08:34 +0200)] 
DOC: config: clarify the wording around single/double quotes

As reported in issue #2327, the wording used in the section about quoting
can be read two ways due to the use of the two types of quotes to protect
each other quote. Better only use the quoting without mixing the two when
mentioning them.