]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
18 months agoBUG/MEDIUM: mux-h2: Only Report H2C error on read error if demux buffer is empty
Christopher Faulet [Mon, 18 Dec 2023 17:09:25 +0000 (18:09 +0100)] 
BUG/MEDIUM: mux-h2: Only Report H2C error on read error if demux buffer is empty

It is similar to the previous fix ("BUG/MEDIUM: mux-h2: Don't report H2C
error on read error if dmux buffer is not empty"), but on receive side. If
the demux buffer is not empty, an error on the TCP connection must not be
immediately reported as an error on the H2 connection. We must be sure to
have tried to demux all data first. Otherwise, messages for one or more
streams may be truncated while all data were already received and are
waiting to be demux.

This patch is part of a series that should fix a bug reported in issue #2388
(#2388#issuecomment-1855735144). Backport instructions will be shipped in
the last commit of the series.

18 months agoBUG/MEDIUM: mux-h2: Switch pending error to error if demux buffer is empty
Christopher Faulet [Mon, 18 Dec 2023 16:53:52 +0000 (17:53 +0100)] 
BUG/MEDIUM: mux-h2: Switch pending error to error if demux buffer is empty

When an error on the H2 connection is detected when sending data, only a
pending error is reported, waiting for an error or a shutdown on the read
side. However if a shutdown was already received, the pending error is
switched to a definitive error.

At this stage, we must also wait to have flushed the demux
buffer. Otherwise, if some data must still be demux, messages for one or
more streams may be truncated. There is already the flag H2_CF_END_REACHED
to know a shutdown was received and we no longer progress on demux side
(buffer empty or data truncated). On sending side, we should use this flag
instead to report a definitive error.

This patch is part of a series that should fix a bug reported in issue #2388
(#2388#issuecomment-1855735144). Backport instructions will be shipped in
the last commit of the series.

18 months agoDEV: patchbot: add the AI-based bot to pre-select candidate patches to backport
Willy Tarreau [Mon, 18 Dec 2023 19:41:41 +0000 (20:41 +0100)] 
DEV: patchbot: add the AI-based bot to pre-select candidate patches to backport

This is a set of scripts, prompts and howtos to have an LLM read commit
messages and determine with great accuracy whether the patch's author
intended for the patch to be backported ASAP, backported after some time,
not backported, or unknown state. It provides all this in an interactive
interface making it easy to adjust choices and proceed with what was
selected. This has been improving over the last 9 months, as helped to
spot patches for a handful of backport sessions, and was only limited by
usability issues (UI). Now that these issues are solved, let's commit the
tool in its current working state. It currently runs every hour in a
crontab for me and started to prove useful since the last update, so it
should be considered in a usable state now, especially since this latest
update reaches close to 100% accuracy compared to a human choice, so it
saves precious development time and may allow stable releases to be
emitted more regularly.

There's detailed readme, please read it before complaining about the
ugliness of the UI :-)

18 months agoSCRIPTS: mk-patch-list: produce a list of patches
Willy Tarreau [Mon, 18 Dec 2023 19:34:38 +0000 (20:34 +0100)] 
SCRIPTS: mk-patch-list: produce a list of patches

There does not seem to be a convenient way to tell git-show-backports to
produce individual patches with numbers. That's what this script does by
calling git-format-patch for each specified commit ID, letting git do all
the painful work (formatting etc). This has been mostly used during
backport sessions but was apparently never committed!

18 months agoBUG/MINOR: resolvers: default resolvers fails when network not configured
William Lallemand [Mon, 18 Dec 2023 11:35:35 +0000 (12:35 +0100)] 
BUG/MINOR: resolvers: default resolvers fails when network not configured

Bug #1740 was opened again, this time a user is complaining about the
"can't create socket for nameserver". This can happen if the resolv.conf
file contains a class of address which was not configured on the
machine, for example IPv6.

The fix does the same as b10b1196b ("MINOR: resolvers: shut the warning
when "default" resolvers is implicit"), and uses the
"resolvers->conf.implicit" variable to emit the error.

Though it is not needed to convert the explicit behavior with a
ERR_WARN, because this is supposed to be an unrecoverable error, unlike
the connect().

Should fix issue #1740.

Must be backported were b10b1196b was backported. (as far as 2.6)

18 months agoDOC: config: also add arguments to the converters in the table
Willy Tarreau [Fri, 15 Dec 2023 10:18:27 +0000 (11:18 +0100)] 
DOC: config: also add arguments to the converters in the table

Now that dconv supports linking to keywords with arguments from tables,
let's mention the arguments in the summary table of converters.

18 months agoDOC: config: add arguments to sample fetch methods in the table
Willy Tarreau [Fri, 15 Dec 2023 10:18:08 +0000 (11:18 +0100)] 
DOC: config: add arguments to sample fetch methods in the table

Now that dconv supports linking to keywords with arguments from tables,
let's mention the arguments in the summary tables of sample fetch methods.

18 months agoBUG/MEDIUM: mux-quic: report early error on stream
Amaury Denoyelle [Wed, 13 Dec 2023 15:28:28 +0000 (16:28 +0100)] 
BUG/MEDIUM: mux-quic: report early error on stream

On STOP_SENDING reception, an error is notified to the stream layer as
no more data can be responded. However, this is not done if the stream
instance is not allocated (already freed for example).

The issue occurs if STOP_SENDING is received and the stream instance is
instantiated after it. It happens if a STREAM frame is received after it
with H3 HEADERS, which is valid in QUIC protocol due to UDP packet
reordering. In this case, stream layer is never notified about the
underlying error. Instead, reponse buffers are silently purged by the
MUX in qmux_strm_snd_buf().

This is suboptimal as there is no point in exchanging data from the
server if it cannot be eventually transferred back to the client.
However, aside from this consideration, no other issue occured. However,
this is not the case with QUIC mux-to-mux implementation. Now, if
mux-to-mux is used, qmux_strm_snd_buf() is bypassed and response if
transferred via nego_ff/done_ff callbacks. However, these functions did
not checked if QCS is already locally closed. This causes a crash when
qcc_send_stream() is called via done_ff.

To fix this crash, there is several approach, one of them would be to
adjust nego_ff/done_ff QUIC callbacks. However, another method has been
chosen. Now stream layer is flagged on error just after its
instantiation if the stream is already locally closed. This ensures that
mux-to-mux won't try to emit data as se_nego_ff() check if the opposide
SD is not on error before continuing.

Note that an alternative solution could be to not instantiate at all
stream layer if QCS is already locally closed. This is the most optimal
solution as it reduce unnecessary allocations and task processing.
However, it's not easy to implement so the easier bug fix has been
chosen for the moment.

This patch is labelled as MEDIUM as it can change behavior of all QCS
instances, wheter mux-to-mux is used or not, and thus could reveal other
architecture issues.

This should fix latest crash occurence on github issue #2392.

It should be backported up to 2.6, until a necessary period of
observation.

19 months agoBUG/MEDIUM: mux-h2: Report too large HEADERS frame only when rxbuf is empty
Christopher Faulet [Wed, 13 Dec 2023 14:36:52 +0000 (15:36 +0100)] 
BUG/MEDIUM: mux-h2: Report too large HEADERS frame only when rxbuf is empty

During HEADERS frames decoding, if a frame is too large to fit in a buffer,
an internal error is reported and a RST_STREAM is emitted. On the other
hand, we wait to have an empty rxbuf to decode the frame because we cannot
retry a failed HPACK decompression.

When we are decoding headers, it is valid to return an error if dbuf buffer
is full because no data can be blocked in the rxbuf (which hosts the HTX
message).

However, during the trailers decoding, it is possible to have some data not
sent yet for the current stream in the rxbug and data for another stream
fully filling the dbuf buffer. In this case, we don't decode the trailers
but we must not return an error. We must wait to empty the rxbuf first.

Now, a HEADERS frame is considered as too large if the dbuf buffer is full
and if the rxbuf is empty (the HTX message to be accurate).

This patch should fix the issue #2382. It must be backported to all stable
versions.

19 months agoCLEANUP: mux-h1: Fix a trace message about C-L header addition
Christopher Faulet [Tue, 12 Dec 2023 13:04:35 +0000 (14:04 +0100)] 
CLEANUP: mux-h1: Fix a trace message about C-L header addition

This fixes a cut-paste error on a trace message notifying a 'Content-Length'
header was added during the HTTP message formatting.

19 months agoBUG/MEDIUM: mux-h1: Explicitly skip request's C-L header if not set originally
Christopher Faulet [Tue, 12 Dec 2023 12:56:05 +0000 (13:56 +0100)] 
BUG/MEDIUM: mux-h1: Explicitly skip request's C-L header if not set originally

Commit f89ba27caa ("BUG/MEDIUM: mux-h1; Ignore headers modifications about
payload representation") introduced a regression. The Content-Length is no
longer sent to the server for requests without payload but with a
'Content-Lnegth' header explicitly set to 0, like POST request with no
payload. It is of course unexpected. In some cases, depending on the server,
such requests are considered as invalid and a 411-Length-Required is returned.

The above commit is not directly responsible for the bug, it only reveals a too
lax condition to skip the 'Content-Length' header of bodyless requests. We must
only skip this header if none was originally found, during the parsing.

This patch should fix the issue #2386. It must be backported to 2.9.

19 months agoBUG/MEDIUM: mux-h1: Cound data from input buf during zero-copy forwarding
Christopher Faulet [Mon, 11 Dec 2023 20:55:32 +0000 (21:55 +0100)] 
BUG/MEDIUM: mux-h1: Cound data from input buf during zero-copy forwarding

During zero-copy forwarding, we first try to forward data found in the input
buffer before trying to receive more data. These data must be removed from
the amount of data to forward (the cound variable).

Otherwise, on an internal retry, in h1_fastfwd(), we can be lead to read
more data than expected. It is especially a problem on the end of a
chunk. An error is erroneously reported because more data than announced are
received.

This patch should fix the issue #2382. It must be backported to 2.9.

19 months agoBUG/MEDIUM: stconn: Block zero-copy forwarding if EOS/ERROR on consumer side
Christopher Faulet [Mon, 11 Dec 2023 12:56:15 +0000 (13:56 +0100)] 
BUG/MEDIUM: stconn: Block zero-copy forwarding if EOS/ERROR on consumer side

When the producer side (h1 for now) negociates with the consumer side to
perform a zero-copy forwarding, we now consider the consumer side as blocked
if it is closed and this was reported to the SE via a end-of-stream or a
(pending) error.

It is performed before calling ->nego_ff callback function, in se_nego_ff().
This way, all consumer are concerned automatically. The aim of this patch is
to fix an issue with the QUIC mux. Indeed, it is unexpected to send a frame
on an closed stream. This triggers a BUG_ON(). Other muxes are not affected
but it remains useless to try to send data if the stream is closed.

This patch should fix the issue #2372. It must be backported to 2.9.

19 months agoBUG/MEDIUM: quic: QUIC CID removed from tree without locking
Frédéric Lécaille [Wed, 13 Dec 2023 10:45:43 +0000 (11:45 +0100)] 
BUG/MEDIUM: quic: QUIC CID removed from tree without locking

This bug arrived with this commit:

   BUG/MINOR: quic: Wrong RETIRE_CONNECTION_ID sequence number chec

Every connection ID manipulations against the by thread trees used to store the
connection IDs must be done under the trees locks. These trees are accessed by
the low level connection identification code.

When receiving a RETIRE_CONNECTION_ID frame, the concerned connection ID must
be deleted from the its underlying by thread tree but not without locking!
Add a WR lock around ebmb_delete() call to do so.

Must be backported as far as 2.7.

19 months agoMINOR: hq-interop: use zero-copy to transfer single HTX data block
Amaury Denoyelle [Fri, 8 Dec 2023 14:52:00 +0000 (15:52 +0100)] 
MINOR: hq-interop: use zero-copy to transfer single HTX data block

Similarly to H3, hq-interop now uses zero-copy when dealing with a HTX
message with only a single data block. Exchange HTX and QCS buffer, and
use the HTX data block for HTTP payload. This is only possible if QCS
buffer is empty. Contrary to HTTP/3, no extra frame header is needed
before transferring HTTP payload.

hq-interop is only implemented for testing purpose so this change should
not be noticeable by users. However, it will be useful to be able to
test zero-copy transfer on QUIC interop testing.

19 months agoMINOR: h3: adjust zero-copy sending related code
Amaury Denoyelle [Fri, 8 Dec 2023 14:48:06 +0000 (15:48 +0100)] 
MINOR: h3: adjust zero-copy sending related code

Adjust HTTP/3 data emission. First, add HTX as argument to the function
as this is used for other frames emission function. Keep the buffer
argument as this is mandatory for zero-copy. Extend comments related to
this, in particular to explain purposes of both HTX and buffer
arguments.

No function change here. This should however be useful to port a code
equivalent to hq-interop protocol.

19 months agoMINOR: h3: complete traces for sending
Amaury Denoyelle [Mon, 11 Dec 2023 14:10:56 +0000 (15:10 +0100)] 
MINOR: h3: complete traces for sending

Add data level traces for each encoded H3 frame. Of notable interest,
traces will be useful to detect if standard emission, zero-copy or fast
forward is used. Also add the generic filter H3_EV_TX_FRAME to be able
to filter these messages.

19 months agoMINOR: mux-quic: factorize QC_SF_UNKNOWN_PL_LENGTH set
Amaury Denoyelle [Fri, 8 Dec 2023 14:47:06 +0000 (15:47 +0100)] 
MINOR: mux-quic: factorize QC_SF_UNKNOWN_PL_LENGTH set

When dealing with HTTP/1 responses without Content-Length nor chunked
encoding, flag QC_SF_UNKNOWN_PL_LENGTH is set on QCS. This prevent the
emission of a RESET_STREAM on shutw, instead resorting to a proper FIN
emission.

This code was duplicated both in H3 and hq-interop. Move it in common
qcs_http_snd_buf() to factorize it.

19 months agoCLEANUP: mux-quic: clean up app ops callback definitions
Amaury Denoyelle [Thu, 7 Dec 2023 16:43:07 +0000 (17:43 +0100)] 
CLEANUP: mux-quic: clean up app ops callback definitions

qcc_app_ops is a set of callbacks used to unify application protocol
running over QUIC. This commit introduces some changes to clarify its
API :
* write simple comment to reflect each callback purpose
* rename decode_qcs to rcv_buf as this name is more common and is
  similar to already existing snd_buf
* finalize is moved up as it is used during connection init stage

All these changes are ported to HTTP/3 layer. Also function comments
have been extended to highlight HTTP/3 special characteristics.

19 months agoMINOR: mux-quic: clean up qcs Tx buffer allocation API
Amaury Denoyelle [Mon, 13 Nov 2023 13:57:28 +0000 (14:57 +0100)] 
MINOR: mux-quic: clean up qcs Tx buffer allocation API

This function is similar to the previous one, but this time for QCS
sending buffer.

Previously, each application layer redefine their own version of
mux_get_buf() which was used to allocate <qcs.tx.buf>. Unify it under a
single function renamed qcc_get_stream_txbuf().

19 months agoMINOR: mux-quic: clean up qcs Rx buffer allocation API
Amaury Denoyelle [Mon, 11 Dec 2023 14:34:42 +0000 (15:34 +0100)] 
MINOR: mux-quic: clean up qcs Rx buffer allocation API

Replaces qcs_get_buf() function which naming does not reflect its
purpose. Add a new function qcc_get_stream_rxbuf() which allocate if
needed <qcs.rx.app_buf> and returns the buffer pointer. This function is
reserved for application protocol layer. This buffer is then accessed by
stconn layer.

For other qcs_get_buf() invocation which was used in effect for a local
buffer, replace these by a plain b_alloc().

19 months agoCLEANUP: mux-quic: remove unused prototype
Amaury Denoyelle [Mon, 13 Nov 2023 13:55:22 +0000 (14:55 +0100)] 
CLEANUP: mux-quic: remove unused prototype

Remove qcc_emit_cc_app() prototype from header file. This function was
removed by a previous commit and does not exist anymore.

19 months agoBUG/MINOR: ext-check: cannot use without preserve-env
Aurelien DARRAGON [Thu, 7 Dec 2023 08:58:27 +0000 (09:58 +0100)] 
BUG/MINOR: ext-check: cannot use without preserve-env

Since 1de44da ("MINOR: ext-check: add an option to preserve environment
variables"), it is now possible to provide an extra argument to
"external-check" directive. This allows to support the "preserve-env"
option which differs from the default behavior.

However a mistake was made, because the config parser doesn't allow the
default configuration anymore: using external-check without argument will
trigger an error:
  'external-check' only supports 'preserve-env' as an argument, found ''.

This is due to as small mistake in the code that make the check
systematically report an error if the first argument is not equal to
"preserve-env". The check was modified so that the error is only reported
if the argument is provided, so that the default behavior is restored.

This should fix GH #2380 and should be backported on 2.9 and potentially
further (anywhere 1de44da is, because a note about an optional backport
up to the 2.6 was left in the original commit message)

19 months agoBUG/MEDIUM: map/acl: pat_ref_{set,delete}_by_id regressions
Aurelien DARRAGON [Fri, 8 Dec 2023 10:46:15 +0000 (11:46 +0100)] 
BUG/MEDIUM: map/acl: pat_ref_{set,delete}_by_id regressions

Some regressions were introduced by 5fea59754b ("MEDIUM: map/acl:
Accelerate several functions using pat_ref_elt struct ->head list")

pat_ref_delete_by_id() fails to properly unlink and free the removed
reference because it bypasses the pat_ref_delete_by_ptr() made for
that purpose. This function is normally used everywhere the target
reference is set for removal, such as the pat_ref_delete() function
that matches pattern against a string. The call was probably skipped
by accident during the rewrite of the function.

With the above commit also comes another undesirable change:
both pat_ref_delete_by_id() and pat_ref_set_by_id() directly use the
<refelt> argument as a valid pointer (they do dereference it).

This is wrong, because <refelt> is unsafe and should be handled as an
ID, not a pointer (hence the function name). Indeed, the calling function
may directly pass user input from the CLI as <refelt> argument, so we must
first ensure that it points to a valid element before using it, else it is
probably invalid and we shouldn't touch it.

What this patch essentially does, is that it reverts pat_ref_set_by_id()
and pat_ref_delete_by_id() to pre 5fea59754b behavior. This seems like
it was the only optimization from the patch that doesn't apply.

Hopefully, after reviewing the changes with Fred, it seems that the 2
functions are only being involved in commands for manipulating maps or
acls on the cli, so the "missed" opportunity to improve their performance
shouldn't matter much. Nonetheless, if we wanted to speed up the reference
lookup by ID, we could consider adding an eb64 tree for that specific
purpose that contains all pattern references IDs (ie: pointers) so that
eb lookup functions may be used instead of linear list search.

The issue was raised by Marko Juraga as he failed to perform an an acl
removal by reference on the CLI on 2.9 which was known to work properly
on other versions.

It should be backported on 2.9.

Co-Authored-by: Frédéric Lécaille <flecaille@haproxy.com>
19 months agoCI: github: switch to wolfssl git-c4b77ad for new PR
William Lallemand [Fri, 8 Dec 2023 10:10:42 +0000 (11:10 +0100)] 
CI: github: switch to wolfssl git-c4b77ad for new PR

The "dynamic-certs-n-ciphers" PR was just merged, lets build the wolfssl
git instead of the 5.6.4 version, so we could test the feature.

19 months agoMINOR: ssl: activate the certificate selection callback for WolfSSL
William Lallemand [Fri, 8 Dec 2023 10:33:03 +0000 (11:33 +0100)] 
MINOR: ssl: activate the certificate selection callback for WolfSSL

The PR which allows to chose a certificate depending on the ciphers and
the signature algorithms was merged in WolfSSL. Let's activate this
code.

This could be backported in 2.9 only when the next WolfSSL release is
available (5.6.5). It will also need a check on the version.

19 months agoBUILD: ssl: update types in wolfssl cert selection callback
William Lallemand [Fri, 8 Dec 2023 10:55:15 +0000 (11:55 +0100)] 
BUILD: ssl: update types in wolfssl cert selection callback

The types have changed in the PR for the wolfSSL_get_sigalg_info()
function, let's update them.

Must be backported in 2.9.

19 months agoBUG/MEDIUM: quic: Possible buffer overflow when building TLS records
Frédéric Lécaille [Thu, 7 Dec 2023 20:12:02 +0000 (21:12 +0100)] 
BUG/MEDIUM: quic: Possible buffer overflow when building TLS records

This bug impacts only the OpenSSL QUIC compatibility module (USE_QUIC_OPENSSL_COMPAT).

This may happen only when the TLS stack has to be provided with more than 1024+1+5+16
bytes of CRYPTO data. In this case several TLS records have to be built in one
call to SSL_provide_quic_data(). A 5-bytes header is created at the head
of these records. This header is used as AAD to cipher the record. But
the length of this AAD was counted two times. One time here in
quic_tls_compat_create_record() (initialization):

 adlen = quic_tls_compat_create_header(qc, rec, ad, 0);

and a second time here in the same function after quic_tls_tls_seal() return:

     ret = aad_len + outlen;

This addition is useless. Note that this bug could be reproduced when haproxy has
to authenticate the client.

Thank you to @vifino for having reported this issue in GH #2381.

Must be backported to 2.8.

19 months agoCLEANUP: mworker/cli: add comments about pcli_find_and_exec_kw()
William Lallemand [Thu, 7 Dec 2023 17:02:29 +0000 (18:02 +0100)] 
CLEANUP: mworker/cli: add comments about pcli_find_and_exec_kw()

Add a comment about the pcli_find_and_exec_kw().

19 months agoBUG/MINOR: mworker/cli: fix set severity-output support
William Lallemand [Wed, 6 Dec 2023 10:15:01 +0000 (11:15 +0100)] 
BUG/MINOR: mworker/cli: fix set severity-output support

"set severity-output" is one of these command that changes the appctx
state so the next commands are affected.

Unfortunately the master CLI works with pipelining and server close
mode, which means the connection between the master and the worker is
closed after each response, so for the next command this is a new appctx
state.

To fix the problem, 2 new flags are added ACCESS_MCLI_SEVERITY_STR and
ACCESS_MCLI_SEVERITY_NB which are used to prefix each command sent to
the worker with the right "set severity-output" command.

This patch fixes issue #2350.

It could be backported as far as 2.6.

19 months agoMINOR: mux-quic: add traces for 0-copy/fast-forward
Amaury Denoyelle [Thu, 7 Dec 2023 14:53:02 +0000 (15:53 +0100)] 
MINOR: mux-quic: add traces for 0-copy/fast-forward

Complete qmux traces :
* add a trace when 0-copy is used for DATA transfer
* mark the FIN as detected when using fast forward

19 months agoCLEANUP: mux_quic: rename ffwd function with prefix qmux_strm_
Amaury Denoyelle [Thu, 7 Dec 2023 10:01:50 +0000 (11:01 +0100)] 
CLEANUP: mux_quic: rename ffwd function with prefix qmux_strm_

All QUIC MUX functions which are callbacks for stream layer use the
prefix qmux_strm_*. This was not the case for fast forward related
callback which only used qmux_* prefix.

Fix this by reusing the standard prefix to respect QUIC MUX code
convention.

19 months agoMINOR: hq-interop: add fastfwd support
Amaury Denoyelle [Thu, 7 Dec 2023 09:36:36 +0000 (10:36 +0100)] 
MINOR: hq-interop: add fastfwd support

Implement callback for fast forwarding for hq-interop.

This change should not be considered as functionally important. Indeed,
HTTP/0.9 is reserved for QUIC interop testing and should not be used
outside of it. However, implementing fast forwarding in this context is
useful as this will allow to test MUX code sections for fast forward via
QUIC interop.

19 months agoDOC: configuration: typo req.ssl_hello_type
William Lallemand [Thu, 7 Dec 2023 14:00:58 +0000 (15:00 +0100)] 
DOC: configuration: typo req.ssl_hello_type

rep_ssl_hello_type was renamed in res.ssl_hello_type a long time ago.

This patch fixes a typo where an example was renamed
"rep.ssl_hello_type" instead of "res.ssl_hello_type"

fixes issue #2377 and #2379.

Must be backported in all maintained versions.

19 months agoBUG/MINOR: lua: Wrong OCSP CID after modifying an SSL certficate (LUA)
Frédéric Lécaille [Wed, 6 Dec 2023 10:42:42 +0000 (11:42 +0100)] 
BUG/MINOR: lua: Wrong OCSP CID after modifying an SSL certficate (LUA)

This bugfix is the same as the following one:
    "BUG/MINOR: ssl_ckch: Wrong OCSP CID after modifying an SSL certficate"
where the OCSP CID had to be reset when updating a certificate.

Must be backported to 2.8.

19 months agoBUG/MINOR: ssl: Wrong OCSP CID after modifying an SSL certficate
Frédéric Lécaille [Tue, 5 Dec 2023 14:38:29 +0000 (15:38 +0100)] 
BUG/MINOR: ssl: Wrong OCSP CID after modifying an SSL certficate

This bug could be reproduced with the "set ssl cert" CLI command to update
a certificate. The OCSP CID is duplicated by ckchs_dup() which calls
ssl_sock_copy_cert_key_and_chain(). It should be computed again by
ssl_sock_load_ocsp(). This may be accomplished resetting the new ckch OCSP CID
returned by ckchs_dup().

This bug may be in relation with GH #2319.

Must be backported to 2.8.

19 months agoMINOR: ssl/cli: Add ha_(warning|alert) msgs to CLI ckch callback
Frédéric Lécaille [Tue, 5 Dec 2023 14:11:33 +0000 (15:11 +0100)] 
MINOR: ssl/cli: Add ha_(warning|alert) msgs to CLI ckch callback

This patch allows cli_io_handler_commit_cert() callback called upon
a "commit ssl cert ..." command to prefix the messages returned by the CLI
to the by the ones built by ha_warining(), ha_alert().

Should be interesting to backport this commit to 2.8.

19 months agoBUG/MINOR: ssl: Double free of OCSP Certificate ID
Frédéric Lécaille [Tue, 5 Dec 2023 13:50:40 +0000 (14:50 +0100)] 
BUG/MINOR: ssl: Double free of OCSP Certificate ID

This bug could be reproduced loading several certificated from "bind" line:
with "server_ocsp.pem" as argument to "crt" setting and updating
the CDSA certificate with the RSA as follows:

echo -e "set ssl cert reg-tests/ssl/ocsp_update/multicert/server_ocsp.pem.ecdsa \
     <<\n$(cat reg-tests/ssl/ocsp_update/multicert/server_ocsp.pem.rsa)\n" | socat - /tmp/stats
followed by an "commit ssl cert reg-tests/ssl/ocsp_update/multicert/server_ocsp.pem.ecdsa"
command. This could be detected by libasan as follows:

=================================================================
==507223==ERROR: AddressSanitizer: attempting double-free on 0x60200007afb0 in thread T3:
    #0 0x7fabc6fb5527 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x54527)
    #1 0x7fabc6ae8f8c in ossl_asn1_string_embed_free (/opt/quictls/lib/libcrypto.so.81.3+0xd4f8c)
    #2 0x7fabc6af54e9 in ossl_asn1_primitive_free (/opt/quictls/lib/libcrypto.so.81.3+0xe14e9)
    #3 0x7fabc6af5960 in ossl_asn1_template_free (/opt/quictls/lib/libcrypto.so.81.3+0xe1960)
    #4 0x7fabc6af569f in ossl_asn1_item_embed_free (/opt/quictls/lib/libcrypto.so.81.3+0xe169f)
    #5 0x7fabc6af58a4 in ASN1_item_free (/opt/quictls/lib/libcrypto.so.81.3+0xe18a4)
    #6 0x46a159 in ssl_sock_free_cert_key_and_chain_contents src/ssl_ckch.c:723
    #7 0x46aa92 in ckch_store_free src/ssl_ckch.c:869
    #8 0x4704ad in cli_release_commit_cert src/ssl_ckch.c:1981
    #9 0x962e83 in cli_io_handler src/cli.c:1140
    #10 0xc1edff in task_run_applet src/applet.c:454
    #11 0xaf8be9 in run_tasks_from_lists src/task.c:634
    #12 0xafa2ed in process_runnable_tasks src/task.c:876
    #13 0xa23c72 in run_poll_loop src/haproxy.c:3024
    #14 0xa24aa3 in run_thread_poll_loop src/haproxy.c:3226
    #15 0x7fabc69e7ea6 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7ea6)
    #16 0x7fabc6907a2e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xfba2e)

0x60200007afb0 is located 0 bytes inside of 3-byte region [0x60200007afb0,0x60200007afb3)
freed by thread T3 here:
    #0 0x7fabc6fb5527 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x54527)
    #1 0x7fabc6ae8f8c in ossl_asn1_string_embed_free (/opt/quictls/lib/libcrypto.so.81.3+0xd4f8c)

previously allocated by thread T2 here:
    #0 0x7fabc6fb573f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
    #1 0x7fabc6ae8d77 in ASN1_STRING_set (/opt/quictls/lib/libcrypto.so.81.3+0xd4d77)

Thread T3 created by T0 here:
    #0 0x7fabc6f84bba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
    #1 0xc04f36 in setup_extra_threads src/thread.c:252
    #2 0xa2761f in main src/haproxy.c:3917
    #3 0x7fabc682fd09 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23d09)

Thread T2 created by T0 here:
    #0 0x7fabc6f84bba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
    #1 0xc04f36 in setup_extra_threads src/thread.c:252
    #2 0xa2761f in main src/haproxy.c:3917
    #3 0x7fabc682fd09 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23d09)

SUMMARY: AddressSanitizer: double-free ??:0 __interceptor_free
==507223==ABORTING
Aborted

The OCSP CID stored in the impacted ckch data were freed but not reset to NULL,
leading to a subsequent double free.

Must be backported to 2.8.

19 months agoMINOR: promex: Export active/backup metrics per-server
Christopher Faulet [Mon, 4 Dec 2023 09:49:52 +0000 (10:49 +0100)] 
MINOR: promex: Export active/backup metrics per-server

numbers of active and backup servers per backend were exported but the info
was not exported per-server. The main issue to do so was we were unable to
have a different name for the same metric in a different scope. Thanks to
the previous patch ("MINOR: promex: Add support for specialized
front/back/li/srv metric names") it is now possible. So the info is now
exported per-server.

This patch should fix the issue #2271.

19 months agoMINOR: promex: Add support for specialized front/back/li/srv metric names
Christopher Faulet [Mon, 4 Dec 2023 08:00:18 +0000 (09:00 +0100)] 
MINOR: promex: Add support for specialized front/back/li/srv metric names

Depending on the scope, metrics can have different names. For instance, the
number of active/backend servers are reported with
"haproxy_backend_active_servers"/"haproxy_backend_backup_servers" metric names
in the backend scope while it should be
"haproxy_server_active"/"haproxy_server_backup" in the server scope.

To be able to support different names depending on the scope for the same
metric, arrays of ISTs were added, one by scope (front, back, listen,
server). These arrays only contain names overriding the default ones.

Note: the exemple above is not supported for now and is the reason for this
commit.

19 months agoDOC: management/lua: Update commands about map and acl
Christopher Faulet [Fri, 1 Dec 2023 11:06:14 +0000 (12:06 +0100)] 
DOC: management/lua: Update commands about map and acl

Because maps and list of ACLs are no longer necessarily referenced by
filenames, CLI commands to manipulate them were updated accordingly. Instead
of "filename" we talk about "name" now.

The same is performed in the LUA documentation.

19 months agoDOC: config: Add section about name format for maps and ACLs
Christopher Faulet [Fri, 1 Dec 2023 11:05:51 +0000 (12:05 +0100)] 
DOC: config: Add section about name format for maps and ACLs

Maps and list of ACLs can now reference something else than regular files
and can have prefix to set the type of the list (file, virutal file or
optional file). So, the configuration manual was updated accordingly.

The section 2.7. about name format for maps and ACLs was added (the former
2.7. sections with some examples was moved to 2.8.) and references to map or
ACLs files were updated.

19 months agoMEDIUM: pattern: Add support for virtual and optional files for patterns
Christopher Faulet [Fri, 1 Dec 2023 11:04:35 +0000 (12:04 +0100)] 
MEDIUM: pattern: Add support for virtual and optional files for patterns

Before this patch, it was not possible to use a list of patterns, map or a
list of acls, without an existing file.  However, it could be handy to just
use an ID, with no file on the disk. It is pretty useful for everyone
managing dynamically these lists. It could also be handy to try to load a
list from a file if it exists without failing if not. This way, it could be
possible to make a cold start without any file (instead of empty file),
dynamically add and del patterns, dump the list to the file periodically to
reuse it on reload (via an external process).

In this patch, we uses some prefixes to be able to use virtual or optional
files.

The default case remains unchanged. regular files are used. A filename, with
no prefix, is used as reference, and it must exist on the disk. With the
prefix "file@", the same is performed. Internally this prefix is
skipped. Thus the same file, with ou without "file@" prefix, references the
same list of patterns.

To use a virtual map, "virt@" prefix must be used. No file is read, even if
the following name looks like a file. It is just an ID. The prefix is part
of ID and must always be used.

To use a optional file, ie a file that may or may not exist on a disk at
startup, "opt@" prefix must be used. If the file exists, its content is
loaded. But HAProxy doesn't complain if not. The prefix is not part of
ID. For a given file, optional files and regular files reference the same
list of patterns.

This patch should fix the issue #2202.

19 months agoMINOR: pattern: Use reference name as filename to read patterns from a file
Christopher Faulet [Fri, 1 Dec 2023 11:04:13 +0000 (12:04 +0100)] 
MINOR: pattern: Use reference name as filename to read patterns from a file

It is only a small API refactoring. The filename is no longer used when
pat_ref_read_from_file_smp() or pat_ref_read_from_file() functions are
called. The filename was already used to create the reference on the list of
patterns. Thus, we now directly use info from this reference.

19 months agoMINOR: cache: Add global option to enable/disable zero-copy forwarding
Christopher Faulet [Mon, 4 Dec 2023 15:06:24 +0000 (16:06 +0100)] 
MINOR: cache: Add global option to enable/disable zero-copy forwarding

tune.cache.zero-copy-forwarding parameter can now be used to enable or
disable the zero-copy fast-forwarding for the cache applet only. It is
enabled ('on') by default. It can be disabled by setting the parameter to
'off'.

19 months agoMEDIUM: cache: Add support for endp-to-endp fast-forwarding
Christopher Faulet [Thu, 23 Nov 2023 16:25:30 +0000 (17:25 +0100)] 
MEDIUM: cache: Add support for endp-to-endp fast-forwarding

It is now possible to directly forward data to the opposite side from the
cache applet. To do so, dedicated functions were added to fast-forward the
payload part of the cached objects. Of course headers and trailers are still
sent via the channel's buffer, using the HTX.

When an object is delivered from the cache, once the applet reaches the
HTX_CACHE_DATA state, it declares it can fast-forward data. From this point,
all data are directly transferred to the oppposite side.

19 months agoMEDIUM: cache: Save body size of cached objects and track it on delivery
Christopher Faulet [Thu, 23 Nov 2023 16:15:00 +0000 (17:15 +0100)] 
MEDIUM: cache: Save body size of cached objects and track it on delivery

We now save the body size of cached objets in the cache entry strucutre. In
addition, the cache applet tracks the body part already sent.

This will be mandatory to add support of endpoint-to-endpoint
fast-forwarding in the cache applet.

19 months agoMINOR: applets: Use channel's field to compute amount of data received
Christopher Faulet [Thu, 23 Nov 2023 15:51:25 +0000 (16:51 +0100)] 
MINOR: applets: Use channel's field to compute amount of data received

To be able to support endpoint-to-endpoint fast-forwarding (formerly called
mux-to-mux fast-forwarding), we cannot rely on data in the input channel to
compute amount of data the applet has produced.

The applet API is not really designed to know how many bytes are produced or
received at each call. Till now, it was not a problem because data always
passed through the channels. With E2E fast-frowarding, input data may be
immediately consumed. From the caller point of view (task_run_applet), there
is only the total field of the input channel that will change. So let's use
it now.

19 months agoMEDIUM: applet: Handle channel's STREAMER flags on applets size
Christopher Faulet [Tue, 21 Nov 2023 07:03:37 +0000 (08:03 +0100)] 
MEDIUM: applet: Handle channel's STREAMER flags on applets size

Till now, it was not possible to notify an producing applet is streaming
data. It means, it was not possible to set CF_STREAMER and CF_STREAMER_FLAGS
on the input channel of an applet streaming data.

While it is not a big deal for most of applets, it is interesting for the
cache. Because there are now dedicated functions to deal with these flags,
we can use them in task_run_applet() to set/unset these flags on the input
channel.

This patch relies on "MINOR: channel: Use dedicated functions to deal with
STREAMER flags".

19 months agoMINOR: channel: Use dedicated functions to deal with STREAMER flags
Christopher Faulet [Tue, 21 Nov 2023 06:51:45 +0000 (07:51 +0100)] 
MINOR: channel: Use dedicated functions to deal with STREAMER flags

For now, CF_STREAMER and CF_STREAMER_FAST flags are set in sc_conn_recv()
function. The logic is moved in dedicated functions.

First, channel_check_idletimer() function is now responsible to check the
channel's last read date against the idle timer value to be sure the
producer is still streaming data. Otherwise, it removes STREAMER flags.

Then, channel_check_xfer() function is responsible to check amount of data
transferred avec a receive, to eventually update STREAMER flags.

In sc_conn_recv(), we now use these functions.

19 months ago[RELEASE] Released version 3.0-dev0 v3.0-dev0
Willy Tarreau [Tue, 5 Dec 2023 15:19:35 +0000 (16:19 +0100)] 
[RELEASE] Released version 3.0-dev0

Released version 3.0-dev0 with the following main changes :
    - exact copy of 2.9.0

19 months ago[RELEASE] Released version 2.9.0 v2.9.0
Willy Tarreau [Tue, 5 Dec 2023 15:15:30 +0000 (16:15 +0100)] 
[RELEASE] Released version 2.9.0

Released version 2.9.0 with the following main changes :
    - DOC: config: add missing colon to "bytes_out" sample fetch keyword (2)
    - BUG/MINOR: cfgparse-listen: fix warning being reported as an alert
    - DOC: config: add matrix entry for "max-session-srv-conns"
    - DOC: config: fix monitor-fail typo
    - DOC: config: add context hint for proxy keywords
    - DEBUG: stream: Report lra/fsb values for front end back SC in stream dump
    - REGTESTS: sample: Test the behavior of consecutive delimiters for the field converter
    - BUG/MINOR: sample: Make the `word` converter compatible with `-m found`
    - DOC: Clarify the differences between field() and word()
    - BUG/MINOR: server/event_hdl: properly handle AF_UNSPEC for INETADDR event
    - BUILD: http_htx: silence uninitialized warning on some gcc versions
    - MINOR: acme.sh: don't use '*' in the filename for wildcard domain
    - MINOR: global: Use a dedicated bitfield to customize zero-copy fast-forwarding
    - MINOR: mux-pt: Add global option to enable/disable zero-copy forwarding
    - MINOR: mux-h1: Add global option to enable/disable zero-copy forwarding
    - MINOR: mux-h2: Add global option to enable/disable zero-copy forwarding
    - MINOR: mux-quic: Add global option to enable/disable zero-copy forwarding
    - MINOR: mux-quic: Disable zero-copy forwarding for send by default
    - DOC: config: update the reminder on the HTTP model and add some terminology
    - DOC: config: add a few more differences between HTTP/1 and 2+
    - DOC: config: clarify session vs stream
    - DOC: config: fix typo abandonned -> abandoned
    - DOC: management: fix two latest typos (optionally, exception)
    - BUG/MEDIUM: peers: fix partial message decoding
    - DOC: management: update stream vs session

19 months agoDOC: management: update stream vs session
Willy Tarreau [Tue, 5 Dec 2023 08:30:44 +0000 (09:30 +0100)] 
DOC: management: update stream vs session

Indicate for some commands such as "show sess" that we now dump streams
and not sessions.

19 months agoBUG/MEDIUM: peers: fix partial message decoding
Christopher Faulet [Tue, 5 Dec 2023 08:21:38 +0000 (09:21 +0100)] 
BUG/MEDIUM: peers: fix partial message decoding

peer_recv_msg() may return because the message is incomplete without
checking if a shutdown is pending for the SC. The function relies on
co_getblk() to detect shutdowns. However, the message length decoding may be
interrupted if the multi-bytes integer is incomplete. In this case, the SC
is not check for shutdowns.

When this happens, this leads to an appctx spinning loop.

This patch should fix the issue #2373. It must be backported to 2.8.

19 months agoDOC: management: fix two latest typos (optionally, exception)
Willy Tarreau [Tue, 5 Dec 2023 03:04:50 +0000 (04:04 +0100)] 
DOC: management: fix two latest typos (optionally, exception)

No backport needed, these were introduced by latest commits 3dd55fa13
("MINOR: mworker/cli: implement hard-reload over the master CLI") and
cef29d370 ("MINOR: trace: define simple -dt argument").

19 months agoDOC: config: fix typo abandonned -> abandoned
Willy Tarreau [Tue, 5 Dec 2023 03:02:25 +0000 (04:02 +0100)] 
DOC: config: fix typo abandonned -> abandoned

No need to backport, it was introduced by recent commit fafa34e5f ("DOC:
config: update the reminder on the HTTP model and add some terminology").

19 months agoDOC: config: clarify session vs stream
Willy Tarreau [Mon, 4 Dec 2023 17:57:12 +0000 (18:57 +0100)] 
DOC: config: clarify session vs stream

Rename "session" to "stream" where relevant (termination states, queue,
and so on).

19 months agoDOC: config: add a few more differences between HTTP/1 and 2+
Willy Tarreau [Mon, 4 Dec 2023 17:34:19 +0000 (18:34 +0100)] 
DOC: config: add a few more differences between HTTP/1 and 2+

Mention the lack of reason phrase and the existence of pseudo-headers for
the request and the response.

19 months agoDOC: config: update the reminder on the HTTP model and add some terminology
Willy Tarreau [Mon, 4 Dec 2023 17:16:52 +0000 (18:16 +0100)] 
DOC: config: update the reminder on the HTTP model and add some terminology

It was really necessary to try to clear the confusion between sessions
and streams, so let's first lift a little bit the HTTP model part to
better consider new protocols, and explain what a stream is and how this
differs from the earlier sessions.

19 months agoMINOR: mux-quic: Disable zero-copy forwarding for send by default
Christopher Faulet [Mon, 4 Dec 2023 14:36:01 +0000 (15:36 +0100)] 
MINOR: mux-quic: Disable zero-copy forwarding for send by default

There is at least an bug for now in this part and it is still unstable. Thus
it is better to disable it for now by default. It can be enable by setting
tune.quic.zero-copy-fwd-send to 'on'.

19 months agoMINOR: mux-quic: Add global option to enable/disable zero-copy forwarding
Christopher Faulet [Mon, 4 Dec 2023 14:26:23 +0000 (15:26 +0100)] 
MINOR: mux-quic: Add global option to enable/disable zero-copy forwarding

tune.quic.zero-copy-fwd-send can now be used to enable or disable the
zero-copy fast-forwarding for the QUIC mux only, for sends. For now, there
is no option to disable it for receives because it is not supported yet.

It is enabled ('on') by default.

19 months agoMINOR: mux-h2: Add global option to enable/disable zero-copy forwarding
Christopher Faulet [Mon, 4 Dec 2023 14:18:49 +0000 (15:18 +0100)] 
MINOR: mux-h2: Add global option to enable/disable zero-copy forwarding

tune.h2.zero-copy-fwd-send can now be used to enable or disable the
zero-copy fast-forwarding for the H2 mux only, for sends. For now, there is
no option to disable it for receives because it is not supported yet.

It is enabled ('on') by default.

19 months agoMINOR: mux-h1: Add global option to enable/disable zero-copy forwarding
Christopher Faulet [Mon, 4 Dec 2023 14:06:06 +0000 (15:06 +0100)] 
MINOR: mux-h1: Add global option to enable/disable zero-copy forwarding

tune.h1.zero-copy-fwd-recv and tune.h1.zero-copy-fwd-send can now be used to
enable or disable the zero-copy fast-forwarding for the H1 mux only, for
receives or sends. Unlike the PT mux, there are 2 options here because
client and server sides can use difference muxes.

Both are enabled ('on') by default.

19 months agoMINOR: mux-pt: Add global option to enable/disable zero-copy forwarding
Christopher Faulet [Mon, 4 Dec 2023 13:48:52 +0000 (14:48 +0100)] 
MINOR: mux-pt: Add global option to enable/disable zero-copy forwarding

tune.pt.zero-copy-forwarding parameter can now be used to enable or disable
the zero-copy fast-forwarding for the PT mux only. It is enabled ('on') by
default. It can be disabled by setting the parameter to 'off'. In this case,
this disables receive and send side.

19 months agoMINOR: global: Use a dedicated bitfield to customize zero-copy fast-forwarding
Christopher Faulet [Mon, 4 Dec 2023 13:18:50 +0000 (14:18 +0100)] 
MINOR: global: Use a dedicated bitfield to customize zero-copy fast-forwarding

Zero-copy fast-forwading feature is a quite new and is a bit sensitive.
There is an option to disable it globally. However, all protocols have not
the same maturity. For instance, for the PT multiplexer, there is nothing
really new. The zero-copy fast-forwading is only another name for the kernel
splicing. However, for the QUIC/H3, it is pretty new, not really optimized
and it will evolved. And soon, the support will be added for the cache
applet.

In this context, it is usefull to be able to enable/disable zero-copy
fast-forwading per-protocol and applet. And when it is applicable, on sends
or receives separately. So, instead of having one flag to disable it
globally, there is now a dedicated bitfield, global.tune.no_zero_copy_fwd.

19 months agoMINOR: acme.sh: don't use '*' in the filename for wildcard domain
William Lallemand [Mon, 4 Dec 2023 10:52:31 +0000 (11:52 +0100)] 
MINOR: acme.sh: don't use '*' in the filename for wildcard domain

By default acme.sh uses the '*' character in the filename for wildcard.
That can be confusing within HAProxy since the * character in front of a
filename in the stat socket is used to specified an uncommitted
transaction.

This patch replace the '*' by a '_' in the filename.  This is only done
when using the default filename, the name can still be forced with an
asterisk.

19 months agoBUILD: http_htx: silence uninitialized warning on some gcc versions
Willy Tarreau [Fri, 1 Dec 2023 14:29:44 +0000 (15:29 +0100)] 
BUILD: http_htx: silence uninitialized warning on some gcc versions

Building on gcc 4.4 reports "start may be used uninitialized". This is
a classical case of dependency between two variables where the compiler
lost track of their initialization and doesn't know that if one is not
set, the other is. By just moving the second test in the else clause
of the assignment both fixes it and makes the code more efficient, and
this can be simplified as a ternary operator.

It's probably not needed to backport this, unless anyone reports build
warnings with more recent compilers (intermediary optimization levels
such as -O1 can sometimes trigger such warnings).

19 months agoBUG/MINOR: server/event_hdl: properly handle AF_UNSPEC for INETADDR event
Aurelien DARRAGON [Fri, 1 Dec 2023 16:41:40 +0000 (17:41 +0100)] 
BUG/MINOR: server/event_hdl: properly handle AF_UNSPEC for INETADDR event

It is possible that a server's addr family is temporarily set to AF_UNSPEC
even if we're certain to be in INET context (ipv4, ipv6).

Indeed, as soon as IP address resolving is involved, srv->addr family will
be set to AF_UNSPEC when the resolution fails (could happen at anytime).

However, _srv_event_hdl_prepare_inetaddr() wrongly assumed that it would
only be called with AF_INET or AF_INET6 families. Because of that, the
function will handle AF_UNSPEC address as an IPV6 address: not only
we could risk reading from an unititialized area, but we would then
propagate false information when publishing the event.

In this patch we make sure to properly handle the AF_UNSPEC family in
both the "prev" and the "next" part for SERVER_INETADDR event and that
every members are explicitly initialized.

This bug was introduced by 6fde37e046 ("MINOR: server/event_hdl: add
SERVER_INETADDR event"), no backport needed.

19 months agoDOC: Clarify the differences between field() and word()
Tim Duesterhus [Thu, 30 Nov 2023 15:41:18 +0000 (16:41 +0100)] 
DOC: Clarify the differences between field() and word()

word() mentions that delimiters at the start and end are ignored, but
it does not mention that consecutive delimiters are merged.

May be backported as far as the patch applies.

19 months agoBUG/MINOR: sample: Make the `word` converter compatible with `-m found`
Tim Duesterhus [Thu, 30 Nov 2023 15:41:17 +0000 (16:41 +0100)] 
BUG/MINOR: sample: Make the `word` converter compatible with `-m found`

Previously an expression like:

    path,word(2,/) -m found

always returned `true`.

Bug exists since the `word` converter exists. That is:
c9a0f6d0232cf44d6b08d1964b9097a45a6c65f0

The same bug was previously fixed for the `field` converter in commit
4381d26edc03faa46401eb0fe82fd7be84be14fd.

The fix should be backported to 1.6+.

19 months agoREGTESTS: sample: Test the behavior of consecutive delimiters for the field converter
Tim Duesterhus [Thu, 30 Nov 2023 15:41:16 +0000 (16:41 +0100)] 
REGTESTS: sample: Test the behavior of consecutive delimiters for the field converter

This is in preparation of a follow-up patch to fix the word converter.

19 months agoDEBUG: stream: Report lra/fsb values for front end back SC in stream dump
Christopher Faulet [Fri, 1 Dec 2023 10:16:53 +0000 (11:16 +0100)] 
DEBUG: stream: Report lra/fsb values for front end back SC in stream dump

REX and WEX date are already reported. But if the corresponding SC cannot
expire on read or write, "<NEVER>" is reported instead. The same is reported
if no expiration date is set. It is not really convenient because we cannot
distinguish the two cases.

So, now, for each SC, read and wirte timer (rto/wto) are also reported in
the dump, based on .lra/.fsb dates and the current I/O timeout. The SC I/O
timeout is also reported.

19 months agoDOC: config: add context hint for proxy keywords
Aurelien DARRAGON [Mon, 20 Nov 2023 16:53:17 +0000 (17:53 +0100)] 
DOC: config: add context hint for proxy keywords

Add a small list of contexts where each proxy keyword is expected to be
employed. (Similar to the defaults/frontend/backend/listen compatibility
grid).

19 months agoDOC: config: fix monitor-fail typo
Aurelien DARRAGON [Thu, 30 Nov 2023 10:11:43 +0000 (11:11 +0100)] 
DOC: config: fix monitor-fail typo

monitor-fail doesn't exist, but it was mentionned in the documentation.
Fixing it with "monitor fail" instead.

19 months agoDOC: config: add matrix entry for "max-session-srv-conns"
Aurelien DARRAGON [Wed, 29 Nov 2023 09:13:18 +0000 (10:13 +0100)] 
DOC: config: add matrix entry for "max-session-srv-conns"

Following 4039329 ("DOC: config: specify supported sections for
"max-session-srv-conns"), "max-session-srv-conns" was also missing
from the proxy keyword matrix.

19 months agoBUG/MINOR: cfgparse-listen: fix warning being reported as an alert
Aurelien DARRAGON [Wed, 29 Nov 2023 14:03:25 +0000 (15:03 +0100)] 
BUG/MINOR: cfgparse-listen: fix warning being reported as an alert

Since b40542000d ("MEDIUM: proxy: Warn about ambiguous use of named
defaults sections") we introduced a new error to prevent user from
having an ambiguous named default section in the config which is both
inherited explicitly using "from" and implicitly by another proxy due to
the default section being the last one defined.

However, despite the error message being presented as a warning the
err_code, the commit message and the documentation, it is actually
reported as a fatal error because ha_alert() was used in place of
ha_warning().

In this patch we make the code comply with the documentation and the
intended behavior by using ha_warning() to report the error message.

This should be backported up to 2.6.

19 months agoDOC: config: add missing colon to "bytes_out" sample fetch keyword (2)
Tim Duesterhus [Thu, 30 Nov 2023 19:15:32 +0000 (20:15 +0100)] 
DOC: config: add missing colon to "bytes_out" sample fetch keyword (2)

This reapplies 1eb049dc677f2de950158615ed3d8306ee5102d6, as the change was
accidentally reverted in 5ef48e063ecf992646c7af374153f106050fb8ec.

19 months ago[RELEASE] Released version 2.9-dev12 v2.9-dev12
Willy Tarreau [Thu, 30 Nov 2023 17:07:06 +0000 (18:07 +0100)] 
[RELEASE] Released version 2.9-dev12

Released version 2.9-dev12 with the following main changes :
    - BUG/MINOR: global: Fix tune.disable-(fast-forward/zero-copy-forwarding) options
    - DOC: config: removing "log-balance" references
    - MINOR: server/event_hdl: add SERVER_INETADDR event
    - MINOR: tools: use const for read only pointers in ip{cmp,cpy}
    - MINOR: server/ip: centralize server ip updates
    - MINOR: backend: remove invalid mode test for "hash-balance-factor"
    - Revert "MINOR: cfgparse-listen: warn when use-server rules is used in wrong mode"
    - MINOR: proxy: add free_logformat_list() helper function
    - MINOR: proxy: add free_server_rules() helper function
    - MINOR: log/backend: prevent "use-server" rules use with LOG mode
    - MINOR: log/balance: set lbprm tot_weight on server on queue/dequeue
    - DOC: config: specify supported sections for "max-session-srv-conns"
    - DOC: config: fix timeout check inheritance restrictions
    - REGTESTS: connection: disable http_reuse_be_transparent.vtc if !TPROXY
    - DOC: lua: add sticktable class reference from Proxy.stktable
    - DOC: lua: fix Proxy.get_mode() output
    - DOC: lua: add "syslog" to Proxy.get_mode() output
    - MEDIUM: ssl: implement rsa/ecdsa selection with WolfSSL
    - MINOR: ssl: replace 'trash.area' by 'servername' in ssl_sock_switchctx_cbk()
    - MINOR: ssl: move certificate selection in a dedicate function
    - MEDIUM: ssl: use ssl_sock_chose_sni_ctx() in the clienthello callback
    - MINOR: mworker/cli: implement hard-reload over the master CLI
    - BUG/MEDIUM: mux-h1: Properly ignore trailers when a content-length is announced
    - MINOR: task/profiling: do not record task_drop_running() as a caller
    - OPTIM: pattern: save memory and time using ebst instead of ebis
    - BUILD: map: fix build warning
    - MINOR: trace: define simple -dt argument
    - MINOR: trace: parse level in a function
    - MINOR: trace: parse verbosity in a function
    - MINOR: trace: support -dt optional format
    - OPTIM: mux-h2/zero-copy: don't allocate more buffers per connections than streams
    - BUG/MINOR: quic: fix CONNECTION_CLOSE_APP encoding
    - BUG/MEDIUM: stconn: Don't perform zero-copy FF if opposite SC is blocked
    - BUG/MEDIUM: mux-h2: Remove H2_SF_NOTIFIED flag for H2S blocked on fast-forward
    - CLEANUP: quic: Remove dead definitions/declarations
    - REORG: quic: Move some QUIC CLI code to its C file
    - REORG: quic: Add a new module to handle QUIC connection IDs
    - REORG: quic: QUIC connection types header cleaning
    - BUILD: quic: Missing RX header inclusions
    - REORG: quic: Move CRYPTO data buffer defintions to QUIC TLS module
    - REORG: quic: Move QUIC CRYPTO stream definitions/declarations to QUIC TLS
    - REORG: quic: Move several inlined functions from quic_conn.h
    - REORG: quic: Move QUIC SSL BIO method related functions to quic_ssl.c
    - REORG: quic: Move the QUIC DCID parser to quic_sock.c
    - REORG: quic: Rename some functions used upon ACK receipt
    - REORG: quic: Move QUIC path definitions/declarations to quic_cc module
    - REORG: quic: Move qc_handle_conn_migration() to quic_conn.c
    - REORG: quic: Move quic_build_post_handshake_frames() to quic_conn module
    - REORG: quic: Move qc_may_probe_ipktns() to quic_tls.h
    - REORG: quic: Move qc_pkt_long() to quic_rx.h
    - REORG: quic: Rename some (quic|qc)_conn* objects to quic_conn_closed
    - REORG: quic: Move NEW_CONNECTION_ID frame builder to quic_cid
    - REORG: quic: Move ncbuf related function from quic_rx to quic_conn
    - REORG: quic: Add a new module for QUIC retry
    - BUILD: quic: Several compiler warns fixes after retry module creation
    - REORG: quic: Move qc_notify_send() to quic_conn
    - REORG: quic: Add a new module for retransmissions
    - REORG: quic: Remove qc_pkt_insert() implementation
    - REORG: quic: Move quic_increment_curr_handshake() to quic_sock
    - BUG/MINOR: cache: Remove incomplete entries from the cache when stream is closed
    - MEDIUM: cli: allow custom pattern for payload
    - CLEANUP: mworker/cli: use a label to return errors
    - MINOR: mworker/cli: implements the customized payload pattern for master CLI
    - DOC: management: add documentation about customized payload pattern
    - BUG/MEDIUM: server/event_hdl: memory overrun in _srv_event_hdl_prepare_inetaddr()
    - MINOR: event_hdl: add global tunables
    - BUG/MAJOR: server/addr: fix a race during server addr:svc_port updates
    - MEDIUM: log/balance: support FQDN for UDP log servers
    - BUG/MINOR: compression: possible NULL dereferences in comp_prepare_compress_request()
    - BUG/MEDIUM: master/cli: Properly pin the master CLI on thread 1 / group 1
    - BUG/MEDIUM: mux-quic: Stop zero-copy FF during nego if input is not empty
    - CLEANUP: log: Fix %rc comment in sess_build_logline()
    - BUG/MINOR: h3: fix TRAILERS encoding
    - BUG/MINOR: h3: always reject PUSH_PROMISE
    - MINOR: h3: use correct error code for missing SETTINGS
    - MINOR: http-fetch: Add a sample to retrieve the server status code
    - DOC: config: Improve 'status' sample documentation
    - MINOR: http-fetch: Add a sample to get the transaction status code
    - MEDIUM: http-ana: Set termination state before returning haproxy response
    - MINOR: stream: Expose session terminate state via a new sample fetch
    - MINOR: stream: add a sample fetch to get the number of connection retries
    - MINOR: stream: Expose the stream's uniq_id via a new sample fetch
    - MINOR: muxes: Rename mux_ctl_type values to use MUX_CTL_ prefix
    - MINOR: muxes: Add a callback function to send commands to mux streams
    - MINOR: muxes: Implement ->sctl() callback for muxes and return the stream id
    - MINOR: Add sample fetches to get the frontend and backend stream ID
    - BUG/MEDIUM: cli: Don't look for payload pattern on empty commands
    - DOC: config: Add argument for tune.lua.maxmem
    - DOC: config: fix mention of request slot in http-response capture
    - DOC: config: fix remaining mention of @reverse for attach-srv action
    - DOC: config: fix missing characters in set-spoe-group action
    - DOC: config: reorganize actions into their own section
    - BUG/MINOR: acme.sh: update the deploy script
    - MINOR: rhttp: mark reverse HTTP as experimental
    - CLEANUP: quic_cid: remove unused listener arg
    - BUG/MINOR: quic_tp: fix preferred_address decoding
    - MINOR: quic_tp: use in_addr/in6_addr for preferred_address
    - MINOR: acme.sh: use the master CLI for hot update
    - DOC: config: move the cache-use and cache-store actions to the proper section
    - DOC: config: fix alphabetical ordering of converter keywords
    - DOC: config: add missing colon to "bytes_out" sample fetch keyword
    - DOC: config: add an index of converter keywords
    - DOC: config: add an index of sample fetch keywords
    - BUG/MINOR: config: Stopped parsing upon unmatched environment variables
    - DEBUG: unstatify a few functions that are often present in backtraces
    - BUILD: server: shut a bogus gcc warning on certain ubuntu

19 months agoBUILD: server: shut a bogus gcc warning on certain ubuntu
Willy Tarreau [Thu, 30 Nov 2023 16:48:03 +0000 (17:48 +0100)] 
BUILD: server: shut a bogus gcc warning on certain ubuntu

On ubuntu 20.04 and 22.04 with gcc 9.4 and 11.4 respectively, we get
the following warning:

  src/server.c: In function 'srv_update_addr_port':
  src/server.c:4027:3: warning: 'new_port' may be used uninitialized in this function [-Wmaybe-uninitialized]
   4027 |   _srv_event_hdl_prepare_inetaddr(&cb_data.addr, &s->addr, s->svc_port,
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   4028 |                                   ((ip_change) ? &sa : &s->addr),
        |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   4029 |                                   ((port_change) ? new_port : s->svc_port),
        |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   4030 |                                   1);
        |                                   ~~

It's clearly wrong, port_change only changes from 0 to anything else
*after* assigning new_port. Let's just preset new_port to zero instead
of trying to play smart with the compiler.

19 months agoDEBUG: unstatify a few functions that are often present in backtraces
Willy Tarreau [Thu, 30 Nov 2023 16:04:16 +0000 (17:04 +0100)] 
DEBUG: unstatify a few functions that are often present in backtraces

It's useful to be able to recognize certain functions that are often
present in backtraces as they call lower level functions, and for this
they must not be static. Let's remove "static" in front of these
functions:

  sc_notify, sc_conn_recv, sc_conn_send, sc_conn_process,
  sc_applet_process, back_establish, stream_update_both_sc,
  httpclient_applet_io_handler, httpclient_applet_init,
  httpclient_applet_release

19 months agoBUG/MINOR: config: Stopped parsing upon unmatched environment variables
Frédéric Lécaille [Thu, 30 Nov 2023 08:26:05 +0000 (09:26 +0100)] 
BUG/MINOR: config: Stopped parsing upon unmatched environment variables

When an environment variable could not be matched by getenv(), the
current character to be parsed by parse_line() from <in> variable
is the trailing double quotes. If nothing is done in such a case,
this character is skipped by parse_line(), then the following spaces
are parsed as an empty argument.

To fix this, skip the double quotes character and the following spaces
to make <in> variable point to the next argument to be parsed.

Thank you to @sigint2 for having reported this issue in GH #2367.

Must be backported as far as 2.4.

19 months agoDOC: config: add an index of sample fetch keywords
Willy Tarreau [Thu, 30 Nov 2023 15:00:14 +0000 (16:00 +0100)] 
DOC: config: add an index of sample fetch keywords

Now we're adding a table for each section, it allows to more easily
spot the list of available sample fetch functions and their types.
For now the arguments are not mentioned in the table because they'd
break indexing but they can be added back later.

19 months agoDOC: config: add an index of converter keywords
Willy Tarreau [Thu, 30 Nov 2023 15:03:55 +0000 (16:03 +0100)] 
DOC: config: add an index of converter keywords

The goal here is to have a centralized list of converters and
their in/out types.

19 months agoDOC: config: add missing colon to "bytes_out" sample fetch keyword
Willy Tarreau [Thu, 30 Nov 2023 15:03:19 +0000 (16:03 +0100)] 
DOC: config: add missing colon to "bytes_out" sample fetch keyword

The colon was missing between the keyword and the type, breaking
rendering and indexing.

19 months agoDOC: config: fix alphabetical ordering of converter keywords
Willy Tarreau [Thu, 30 Nov 2023 10:55:22 +0000 (11:55 +0100)] 
DOC: config: fix alphabetical ordering of converter keywords

- rfc7239_* were misplaced and incorrectly ordered
- table_gpt was placed before some table_gpc*
- capture-req/res were misplaced
- htonl was misplaced
- upper/url_* were misplaced
- x509_v_err_str was misplaced

Let's fix these since poor ordering complicates their finding.

19 months agoDOC: config: move the cache-use and cache-store actions to the proper section
Willy Tarreau [Thu, 30 Nov 2023 15:25:58 +0000 (16:25 +0100)] 
DOC: config: move the cache-use and cache-store actions to the proper section

Actions were grouped by previous commit d54e8f810 ("DOC: config: reorganize
actions into their own section") but cache-use and cache-store were still
making reference to the cache section. This moves the text back to their
respective keywords in the actions section and leaves the example and an
explanation of how to use the keywords in the cache section.

19 months agoMINOR: acme.sh: use the master CLI for hot update
William Lallemand [Thu, 30 Nov 2023 15:15:45 +0000 (16:15 +0100)] 
MINOR: acme.sh: use the master CLI for hot update

DEPLOY_HAPROXY_MASTER_CLI allows to use the HAProxy master CLI
instead of a stats socket for DEPLOY_HAPROXY_HOT_UPDATE="yes"

The syntax of the master CLI is slightly different, a prefix with
the process number need to be added before any command.

This patch uses ${_cmdpfx} in front of every socat commands which is
filled when the master CLI is used.

19 months agoMINOR: quic_tp: use in_addr/in6_addr for preferred_address
Amaury Denoyelle [Thu, 30 Nov 2023 14:36:10 +0000 (15:36 +0100)] 
MINOR: quic_tp: use in_addr/in6_addr for preferred_address

preferred_address is a transport parameter specify by the server. It
specified both an IPv4 and IPv6 address. These addresses were defined as
plain array in <struct tp_preferred_address>.

Convert these adressees to use the common types in_addr/in6_addr. With
this change, dumping of preferred_address is extended. It now displays
the addresses using inet_ntop() and CID value.

19 months agoBUG/MINOR: quic_tp: fix preferred_address decoding
Amaury Denoyelle [Thu, 30 Nov 2023 13:01:51 +0000 (14:01 +0100)] 
BUG/MINOR: quic_tp: fix preferred_address decoding

quic_transport_param_dec_pref_addr() is responsible to decode
preferred_address from received transport parameter. There was two
issues with this function :
* address and port location as defined in RFC were inverted for both
  IPv4 and IPv6 during decoding
* an invalid check was done to ensure decoded CID length corresponds to
  remaining buffer size. It did not take into account the final field
  for stateless reset token.

These issues were never encountered as only server can emit
preferred_address transport parameter, so the impact of this bug is
invisible.

This should be backported up to 2.6.

19 months agoCLEANUP: quic_cid: remove unused listener arg
Amaury Denoyelle [Thu, 30 Nov 2023 13:00:56 +0000 (14:00 +0100)] 
CLEANUP: quic_cid: remove unused listener arg

retrieve_qc_conn_from_cid() requires listener as argument whereas it is
unused. This is an artifact from the old architecture where CID trees
where stored on listener instances instead of globally. Remove it to
better reflect this change.

19 months agoMINOR: rhttp: mark reverse HTTP as experimental
Amaury Denoyelle [Thu, 30 Nov 2023 13:28:47 +0000 (14:28 +0100)] 
MINOR: rhttp: mark reverse HTTP as experimental

Mark the reverse HTTP feature as experimental. This will allow to adjust
if needed the configuration mechanism with future developments without
maintaining retro-compatibility.

Concretely, each config directives linked to it now requires to specify
first global expose-experimental-directives before. This is the case for
the following directives :
- rhttp@ prefix uses in bind and server lines
- nbconn bind keyword
- attach-srv tcp rule

Each documentation section refering to these keywords are updated to
highlight this new requirement.

Note that this commit has duplicated on several places the code from the
global function check_kw_experimental(). This is because the latter only
work with cfg_keyword type. This is not adapted with bind_kw or
action_kw types. This should be improve in a future patch.

19 months agoBUG/MINOR: acme.sh: update the deploy script
William Lallemand [Thu, 30 Nov 2023 13:15:06 +0000 (14:15 +0100)] 
BUG/MINOR: acme.sh: update the deploy script

https://github.com/acmesh-official/acme.sh/pull/4581 was updated, this
patch update the haproxy repository with the update.
the following changes were done:

- sanitize the PEM to remove the '\n' (truncated certicate chain)
- shellcheck fixes
- socat format is directly used in the DEPLOY_HAPROXY_STATS_SOCKET variable

19 months agoDOC: config: reorganize actions into their own section
Willy Tarreau [Thu, 30 Nov 2023 08:28:39 +0000 (09:28 +0100)] 
DOC: config: reorganize actions into their own section

The split of the rulesets from their respective actions has long been
overdue so it's time to do it because it has become extremely difficult
to add simple actions in the documentation, as well as it's hard to find
them.

This commit creates two new sections "4.3 Actions keywords matrix" and
"4.4 Alphabetically sorted actions reference" that enumerates all known
actions, with a check indicating for which rule sets they're valid. This
removes all the repetition, occurrences of "see http-request blah for
details" and significantly reduces the number of keywords listed in the
proxies section. This removes 2245 lines from the proxies section in
exchange of 1608 in these new sections.

19 months agoDOC: config: fix missing characters in set-spoe-group action
Willy Tarreau [Thu, 30 Nov 2023 08:27:51 +0000 (09:27 +0100)] 
DOC: config: fix missing characters in set-spoe-group action

It was written "Thaction" instead of "This action".

19 months agoDOC: config: fix remaining mention of @reverse for attach-srv action
Willy Tarreau [Thu, 30 Nov 2023 08:26:38 +0000 (09:26 +0100)] 
DOC: config: fix remaining mention of @reverse for attach-srv action

The new address is "rhttp@".

19 months agoDOC: config: fix mention of request slot in http-response capture
Willy Tarreau [Thu, 30 Nov 2023 08:24:21 +0000 (09:24 +0100)] 
DOC: config: fix mention of request slot in http-response capture

It's response slot, not request slot.

19 months agoDOC: config: Add argument for tune.lua.maxmem
Olivier Duclos [Wed, 29 Nov 2023 11:08:12 +0000 (12:08 +0100)] 
DOC: config: Add argument for tune.lua.maxmem

Make it clear that tune.lua.maxmem expects a number.

19 months agoBUG/MEDIUM: cli: Don't look for payload pattern on empty commands
Christopher Faulet [Wed, 29 Nov 2023 12:20:59 +0000 (13:20 +0100)] 
BUG/MEDIUM: cli: Don't look for payload pattern on empty commands

A regression was introduced by commit 9431aa0bdf ("BUG/MEDIUM: cli: Don't
look for payload pattern on empty commands").

On empty commands (really empty or containing spaces and tabs), the number of
arguments set to 0. However we look for the payload pattern without checking
it. The result is an access at the index -1 in the argument array. It is of
course invalid.

To fix the issue, we just skip this part when there is no argument. Note that
the empty command is still sent to the worker.

This patch should solve the issue #2365. No backport needed.

19 months agoMINOR: Add sample fetches to get the frontend and backend stream ID
Christopher Faulet [Tue, 28 Nov 2023 15:34:23 +0000 (16:34 +0100)] 
MINOR: Add sample fetches to get the frontend and backend stream ID

"fc.id" and "bc.id" sample fetches can now be used to get, respectively, the
frontend or the backend stream ID. They rely on ->sctl() callback function
on the mux attached to the corresponding SC.

It means these sample fetches work only for connection, not applets, and
from the time a multiplexer is installed.

19 months agoMINOR: muxes: Implement ->sctl() callback for muxes and return the stream id
Christopher Faulet [Tue, 28 Nov 2023 14:12:51 +0000 (15:12 +0100)] 
MINOR: muxes: Implement ->sctl() callback for muxes and return the stream id

All muxes now implements the ->sctl() callback function and are able to
return the stream ID. For the PT multiplexer, it is always 0. For the H1
multiplexer it is the request count for the current H1 connection (added for
this purpose). The FCGI, H2 and QUIC muxes, the stream ID is returned.

The stream ID is returned as a signed 64 bits integer.