]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
17 months agoMINOR: applet: Add callback function to deal with zero-copy forwarding
Christopher Faulet [Tue, 23 Jan 2024 06:51:24 +0000 (07:51 +0100)] 
MINOR: applet: Add callback function to deal with zero-copy forwarding

This patch introduces the support for the callback function responsible to
produce data via the zero-copy forwarding mechanism. There is no
implementation for now. But <to_forward> field was added in the appctx
structure to let an applet inform how much data it want to forward. It is
not mandatory but it will be used during the zero-copy forwarding
negociation.

17 months agoMEDIUM: applet: Use appctx flags to report EOS/EOI/ERROR to SE
Christopher Faulet [Tue, 23 Jan 2024 06:49:56 +0000 (07:49 +0100)] 
MEDIUM: applet: Use appctx flags to report EOS/EOI/ERROR to SE

We have indroduced flags to deal with end of input, end of stream and errors
at the applet level. With this patch we make the link with the endpoint
descriptor.

In appctx_rcv_buf(), applet flags are converted to SE flags.

17 months agoMINOR: applet: Add an appctx flag to report shutdown to applets
Christopher Faulet [Tue, 23 Jan 2024 06:42:08 +0000 (07:42 +0100)] 
MINOR: applet: Add an appctx flag to report shutdown to applets

There is no shutdown for reads and send with applets. Both are performed
when the appctx is released. So instead of 2 flags, like for
muxes/connections, only one flag is used. But the idea is the same:
acknowledge the event at the applet level.

17 months agoMINOR: applet: Remove appctx state field to only used the flags
Christopher Faulet [Mon, 15 Jan 2024 17:42:39 +0000 (18:42 +0100)] 
MINOR: applet: Remove appctx state field to only used the flags

The appctx state was never really used as a state. It is only used to know
when an applet should be freed on the next wakeup. This can be converted to
a flag and the state can be removed. This is what this patch does.

17 months agoMINIOR: applet: Add flags to deal with ends of input, ends of stream and errors
Christopher Faulet [Mon, 15 Jan 2024 17:35:14 +0000 (18:35 +0100)] 
MINIOR: applet: Add flags to deal with ends of input, ends of stream and errors

Dedicated appctx flags to report EOI, EOS and errors (pending or terminal) were
added with the functions to set these flags. It is pretty similar to what it
done on most of muxes.

17 months agoMINOR: applet: Add flags on the appctx and stop abusing its state
Christopher Faulet [Mon, 15 Jan 2024 08:04:08 +0000 (09:04 +0100)] 
MINOR: applet: Add flags on the appctx and stop abusing its state

Till now, we've extended the appctx state to add some flags. However, the
field name is misleading. So a bitfield was added to handle real flags. And
helper functions to manipulate this bitfield were added.

17 months agoMINOR: applet: Show IN/OUT buffers in trace messages when used
Christopher Faulet [Thu, 11 Jan 2024 09:02:47 +0000 (10:02 +0100)] 
MINOR: applet: Show IN/OUT buffers in trace messages when used

The function dumping applet trace messages was updated to dump info about
in/out buffers instead of channel buffers when it is relevant.

17 months agoMEDIM: applet: Add the applet handler based on IN/OUT buffers
Christopher Faulet [Thu, 11 Jan 2024 08:57:01 +0000 (09:57 +0100)] 
MEDIM: applet: Add the applet handler based on IN/OUT buffers

A dedicated function to run applets was introduced, in addition to the old
one, to deal with applets that use their own buffers. The main differnce
here is that this handler does not use channels at all. It performs a
synchronous send before calling the applet and performs a synchronous
receive just after.

No applets are plugged on this handler for now.

17 months agoMEDIUM: stconn: Add functions to handle applets I/O from the SC layer
Christopher Faulet [Thu, 11 Jan 2024 09:10:06 +0000 (10:10 +0100)] 
MEDIUM: stconn: Add functions to handle applets I/O from the SC layer

There is no tasklet to handle I/O subscriptions for applets, but functions
to deal with receives and sends from the SC layer were added. it meanse a
function to retrieve data from an applet with this synchronous version and a
function to push data to an applet wit this synchronous version.

It is pretty similar to the functions used for muxes but there are some
differences. So for now, we keep them separated.

Zero-copy forwarding is not supported for now. In addition, there is no
subscription mechanism.

17 months agoMINOR: applet: Implement default functions to exchange data with channels
Christopher Faulet [Thu, 11 Jan 2024 08:58:46 +0000 (09:58 +0100)] 
MINOR: applet: Implement default functions to exchange data with channels

In this patch, we add default functions to copy data from a channel to the
<inbuf> buffer of an applet (appctx_rcv_buf) and another on to copy data
from <outbuf> buffer of an applet to a channel (appctx_snd_buf).

These functions are not used for now, but they will be used by applets to
define their <rcv_buf> and <snd_buf> callback functions. Of course, it will
be possible for a specific applet to implement its own functions but these
ones should be good enough for most of applets. HTX and RAW buffers are
supported.

17 months agoMINOR: applet: Add support for callback functions to exchange data with channels
Christopher Faulet [Thu, 11 Jan 2024 08:02:17 +0000 (09:02 +0100)] 
MINOR: applet: Add support for callback functions to exchange data with channels

For now, it is not usable, but this patch introduce the support of callback
functions, in the applet structure, to exchange data between channels and
applets. It is pretty similar to callback functions defined by muxes.

17 months agoMINOR: applet: Add traces to debug receive/send and block/wake events
Christopher Faulet [Mon, 8 Jan 2024 07:07:30 +0000 (08:07 +0100)] 
MINOR: applet: Add traces to debug receive/send and block/wake events

New traces events are added to be able to debug receives and sends.

17 months agoMINOR: applet: Add dedicated IN/OUT buffers for appctx
Christopher Faulet [Mon, 8 Jan 2024 07:05:59 +0000 (08:05 +0100)] 
MINOR: applet: Add dedicated IN/OUT buffers for appctx

It is the first patch of a series aimed to align applets on connections.
Here, dedicated buffers are added for applets. For now, buffers are
initialized and helpers function to deal with allocation are added. In
addition, flags to report allocation failures or full buffers are also
introduced. <inbuf> will be used to push data to the applet from the stream
and <outbuf> will be used to push data from the applet to the stream.

17 months agoMINOR: stconn: Be prepared to handle error when a SC is attached to an applet
Christopher Faulet [Wed, 10 Jan 2024 13:23:38 +0000 (14:23 +0100)] 
MINOR: stconn: Be prepared to handle error when a SC is attached to an applet

sc_attach_applet() was changed to be able to fail and callers were updated
accordingly. For now it cannot fail but if this changes, callers will be
prepared to handle errors.

17 months agoMINOR: stconn: Explicitly use an appctx to attach a stconn on it
Christopher Faulet [Wed, 10 Jan 2024 13:17:14 +0000 (14:17 +0100)] 
MINOR: stconn: Explicitly use an appctx to attach a stconn on it

In sc_attach_applet, an untyped pointer (void *) was used to attach a SC on
an applet. There is no reason to not use the right type here. So now a
pointer on an appctx is explicitly used.

17 months agoMINOR: stconn: Be able to detect applets using HTX
Christopher Faulet [Thu, 11 Jan 2024 09:03:38 +0000 (10:03 +0100)] 
MINOR: stconn: Be able to detect applets using HTX

IS_HXT_SC() macro is only usable if the stream-connector is attached to a
connection. It is a bit restrictive because this cannot work if the SC is
attached to an applet. So let's fix that be adding the support of applets
too.

17 months agoMINOR: task: Move wait_event in the task header file
Christopher Faulet [Wed, 10 Jan 2024 07:55:00 +0000 (08:55 +0100)] 
MINOR: task: Move wait_event in the task header file

wait_event structure was in connection header file because it is only used
by connections and muxes. But, this may change. For instance applets may be
good candidates to use it too. So, the structure is moved to the task header
file instead.

17 months agoDOC: install: clarify WolfSSL chroot requirements
Lukas Tribus [Fri, 2 Feb 2024 17:33:08 +0000 (17:33 +0000)] 
DOC: install: clarify WolfSSL chroot requirements

17 months agoCI: ssl: add yet another OpenSSL download fallback
Ilya Shipitsin [Fri, 2 Feb 2024 19:33:16 +0000 (20:33 +0100)] 
CI: ssl: add yet another OpenSSL download fallback

17 months agoCI: github: abandon asan matrix.py helper
Ilya Shipitsin [Fri, 2 Feb 2024 19:33:15 +0000 (20:33 +0100)] 
CI: github: abandon asan matrix.py helper

that helper was useful in days when we beleived that gcc and clang
require different flags. those days are gone.

17 months agoMINOR: quic: Stop using 1024th of a second.
Frederic Lecaille [Tue, 6 Feb 2024 17:30:08 +0000 (18:30 +0100)] 
MINOR: quic: Stop using 1024th of a second.

Use milliseconds in place of 1024th of a second.

Should be backported as far as 2.6.

17 months agoBUG/MINOR: quic: fix possible integer wrap around in cubic window calculation
Frederic Lecaille [Wed, 31 Jan 2024 17:21:34 +0000 (18:21 +0100)] 
BUG/MINOR: quic: fix possible integer wrap around in cubic window calculation

Avoid loss of precision when computing K cubic value.
Same issue when computing the congestion window value from cubic increase function
formula with possible integer varaiable wrap around.

Depends on this commit:

MINOR: quic: Code clarifications for QUIC CUBIC (RFC 9438)

Must be backported as far as 2.6.

17 months agoCLEANUP: quic: Code clarifications for QUIC CUBIC (RFC 9438)
Frederic Lecaille [Tue, 30 Jan 2024 10:40:41 +0000 (11:40 +0100)] 
CLEANUP: quic: Code clarifications for QUIC CUBIC (RFC 9438)

The first version of our QUIC CUBIC implementation is confusing because relying on
TCP CUBIC linux kernel implementation and with references to RFC 8312 which is
obsoleted by RFC 9438 (August 2023) after our implementation. RFC 8312 is a little
bit hard to understand. RFC 9438 arrived with much more clarifications.

So, RFC 9438 is about "CUBIC for Fast Long-Distance Networks". Our implementation
for QUIC is not very well documented. As it was difficult to reread this
code, this patch adds only some comments at complicated locations and rename
some macros, variables without logic modifications at all.

So, the aim of this patch is to add first some comments and variables/macros renaming
to avoid embedding too much code modifications in the same big patch.

Some code modifications will come to adapt this CUBIC implementation to this new
RFC 9438.

Rename some macros:
  CUBIC_BETA -> CUBIC_BETA_SCALED
  CUBIC_C    -> CUBIC_C_SCALED
  CUBIC_BETA_SCALE_SHIFT -> CUBIC_SCALE_FACTOR_SHIFT (this is the scaling factor
which is used only for CUBIC_BETA_SCALED)
  CUBIC_DIFF_TIME_LIMIT -> CUBIC_TIME_LIMIT

CUBIC_ONE_SCALED was added (scaled value of 1).

These cubic struct members were renamed:
->tcp_wnd -> ->W_est
->origin_point -> ->W_target
->epoch_start -> ->t_epoch
->remaining_tcp_inc -> remaining_W_est_inc

Local variables to quic_cubic_update() were renamed:
    t -> elapsed_time
    diff ->t
    delta -> W_cubic_t

Add a grahpic curve about the CUBIC Increase function.
Add big copied & pasted RFC 9438 extracts in relation with the 3 different increase
function regions.
Same thing for the fast convergence.
Fix a typo about the reference to QUIC RFC 9002.

Must be backported as far as 2.6 to ease any further modifications to come.

17 months agoDEBUG: make the "debug dev {debug|warn|check}" command print a message
Willy Tarreau [Mon, 5 Feb 2024 15:23:32 +0000 (16:23 +0100)] 
DEBUG: make the "debug dev {debug|warn|check}" command print a message

In order to test the new message output capability, these commands will
now explicitly mention that the bug was triggered from the CLI.

17 months agoMINOR: debug: add an optional message argument to the BUG_ON() family
Willy Tarreau [Mon, 5 Feb 2024 15:20:13 +0000 (16:20 +0100)] 
MINOR: debug: add an optional message argument to the BUG_ON() family

This commit adds support for an optional second argument to BUG_ON(),
WARN_ON(), CHECK_IF(), that can be a constant string. When such an
argument is given, it will be printed on a second line after the
existing first message that contains the condition.

This can be used to provide more human-readable explanations about
what happened, such as "too low on memory" or "memory corruption
detected" that may help a user resolve the incident by themselves.

17 months agoMINOR: debug: support passing an optional message in ABORT_NOW()
Willy Tarreau [Mon, 5 Feb 2024 15:16:08 +0000 (16:16 +0100)] 
MINOR: debug: support passing an optional message in ABORT_NOW()

The ABORT_NOW() macro is not much used since we have BUG_ON(), but
there are situations where it makes sense, typically if the program
must always die regardless od DEBUG_STRICT, or if the condition must
always be evaluated (e.g. decompress something and check it).

It's not convenient not to have any hint about what happened there. But
providing too much info also results in wiping some registers, making
the trace less exploitable, so a compromise must be found.

What this patch does is to provide the support for an optional argument
to ABORT_NOW(). When an argument is passed (a string), then a message
will be emitted with the file name, line number, the message and a
trailing LF, before the stack dump and the crash. It should be used
reasonably, for example in functions that have multiple calls that need
to be more easily distinguished.

17 months agoBUG/MINOR: ssl: Fix error message after ssl_sock_load_ocsp call
Remi Tricot-Le Breton [Thu, 1 Feb 2024 10:58:14 +0000 (11:58 +0100)] 
BUG/MINOR: ssl: Fix error message after ssl_sock_load_ocsp call

If we were to enable 'ocsp-update' on a certificate that does not have
an OCSP URI, we would exit ssl_sock_load_ocsp with a negative error code
which would raise a misleading error message ("<cert> has an OCSP URI
and OCSP auto-update is set to 'on' ..."). This patch simply fixes the
error message but an error is still raised.

This issue was raised in GitHub #2432.
It can be backported up to branch 2.8.

17 months agoMINOR: debug: make BUG_ON() catch build errors even without DEBUG_STRICT
Willy Tarreau [Mon, 5 Feb 2024 14:06:05 +0000 (15:06 +0100)] 
MINOR: debug: make BUG_ON() catch build errors even without DEBUG_STRICT

As seen in previous commit 59acb27001 ("BUILD: quic: Variable name typo
inside a BUG_ON()."), it can sometimes happen that with DEBUG forced
without DEBUG_STRICT, BUG_ON() statements are ignored. Sadly, it means
that typos there are not even build-tested.

This patch makes these statements reference sizeof(cond) to make sure
the condition is parsed. This doesn't result in any code being emitted,
but makes sure the expression is correct so that an issue such as the one
above will fail to build (which was verified).

This may be backported as it can help spot failed backports as well.

17 months agoBUILD: debug: remove leftover parentheses in ABORT_NOW()
Aurelien DARRAGON [Mon, 5 Feb 2024 13:41:16 +0000 (14:41 +0100)] 
BUILD: debug: remove leftover parentheses in ABORT_NOW()

Since d480b7b ("MINOR: debug: make ABORT_NOW() store the caller's line
number when using abort"), building with 'DEBUG_USE_ABORT' fails with:

  |In file included from include/haproxy/api.h:35,
  |                 from include/haproxy/activity.h:26,
  |                 from src/ev_poll.c:20:
  |include/haproxy/thread.h: In function ‘ha_set_thread’:
  |include/haproxy/bug.h:107:47: error: expected ‘;’ before ‘_with_line’
  |  107 | #define ABORT_NOW() do { DUMP_TRACE(); abort()_with_line(__LINE__); } while (0)
  |      |                                               ^~~~~~~~~~
  |include/haproxy/bug.h:129:25: note: in expansion of macro ‘ABORT_NOW’
  |  129 |                         ABORT_NOW();                                    \
  |      |                         ^~~~~~~~~
  |include/haproxy/bug.h:123:9: note: in expansion of macro ‘__BUG_ON’
  |  123 |         __BUG_ON(cond, file, line, crash, pfx, sfx)
  |      |         ^~~~~~~~
  |include/haproxy/bug.h:174:30: note: in expansion of macro ‘_BUG_ON’
  |  174 | #  define BUG_ON(cond)       _BUG_ON     (cond, __FILE__, __LINE__, 3, "FATAL: bug ",     "")
  |      |                              ^~~~~~~
  |include/haproxy/thread.h:201:17: note: in expansion of macro ‘BUG_ON’
  |  201 |                 BUG_ON(!thr->ltid_bit);
  |      |                 ^~~~~~
  |compilation terminated due to -Wfatal-errors.
  |make: *** [Makefile:1006: src/ev_poll.o] Error 1

This is because of a leftover: abort()_with_line(__LINE__);
                                    ^^
Fixing it by removing the extra parentheses after 'abort' since the
abort() call is now performed under abort_with_line() helper function.

This was raised by Ilya in GH #2440.

No backport is needed, unless the above commit gets backported.

17 months agoMINOR: stream: add "txn.redispatch" fetch
Aurelien DARRAGON [Tue, 30 Jan 2024 11:03:28 +0000 (12:03 +0100)] 
MINOR: stream: add "txn.redispatch" fetch

Fetch will return true if the stream underwent a redispatch according to
"option redispatch" setting upon retries.

Documentation was added, and the "%rc" logformat alternative now mentions
the new fetch to properly emulate the logformat behavior.

17 months agoDOC: config: fix ordering for "txn.*" fetches
Aurelien DARRAGON [Tue, 30 Jan 2024 15:20:41 +0000 (16:20 +0100)] 
DOC: config: fix ordering for "txn.*" fetches

Properly re-order "txn.*" fetches by alphabetical name.

17 months agoDOC: config: fix typo for '%ms' log format alternative
Aurelien DARRAGON [Tue, 30 Jan 2024 15:00:40 +0000 (16:00 +0100)] 
DOC: config: fix typo for '%ms' log format alternative

As found in the documentation: '%ms' can be replaced with
%[accept_date(ms),ms_utime("%3N")] alternative, however the closing
bracket was missing.

17 months agoBUILD: quic: Variable name typo inside a BUG_ON().
Frederic Lecaille [Mon, 5 Feb 2024 13:31:21 +0000 (14:31 +0100)] 
BUILD: quic: Variable name typo inside a BUG_ON().

This build issued was introduced by this previous commit which is a bugfix:

   BUG/MINOR: quic: Wrong ack ranges handling when reaching the limit.

A BUG_ON() referenced <fist> variable in place of <first>.

Must be backported as far as 2.6 as the previous commit.

17 months agoBUG/MINOR: quic: Wrong ack ranges handling when reaching the limit.
Frederic Lecaille [Mon, 5 Feb 2024 13:07:51 +0000 (14:07 +0100)] 
BUG/MINOR: quic: Wrong ack ranges handling when reaching the limit.

Acknowledgements ranges are used to build ACK frames. To avoid allocating too
much such objects, a limit was set to 32(QUIC_MAX_ACK_RANGES) by this commit:

MINOR: quic: Do not allocate too much ack ranges

But there is an inversion when removing the oldest range from its tree.
eb64_first() must be used in place of eb64_last(). Note that this patch
only does this modification in addition to rename <last> variable to <first>.

This bug leads such a h2load command to block when a request ends up not
being acknowledged by haproxy even if correctly served:

/opt/nghttp2/build/bin/h2load --alpn-list h3 -t 1 -c 1 -m 1 -n 100 \
https://127.0.0.1/?s=5m

There is a remaining question to be answered. In such a case, haproxy refuses to
reopen the stream, this is a good thing but should not haproxy ackownledge the
request (because correctly parsed again).

Note that to be easily reproduced, this setting had to be applied to the client
network interface:

    tc qdisc add dev eth1 root netem delay 100ms 1s loss random

Must be backported as far as 2.6.

17 months agoMINOR: acl: add extra diagnostics about suspicious string patterns
Willy Tarreau [Sat, 3 Feb 2024 10:55:26 +0000 (11:55 +0100)] 
MINOR: acl: add extra diagnostics about suspicious string patterns

As noticed in this thread, some bogus configurations are not always easy
to spot: https://www.mail-archive.com/haproxy@formilux.org/msg44558.html
Here it was about config keywords being used in ACL patterns where strings
were expected, hence they're always valid.

Since we have the diag mode (-dD) we can perform some extra checks when
it's used, and emit them to suggest the user there might be an issue.

Here we detect a few common words (logic such as "and"/"or"/"||" etc),
C++/JS comments mistakenly used to try to isolate final args, and words
that have the exact name of a sample fetch or an ACL keyword. These checks
are only done in diag mode of course.

17 months agoBUG/MINOR: diag: run the final diags before quitting when using -c
Willy Tarreau [Sat, 3 Feb 2024 11:05:08 +0000 (12:05 +0100)] 
BUG/MINOR: diag: run the final diags before quitting when using -c

Final diags were added in 2.4 by commit 5a6926dcf ("MINOR: diag: create
cfgdiag module"), but it's called too late in the startup process,
because when "-c" is passed, the call is not made, while it's its primary
use case. Let's just move the call earlier.

Note that currently the check in this function is limited to verifying
unicity of server cookies in a backend, so it can be backported as far
as 2.4, but there is little value in insisting if it doesn't backport
easily.

17 months agoBUG/MINOR: diag: always show the version before dumping a diag warning
Willy Tarreau [Sat, 3 Feb 2024 11:01:58 +0000 (12:01 +0100)] 
BUG/MINOR: diag: always show the version before dumping a diag warning

Diag warnings were added in 2.4 by commit 7b01a8dbd ("MINOR: global:
define diagnostic mode of execution") but probably due to the split
function that checks for the mode, they did not reuse the emission of
the version string before the first warning, as was brought in 2.2 by
commit bebd21206 ("MINOR: init: report in "haproxy -c" whether there
were warnings or not"). The effet is that diag warnings are emitted
before the version string if there is no other warning nor error. Let's
just proceed like for the two other ones.

This can be backported to 2.4, though this is of very low importance.

17 months agoMINOR: debug: make ABORT_NOW() store the caller's line number when using abort
Willy Tarreau [Fri, 2 Feb 2024 16:09:09 +0000 (17:09 +0100)] 
MINOR: debug: make ABORT_NOW() store the caller's line number when using abort

Placing DO_NOT_FOLD() before abort() only works in -O2 but not in -Os which
continues to place only 5 calls to abort() in h3.o for call places. The
approach taken here is to replace abort() with a new function that wraps
it and stores the line number in the stack. This slightly increases the
code size (+0.1%) but when unwinding a crash, the line number remains
present now. This is a very low cost, especially if we consider that
DEBUG_USE_ABORT is almost only used by code coverage tools and occasional
debugging sessions.

17 months agoMINOR: debug: make sure calls to ha_crash_now() are never merged
Willy Tarreau [Fri, 2 Feb 2024 16:05:36 +0000 (17:05 +0100)] 
MINOR: debug: make sure calls to ha_crash_now() are never merged

As indicated in previous commit, we don't want calls to ha_crash_now()
to be merged, since it will make gdb return a wrong line number. This
was found to happen with gcc 4.7 and 4.8 in h3.c where 26 calls end up
as only 5 to 18 "ud2" instructions depending on optimizations. By
calling DO_NOT_FOLD() just before provoking the trap, we can reliably
avoid this folding problem. Note that this does not address the case
where abort() is used instead (DEBUG_USE_ABORT).

17 months agoMINOR: compiler: add a new DO_NOT_FOLD() macro to prevent code folding
Willy Tarreau [Fri, 2 Feb 2024 16:00:01 +0000 (17:00 +0100)] 
MINOR: compiler: add a new DO_NOT_FOLD() macro to prevent code folding

Modern compilers sometimes perform function tail merging and identical
code folding, which consist in merging identical occurrences of same
code paths, generally final ones (e.g. before a return, a jump or an
unreachable statement). In the case of ABORT_NOW(), it can happen that
the compiler merges all of them into a single one in a function,
defeating the purpose of the check which initially was to figure where
the bug occurred.

Here we're creating a DO_NO_FOLD() macro which makes use of the line
number and passes it as an integer argument to an empty asm() statement.
The effect is a code position dependency which prevents the compiler
from merging the code till that point (though it may still merge the
following code). In practice it's efficient at stopping the compilers
from merging calls to ha_crash_now(), which was the initial purpose.

It may also be used to force certain optimization constructs since it
gives more control to the developer.

17 months agoREGTESTS: promex: Adapt script to be less verbose
Christopher Faulet [Thu, 1 Feb 2024 13:20:00 +0000 (14:20 +0100)] 
REGTESTS: promex: Adapt script to be less verbose

First, checks on the resolver scope were added. Then, because of the recent
changes, the logs emitted by vtest are now too big and this makes the script
fails. So tests on NaN values are now performed on a smaller request. This
reduces enough the logs to pass.

In fact some checks were removed

17 months agoMEDIUM: promex: Add support for filters on metric names
Christopher Faulet [Wed, 31 Jan 2024 16:15:49 +0000 (17:15 +0100)] 
MEDIUM: promex: Add support for filters on metric names

It is now possible to filter the metrics on their name, by listing
explicitly metrics to dump or on the opposite to exclude only some metrics
from the dump. To do so, a comma-separated list of metrics must be
specified. If a name is preceded by a minus (-), the metric is excluded from
the dump. If at least one metric is specified to be explicitly dumped, all
metrics are no longer dumped, but only those explicitly listed.

The list is specified via one or more "metrics" parameters in the uri
query-string. For insance:

  # Dumped all metrics, except "haproxy_server_check_status"
  /metrics?metrics=-haproxy_server_check_status

  # Only dump frontends, backends and servers status
  /metrics?metrics=haproxy_frontend_status,haproxy_backend_status,haproxy_server_status

Included and Excluded metrics can be mixed. Only the intersection will be
dumped.

This patch should fix the issue #770.

17 months agoMINOR: promex: Always pass the final name and description to promex_dmp_ts()
Christopher Faulet [Wed, 31 Jan 2024 10:54:58 +0000 (11:54 +0100)] 
MINOR: promex: Always pass the final name and description to promex_dmp_ts()

It is easier this way, especially for promex modules. And because name and
description are now explicitly passed to this function, there is no reason
to still pass the metric, its type is enough. The function is easier to read
this way.

17 months agoMINOR: promex: Rename dump functions to use the right wording
Christopher Faulet [Wed, 31 Jan 2024 09:42:10 +0000 (10:42 +0100)] 
MINOR: promex: Rename dump functions to use the right wording

In Prometheus, a time series a stream of timestamped values belonging to the
same metric and the same set of labeled dimensions. Thus the exporter dump
time-series and not metrics.

Thus, promex_dump_metric(), promex_dump_metric_header() and
promex_metric_to_str() functions were renamed to replace "metric"

17 months agoMEDIUM: promex/resolvers: Dump resolvers metrics via a promex module
Christopher Faulet [Wed, 31 Jan 2024 09:34:14 +0000 (10:34 +0100)] 
MEDIUM: promex/resolvers: Dump resolvers metrics via a promex module

Just like for stick-tables, this patch adds a promex module to dump
resolvers metrics. It adds the "resolver" scope and for now, it dumps
folloowing metrics:

  * haproxy_resolver_sent
  * haproxy_resolver_send_error
  * haproxy_resolver_valid
  * haproxy_resolver_update
  * haproxy_resolver_cname
  * haproxy_resolver_cname_error
  * haproxy_resolver_any_err
  * haproxy_resolver_nx
  * haproxy_resolver_timeout
  * haproxy_resolver_refused
  * haproxy_resolver_other
  * haproxy_resolver_invalid
  * haproxy_resolver_too_big
  * haproxy_resolver_outdated

17 months agoMEDIUM: promex/stick-table: Dump stick-table metrics via a promex module
Christopher Faulet [Wed, 31 Jan 2024 09:33:55 +0000 (10:33 +0100)] 
MEDIUM: promex/stick-table: Dump stick-table metrics via a promex module

Create a promex module to dump stick-table metrics. Thanks to this patch,
all references to stick tables were removed from the promex service.

17 months agoMEDIUM: promex: Dump metrics of registered modules with a way to filter them
Christopher Faulet [Tue, 30 Jan 2024 14:58:31 +0000 (15:58 +0100)] 
MEDIUM: promex: Dump metrics of registered modules with a way to filter them

This patch adds a dump loop on the registered modules. It is very similar to
other dump loops. When a module registered, a implicit scope is created with
the module's name. It means a module name must be unique. It also means,
metrics dump of modules can be filtered via the "scope" parameter.

17 months agoMEDIUM: promex: Add a registration mechanism to support modules
Christopher Faulet [Tue, 30 Jan 2024 06:34:54 +0000 (07:34 +0100)] 
MEDIUM: promex: Add a registration mechanism to support modules

In this patch we add a registration mechanism for modules. To do so, a
module must defined the "promex_module" structure. The dump itself will be
based on 2 contexts. One for all the dump and another one for each metric
time-series. These contexts are used as restart points when the dump is
interrupted.

Modules must also implement 6 callback functions:

  * start_metric_dump(): It is an optional callback function. If defined, it
                         is responsible to initialize the dump context use
                         as the first restart point.

  * stop_metric_dump(): It is an optional callback function. If defined, it
                        is responsible to deinit the dump context.

  * metric_info(): This one is mandatory. It returns the info about the
                   metric: name, type and flags and descrition.

  * start_ts(): This one is mandatory, it initializes the context for a time
                series for a given metric. This context is the second
                restart point.

  * next_ts(): This one is mandatory. It interates on time series for a
               given metrics. It is also responsible to handle end of a
               time series and deinit the context.

  * fill_ts(): It fills info on the time series for a given metric : the
               labels and the value.

In addition, a module must set its name and declare the number of metrics is
exposed.

17 months agoMINOR: promex: Remove unsued htx parameter when a metric is dumped
Christopher Faulet [Tue, 30 Jan 2024 13:42:02 +0000 (14:42 +0100)] 
MINOR: promex: Remove unsued htx parameter when a metric is dumped

the HTX parameter in promex_dump_metric() and promex_dump_metric_header()
was not used. Let's remove it.

17 months agoMEDIUM: promex: Simplify the context using generic pointers for restart points
Christopher Faulet [Tue, 30 Jan 2024 13:36:07 +0000 (14:36 +0100)] 
MEDIUM: promex: Simplify the context using generic pointers for restart points

Instead of using typed pointers to save the restart points we know use
generic pointers. 4 pointers can be saved now. This replaces the 5 typed
pointers used before. So, we save 8-bytes but it is also more generic and
this will be used by the promex modules.

17 months agoMINOR: promex: Always limit the number of labels dumped for each metric
Christopher Faulet [Mon, 29 Jan 2024 16:19:28 +0000 (17:19 +0100)] 
MINOR: promex: Always limit the number of labels dumped for each metric

It was not an issue since now, be a way to register modules on promex will
be added. Thus it is important to add some extra checks. Here, we take care
to never dump more than the max labels allowed.

17 months agoDOC: promex: Add documentation about extra-counters
Christopher Faulet [Mon, 29 Jan 2024 15:55:01 +0000 (16:55 +0100)] 
DOC: promex: Add documentation about extra-counters

Now the feature is fully implementated, the README is updated accordingly.

17 months agoMEDIUM: promex: Dump listeners extra counters if requested
Christopher Faulet [Mon, 29 Jan 2024 15:42:02 +0000 (16:42 +0100)] 
MEDIUM: promex: Dump listeners extra counters if requested

Dump extra counter for the listeners. We loop on stats modules and dumped
all concerned counters. The module name is reported with the "mod" label.

17 months agoMEDIUM: promex: Dump servers extra counters if requested
Christopher Faulet [Mon, 29 Jan 2024 15:41:56 +0000 (16:41 +0100)] 
MEDIUM: promex: Dump servers extra counters if requested

Dump extra counter for the servers. We loop on stats modules and dumped all
concerned counters. The module name is reported with the "mod" label.

17 months agoMEDIUM: promex: Dump backends extra counters if requested
Christopher Faulet [Mon, 29 Jan 2024 15:41:42 +0000 (16:41 +0100)] 
MEDIUM: promex: Dump backends extra counters if requested

Dump extra counter for the backend. We loop on stats modules and dumped all
concerned counters. The module name is reported with the "mod" label.

17 months agoMEDIUM: promex: Dump frontends extra counters if requested
Christopher Faulet [Mon, 29 Jan 2024 15:41:24 +0000 (16:41 +0100)] 
MEDIUM: promex: Dump frontends extra counters if requested

Dump extra counter for the frontends. We loop on stats modules and dumped
all concerned counters. The module name is reported with the "mod" label.

17 months agoMINOR: promex: Add info in the promex context to dump extra counters
Christopher Faulet [Mon, 29 Jan 2024 15:40:41 +0000 (16:40 +0100)] 
MINOR: promex: Add info in the promex context to dump extra counters

The context of the promex applet was extended to support the dump of extra
counters. These counters are not dumped yet, but info to interrupt and
restart the dump are required. The stats module and the relative field
number for this module can now be saved.

In addition support for "extra-counters" parameter was added on the
query-string to dump these counters. Otherwise, no extra-counters are
dumped.

17 months agoMINOR: promex: Add a param to override the description when a metric is dumped
Christopher Faulet [Mon, 29 Jan 2024 15:37:35 +0000 (16:37 +0100)] 
MINOR: promex: Add a param to override the description when a metric is dumped

When a metric is dumped, it is now possible to specify a custom
description. We will add the support for extra counters. The list of these
counters is retrived dynamically. Thus the description must be dynamic
too. Note it was already possible to customize the metric name.

17 months agoMEDIUM: stats: Be able to access a specific field into a stats module
Christopher Faulet [Mon, 29 Jan 2024 15:35:19 +0000 (16:35 +0100)] 
MEDIUM: stats: Be able to access a specific field into a stats module

It is now possible to selectively retrieve extra counters from stats
modules. H1, H2, QUIC and H3 fill_stats() callback functions are updated to
return a specific counter.

17 months agoMINOR: stats: Be able to access to registered stats modules from anywhere
Christopher Faulet [Mon, 29 Jan 2024 15:34:23 +0000 (16:34 +0100)] 
MINOR: stats: Be able to access to registered stats modules from anywhere

The list of modules registered on the stats to expose extra counters is now
public. It is required to export these counters into the Prometheus
exporter.

17 months agoMEDIUM: tcp-act/backend: support for set-bc-{mark,tos} actions
Aurelien DARRAGON [Thu, 18 Jan 2024 17:51:26 +0000 (18:51 +0100)] 
MEDIUM: tcp-act/backend: support for set-bc-{mark,tos} actions

set-bc-{mark,tos} actions are pretty similar to set-fc-{mark,tos} to set
mark/tos on packets sent from haproxy to server: set-bc-{mark,tos} actions
act on the whole backend/srv connection: from connect() to connection
teardown, thus they may only be used before the connection to the server
is instantiated, meaning that they are only relevant for request-oriented
rules such as tcp-request or http-request rules. For now their use is
limited to content request rules, because tos and mark informations are
stored directly within the stream, thus it is required that the stream
already exists.

stream flags are used in combination with dedicated stream struct members
variables to pass 'tos' and 'mark' informations so that they are correctly
considered during stream connection assignment logic (prior to connecting
to actually connecting to the server)

'tos' and 'mark' fd sockopts are taken into account in conn hash
parameters for connection reuse mechanism.

The documentation was updated accordingly.

17 months agoMEDIUM: tcp-act: <expr> support for set-fc-{mark,tos} actions
Aurelien DARRAGON [Thu, 18 Jan 2024 16:17:41 +0000 (17:17 +0100)] 
MEDIUM: tcp-act: <expr> support for set-fc-{mark,tos} actions

In this patch we add the possibility to use sample expression as argument
for set-fc-{mark,tos} actions. To make it backward compatible with
previous behavior, during parsing we first try to parse the value as
as integer (decimal or hex notation), and then fallback to expr parsing
in case of failure.

The documentation was updated accordingly.

17 months agoMINOR: hlua: Rename set_{tos, mark} to set_fc_{tos, mark}
Aurelien DARRAGON [Mon, 15 Jan 2024 15:33:04 +0000 (16:33 +0100)] 
MINOR: hlua: Rename set_{tos, mark} to set_fc_{tos, mark}

This is a complementary patch to "MINOR: tcp-act: Rename "set-{mark,tos}"
to "set-fc-{mark,tos}"", but for the Lua API.

set_mark and set_tos were kept as aliases for set_fc_mark and set_fc_tos
but they were marked as deprecated.

Using this opportunity to reorder set_mark and set_tos by alphabetical
order.

17 months agoMINOR: tcp-act: Rename "set-{mark,tos}" to "set-fc-{mark,tos}"
Aurelien DARRAGON [Mon, 15 Jan 2024 15:08:40 +0000 (16:08 +0100)] 
MINOR: tcp-act: Rename "set-{mark,tos}" to "set-fc-{mark,tos}"

"set-mark" and "set-tos" only alter packets from haproxy to client
(frontend connection). Since we may add support for equivalent keywords
on server side, we rename them with an explicit name to prevent
confusions.

Thus, we rename:
 - "set-mark" to "set-fc-mark"
 - "set-tos" to "set-fc-tos"

"set-mark" and "set-tos" were kept as aliases (to "set-fc-mark" and
"set-fc-tos" respectively) for now to prevent config breakage, but they
have been marked as deprecated so they can be removed in future version.

17 months agoMINOR: tcp_act: fix alphabetical ordering of tcp request content actions
Aurelien DARRAGON [Thu, 1 Feb 2024 08:53:10 +0000 (09:53 +0100)] 
MINOR: tcp_act: fix alphabetical ordering of tcp request content actions

"set-src" and "set-src-port" were misplaced and incorrectly ordered in
tcp_req_cont_actions keyword list.

17 months agoOPTIM: connection: progressive hash for conn_calculate_hash()
Aurelien DARRAGON [Thu, 25 Jan 2024 09:35:39 +0000 (10:35 +0100)] 
OPTIM: connection: progressive hash for conn_calculate_hash()

Some CPU time is needlessly wasted in conn_calculate_hash(), because all
params are first copied into a temporary buffer before computing the
hash on the whole buffer. Instead, let's leverage the XXH progressive
hash update functions to avoid expensive memcpys.

17 months agoCLEANUP: connection: remove obsolete comment in header file
Aurelien DARRAGON [Thu, 18 Jan 2024 16:58:30 +0000 (17:58 +0100)] 
CLEANUP: connection: remove obsolete comment in header file

0x00000008 bit for CO_FL_* flags is no more unused since 8cc3fc73f1
("MINOR: connection: update rhttp flags usage"). Removing the comment
that says otherwise.

17 months agoMINOR: mux-quic: realign Tx buffer if possible
Amaury Denoyelle [Wed, 17 Jan 2024 15:01:00 +0000 (16:01 +0100)] 
MINOR: mux-quic: realign Tx buffer if possible

A major reorganization of QUIC MUX sending has been implemented. Now
data transfer occur over a single QCS buffer. This has improve
performance but at the cost of restrictions on snd_buf. Indeed, buffer
instances are now shared from stream callback snd_buf up to quic-conn
layer.

As such, snd_buf cannot manipulate freely already present data buffer.
In particular, realign has been completely removed by the previous
patches.

This commit reintroduces a partial realign support. This is only done if
the buffer contains only unsent data, via a new MUX function
qcc_realign_stream_txbuf() which is called during snd_buf.

17 months agoMEDIUM: mux-quic: properly handle conn Tx buf exhaustion
Amaury Denoyelle [Wed, 17 Jan 2024 14:15:55 +0000 (15:15 +0100)] 
MEDIUM: mux-quic: properly handle conn Tx buf exhaustion

This commit is a direct follow-up on the major rearchitecture of send
buffering. This patch implements the proper handling of connection pool
buffer temporary exhaustion.

The first step is to be able to differentiate a fatal allocation error
from a temporary pool exhaustion. This is done via a new output argument
on qcc_get_stream_txbuf(). For a fatal error, application protocol layer
will schedule the immediate connection closing. For a pool exhaustion,
QCC is flagged with QC_CF_CONN_FULL and stream sending process is
interrupted. QCS instance is also registered in a new list
<qcc.buf_wait_list>.

A new connection buffer can become available when all ACKs are received
for an older buffer. This process is taken in charge by quic-conn layer.
It uses qcc_notify_buf() function to clear QC_CF_CONN_FULL and to wake
up every streams registered on buf_wait_list to resume sending process.

17 months agoMEDIUM: mux-quic: release Tx buf on too small room
Amaury Denoyelle [Mon, 22 Jan 2024 16:03:41 +0000 (17:03 +0100)] 
MEDIUM: mux-quic: release Tx buf on too small room

This commit is a direct follow-up on the major rearchitecture of send
buffering. It allows application protocol to react if current QCS
sending buffer space is too small. In this case, the buffer can be
released to the quic-conn layer. This allows to allocate a new QCS
buffer and retry HTX parsing, unless connection buffer pool is already
depleted.

A new function qcc_release_stream_txbuf() serves as API for app protocol
to release the QCS sending buffer. This operation fails if there is
unsent data in it. In this case, MUX has to keep it to finalize transfer
of unsent data to quic-conn layer. QCS is thus flagged with
QC_SF_BLK_MROOM to interrupt snd_buf operation.

When all data are sent to the quic-conn layer, QC_SF_BLK_MROOM is
cleared via qcc_streams_sent_done() and stream layer is woken up to
restart snd_buf.

Note that a new function qcc_stream_can_send() has been defined. It
allows app proto to check if sending is currently blocked for the
current QCS. For now, it checks QC_SF_BLK_MROOM flag. However, it will
be extended to other conditions with the following patches.

17 months agoMEDIUM: mux-quic: simplify sending API
Amaury Denoyelle [Tue, 30 Jan 2024 10:23:48 +0000 (11:23 +0100)] 
MEDIUM: mux-quic: simplify sending API

The previous commit was a major rework for QUIC MUX sending process.
Following this, this patch cleans up a few elements that remains but can
be removed as they are duplicated.

Of notable changes, offset fields from QCS and QCC are removed. They are
both equivalent to flow control soft offsets.

A new function qcs_prep_bytes() is implemented. Its purpose is to return
the count of prepared data bytes not yet sent. It also replaces
qcs_need_sending().

17 months agoMAJOR: mux-quic: remove intermediary Tx buffer
Amaury Denoyelle [Tue, 16 Jan 2024 15:47:57 +0000 (16:47 +0100)] 
MAJOR: mux-quic: remove intermediary Tx buffer

Previously, QUIC MUX sending was implemented with data transfered along
two different buffer instances per stream.

The first QCS buffer was used for HTX blocks conversion into H3 (or
other application protocol) during snd_buf stream callback. QCS instance
is then registered for sending via qcc_io_cb().

For each sending QCS, data memcpy is performed from the first to a
secondary buffer. A STREAM frame is produced for each QCS based on the
content of their secondary buffer.

This model is useful for QUIC MUX which has a major difference with
other muxes : data must be preserved longer, even after sent to the
lower layer. Data references is shared with quic-conn layer which
implements retransmission and data deletion on ACK reception.

This double buffering stages was the first model implemented and remains
active until today. One of its major drawbacks is that it requires
memcpy invocation for every data transferred between the two buffers.
Another important drawback is that the first buffer was is allocated by
each QCS individually without restriction. On the other hand, secondary
buffers are accounted for the connection. A bottleneck can appear if
secondary buffer pool is exhausted, causing unnecessary haproxy
buffering.

The purpose of this commit is to completely break this model. The first
buffer instance is removed. Now, application protocols will directly
allocate buffer from qc_stream_desc layer. This removes completely the
memcpy invocation.

This commit has a lot of code modifications. The most obvious one is the
removal of <qcs.tx.buf> field. Now, qcc_get_stream_txbuf() returns a
buffer instance from qc_stream_desc layer. qcs_xfer_data() which was
responsible for the memcpy between the two buffers is also completely
removed. Offset fields of QCS and QCC are now incremented directly by
qcc_send_stream(). These values are used as boundary with flow control
real offset to delimit the STREAM frames built.

As this change has a big impact on the code, this commit is only the
first part to fully support single buffer emission. For the moment, some
limitations are reintroduced and will be fixed in the next patches :

* on snd_buf if QCS sent buffer in used has room but not enough for the
  application protocol to store its content
* on snd_buf if QCS sent buffer is NULL and allocation cannot succeeds
  due to connection pool exhaustion

One final important aspect is that extra care is necessary now in
snd_buf callback. The same buffer instance is referenced by both the
stream and quic-conn layer. As such, some operation such as realign
cannot be done anymore freely.

17 months agoMINOR: mux-quic: check fctl during STREAM frame build
Amaury Denoyelle [Wed, 24 Jan 2024 10:54:41 +0000 (11:54 +0100)] 
MINOR: mux-quic: check fctl during STREAM frame build

qcs_build_stream_frm() is responsible to generate a STREAM frame
pointing to the content of QCS TX buffer.

This patch moves send flow control overflow check from qcs_xfer_data()
to qcs_build_stream_frm(), i.e. from transfer between internal
QCS buffer and qc_stream_desc, to STREAM frame generation.

Flow control is both check at stream and connection level. For
connection flow control, as several frames are built before emission, an
accumulator is used as extra arguments to functions to account the total
length of already built frames.

This patch should not provide any functional changes. Its main purpose
is to prepare for the removal of QCS internal buffer.

17 months agoMINOR: mux-quic: remove unneeded sent-offset fields
Amaury Denoyelle [Tue, 9 Jan 2024 10:37:56 +0000 (11:37 +0100)] 
MINOR: mux-quic: remove unneeded sent-offset fields

Both QCS and QCC have their owned sent offset field. These fields store
the newest offset sent to the quic-conn layer. It is similar to QCS/QCC
flow control real offset. This patch removes them and replaces them by
the latter for code clarification.

MINOR: mux-quic: remove unneeded qcc.tx.sent_offsets field

This commit as a similar purpose as previous, except that it removes QCC
<sent_offsets> field, now equivalent to connection flow control real
offset.

17 months agoMEDIUM: mux-quic: limit conn flow control on snd_buf
Amaury Denoyelle [Wed, 18 Oct 2023 15:48:11 +0000 (17:48 +0200)] 
MEDIUM: mux-quic: limit conn flow control on snd_buf

This commit is a direct follow-up on the previous one. This time, it
deals with connection level flow control. Process is similar to stream
level : soft offset is incremented during snd_buf and real offset during
STREAM frame emission.

On MAX_DATA reception, both stream layer and QMUX is woken up if
necessary. One extra feature for conn level is the introduction of a new
QCC list to reference QCS instances. It will store instances for which
snd_buf callback has been interrupted on QCC soft offset reached. Every
stream instances is woken up on MAX_DATA reception if soft_offset is
unblocked.

17 months agoMEDIUM: mux-quic: limit stream flow control on snd_buf
Amaury Denoyelle [Wed, 18 Oct 2023 13:55:38 +0000 (15:55 +0200)] 
MEDIUM: mux-quic: limit stream flow control on snd_buf

This patch is the first of two to reimplement flow control emission
limits check. The objective is to account flow control earlier during
snd_buf stream callback. This should smooth transfers and prevent over
buffering on haproxy side if flow control limit is reached.

The current patch deals with stream level flow control. It reuses the
newly defined flow control type. Soft offset is incremented after HTX to
data conversion. If limit is reached, snd_buf is interrupted and stream
layer will subscribe on QCS.

On qcc_io_cb(), generation of STREAM frames is restricted as previously
to ensure to never surpass peer limits. Finally, flow control real
offset is incremented on lower layer send notification. Thus, it will
serve as a base offset for built STREAM frames. If limit is reached,
STREAM frames generation is suspended.

Each time QCS data flow control limit is reached, soft and real offsets
are reconsidered.

Finally, special care is used when flow control limit is incremented via
MAX_STREAM_DATA reception. If soft value is unblocked, stream layer
snd_buf is woken up. If real value is unblocked, qcc_io_cb() is
rescheduled.

17 months agoMINOR: mux-quic: define a flow control related type
Amaury Denoyelle [Wed, 3 Jan 2024 15:14:52 +0000 (16:14 +0100)] 
MINOR: mux-quic: define a flow control related type

Create a new module dedicated to flow control handling. It will be used
to implement earlier flow control update on snd_buf stream callback.

For the moment, only Tx part is implemented (i.e. limit set by the peer
that haproxy must respect for sending). A type quic_fctl is defined to
count emitted data bytes. Two offsets are used : a real one and a soft
one. The difference is that soft offset can be incremented beyond limit
unless it is already in excess.

Soft offset will be used for HTX to H3 parsing. As size of generated H3
is unknown before parsing, it allows to surpass the limit one time. Real
offset will be used during STREAM frame generation : this time the limit
must not be exceeded to prevent protocol violation.

17 months agoMINOR: mux-quic: prepare for earlier flow control update
Amaury Denoyelle [Wed, 10 Jan 2024 10:09:33 +0000 (11:09 +0100)] 
MINOR: mux-quic: prepare for earlier flow control update

Add a new argument to qcc_send_stream() to specify the count of sent
bytes.

For the moment this argument is unused. This commit is in fact a step to
implement earlier flow control update during stream layer snd_buf.

17 months agoBUG/MINOR: ssl/quic: fix 0RTT define
Amaury Denoyelle [Wed, 31 Jan 2024 15:20:00 +0000 (16:20 +0100)] 
BUG/MINOR: ssl/quic: fix 0RTT define

Previous patches have reorganize define definitions for SSL 0RTT
support. However a typo was introduced. This caused haproxy to disable
0RTT support announcement and report of an erroneous warning for no
support on the SSL library side when using quictls/openssl compat layer.

This was detected by using ngtcp2-client. No 0RTT packet were emitted by
the client due to haproxy missing support advertisement.

The faulty commit is the following one :
  commit 5c4519934708bfe6a26b9ad0cc93a8c5c87df112
  MEDIUM: ssl/quic: always compile the ssl_conf.early_data test

This must be backported wherever the above patch is.

17 months agoCLEANUP: h1: remove unused function h1_measure_trailers()
Willy Tarreau [Wed, 31 Jan 2024 14:21:06 +0000 (15:21 +0100)] 
CLEANUP: h1: remove unused function h1_measure_trailers()

This one stopped being used in 2.1 when HTX became mandatory,
let's drop it.

17 months agoBUG/MEDIUM: h1: always reject the NUL character in header values
Willy Tarreau [Wed, 31 Jan 2024 14:10:39 +0000 (15:10 +0100)] 
BUG/MEDIUM: h1: always reject the NUL character in header values

Ben Kallus kindly reported that we still hadn't blocked the NUL
character from header values as clarified in RFC9110 and that, even
though there's no known issure related to this, it may one day be
used to construct an attack involving another component.

Actually, both Christopher and I sincerely believed we had done it
prior to releasing 2.9, shame on us for missing that one and thanks
to Ben for the reminder!

The change was applied, it was confirmed to properly reject this NUL
byte from both header and trailer values, and it's still possible to
force it to continue to be supported using the usual pair of unsafe
"option accept-invalid-http-{request|response}" for those who would
like to keep it for whatever reason that wouldn't make sense.

This was tagged medium so that distros also remember to apply it as
a preventive measure.

It should progressively be backported to all versions down to 2.0.

17 months agoBUG/MINOR: h1-htx: properly initialize the err_pos field
Willy Tarreau [Wed, 31 Jan 2024 14:04:11 +0000 (15:04 +0100)] 
BUG/MINOR: h1-htx: properly initialize the err_pos field

Trailers are parsed using a temporary h1m struct, likely due to using
distinct h1 parser states. However, the err_pos field that's used to
decide whether or not to enfore option accept-invalid-http-request (or
response) was not initialized in this struct, resulting in using a
random value that may randomly accept or reject a few bad chars. The
impact is very limited in trailers (e.g. no message size is transmitted
there) but we must make sure that the option is respected, at least for
users facing the need for this option there.

The issue was introduced in 2.0 by commit 2d7c5395ed ("MEDIUM: htx:
Add the parsing of trailers of chunked messages"), and the code moved
from mux_h1.c to h1_htx.c in 2.1 with commit 4f0f88a9d0 ("MEDIUM:
mux-h1/h1-htx: move HTX convertion of H1 messages in dedicated file")
so the patch needs to be backported to all stable versions, and the
file adjusted for 2.0.

17 months agoDOC: httpclient: add dedicated httpclient section
Lukas Tribus [Tue, 30 Jan 2024 21:17:44 +0000 (21:17 +0000)] 
DOC: httpclient: add dedicated httpclient section

Move httpclient keywords into its own section and explain adding
an introductory paragraph.

Also see Github issue #2409

Should be backported to 2.6 ; but note that:
2.7 does not have httpclient.resolvers.disabled
2.6 does not have httpclient.retries and httpclient.timeout.connect

17 months agoMEDIUM: ssl/quic: always compile the ssl_conf.early_data test
William Lallemand [Mon, 29 Jan 2024 17:36:31 +0000 (18:36 +0100)] 
MEDIUM: ssl/quic: always compile the ssl_conf.early_data test

Always compile the test of the early_data variable in
"ssl_quic_initial_ctx", this way we can emit a warning about its support
or not.

The test was moved in a more simple preprocessor check which only checks
the new HAVE_SSL_0RTT_QUIC constant.

Could be backported to 2.9 with the 2 previous commits.
However AWS-LC must be excluded of HAVE_SSL_0RTT_QUIC in this version.

17 months agoMINOR: ssl: rename HA_OPENSSL_HAVE_0RTT_SUPPORT constant to HAVE_SSL_0RTT_QUIC
William Lallemand [Mon, 29 Jan 2024 17:26:19 +0000 (18:26 +0100)] 
MINOR: ssl: rename HA_OPENSSL_HAVE_0RTT_SUPPORT constant to HAVE_SSL_0RTT_QUIC

Rename the constant to be me more comprehensive.

17 months agoMINOR: ssl: add HAVE_SSL_0RTT constant
William Lallemand [Mon, 29 Jan 2024 17:17:04 +0000 (18:17 +0100)] 
MINOR: ssl: add HAVE_SSL_0RTT constant

Add the HAVE_SSL_0RTT constant which define if the SSL library supports
0RTT. Which is different from HA_OPENSSL_HAVE_0RTT_SUPPORT which was
used only in the context of QUIC

17 months agoBUG/MEDIUM: h1: Don't support LF only to mark the end of a chunk size
Christopher Faulet [Fri, 26 Jan 2024 15:30:53 +0000 (16:30 +0100)] 
BUG/MEDIUM: h1: Don't support LF only to mark the end of a chunk size

It is similar to the previous fix but for the chunk size parsing. But this
one is more annoying because a poorly coded application in front of haproxy
may ignore the last digit before the LF thinking it should be a CR. In this
case it may be out of sync with HAProxy and that could be exploited to
perform some sort or request smuggling attack.

While it seems unlikely, it is safer to forbid LF with CR at the end of a
chunk size.

This patch must be backported to 2.9 and probably to all stable versions
because there is no reason to still support LF without CR in this case.

17 months agoBUG/MINOR: h1: Don't support LF only at the end of chunks
Christopher Faulet [Fri, 26 Jan 2024 15:23:51 +0000 (16:23 +0100)] 
BUG/MINOR: h1: Don't support LF only at the end of chunks

When the message is chunked, all chunks must ends with a CRLF. However, on
old versions, to support bad client or server implementations, the LF only
was also accepted. Nowadays, it seems useless and can even be considered as
an issue. Just forbid LF only at the end of chunks, it seems reasonnable.

This patch must be backported to 2.9 and probably to all stable versions
because there is no reason to still support LF without CR in this case.

17 months agoCLEANUP: log: deinitialization of the log buffer in one function
Miroslav Zagorac [Tue, 30 Jan 2024 02:14:09 +0000 (03:14 +0100)] 
CLEANUP: log: deinitialization of the log buffer in one function

In several places in the source, there was the same block of code that was
used to deinitialize the log buffer.  There were even two functions that
did this, but they were called only from the code that is in the same
source file (free_tcpcheck_fmt() in src/tcpcheck.c and free_logformat_list()
in src/proxy.c - they were both static functions).

The function free_logformat_list() was moved from the file src/proxy.c to
src/log.c, and a check of the list before freeing the memory was added to
that function.

17 months agoBUG/MEDIUM: quic: fix crash on invalid qc_stream_buf_free() BUG_ON
Amaury Denoyelle [Mon, 29 Jan 2024 08:18:08 +0000 (09:18 +0100)] 
BUG/MEDIUM: quic: fix crash on invalid qc_stream_buf_free() BUG_ON

A recent fix was introduced to ensure unsent data are deleted when a
QUIC MUX stream releases its qc_stream_desc instance. This is necessary
to ensure all used buffers will be liberated once all ACKs are received.
This is implemented by the following patch :

  commit ad6b13d3177945bf6a85d6dc5af80b8e34ea6191 (quic-dev/qns)
  BUG/MEDIUM: quic: remove unsent data from qc_stream_desc buf

Before this patch, buffer removal was done only on ACK reception. ACK
handling is only done in order from the oldest one. A BUG_ON() statement
is present to ensure this assertion remains valid.

This is however not true anymore since the above patch. Indeed, after
unsent data removal, the current buffer may be empty if it did not
contain yet any sent data. In this case, it is not the oldest buffer,
thus the BUG_ON() statement will be triggered.

To fix this, simply remove this BUG_ON() statement. It should not have
any impact as it is safe to remove buffers in any order.

Note that several conditions must be met to trigger this BUG_ON crash :
* a QUIC MUX stream is destroyed before transmitting all of its data
* several buffers must have been previously allocated for this stream so
  it happens only for transfers bigger than bufsize
* latency should be high enough to delay ACK reception

This must be backported wherever the above patch is (currently targetted
to 2.6).

17 months agoBUG/MEDIUM: qpack: allow 6xx..9xx status codes
Amaury Denoyelle [Mon, 29 Jan 2024 12:45:48 +0000 (13:45 +0100)] 
BUG/MEDIUM: qpack: allow 6xx..9xx status codes

HTTP status codes outside of 100..599 are considered invalid in HTTP
RFC9110. However, it is explicitely stated that range 600..999 is often
used for internal communication so in practice haproxy must be lenient
with it.

Before this patch, QPACK encoder rejected these values. This resulted in
a connection error. Fix this by extending the range of allowed values
from 100 to 999.

This is linked to github issue #2422. Once again, thanks to @yokim-git
for his help here.

This must be backported up to 2.6.

17 months agoBUG/MEDIUM: h3: do not crash on invalid response status code
Amaury Denoyelle [Mon, 29 Jan 2024 12:47:44 +0000 (13:47 +0100)] 
BUG/MEDIUM: h3: do not crash on invalid response status code

A crash occurs in h3_resp_headers_send() if an invalid response code is
received from the backend side. Fix this by properly flagging the
connection on error. This will cause a CONNECTION_CLOSE.

This should fix github issue #2422.

Big thanks to ygkim (@yokim-git) for his help and reactivity. Initially,
GDB reported an invalid code source location due to heavy functions
inlining inside h3_snd_buf(). The issue was found after using -Og flag.

This must be backported up to 2.6.

17 months agoMINOR: h3: add traces for stream sending function
Amaury Denoyelle [Mon, 29 Jan 2024 14:15:27 +0000 (15:15 +0100)] 
MINOR: h3: add traces for stream sending function

Replace h3_debug_printf() by real trace for functions used by stream
layer snd_buf callback. A new event type H3_EV_STRM_SEND is created for
the occasion.

This should be backported up to 2.6 to help investigate H3 issues on
stable releases. Note that h3_nego_ff/h3_done_ff definition are not
available from 2.8.

17 months agoBUG/MAJOR: ssl_sock: Always clear retry flags in read/write functions
Olivier Houchard [Sat, 27 Jan 2024 21:58:29 +0000 (22:58 +0100)] 
BUG/MAJOR: ssl_sock: Always clear retry flags in read/write functions

It has been found that under some rare error circumstances,
SSL_do_handshake() could return with SSL_ERROR_WANT_READ without
even trying to call the read function, causing permanent wakeups
that prevent the process from sleeping.

It was established that this only happens if the retry flags are
not systematically cleared in both directions upon any I/O attempt,
but, given the lack of documentation on this topic, it is hard to
say if this rather strange behavior is expected or not, otherwise
why wouldn't the library always clear the flags by itself before
proceeding?

In addition, this only seems to affect OpenSSL 1.1.0 and above,
and does not affect wolfSSL nor aws-lc.

A bisection on haproxy showed that this issue was first triggered by
commit a8955d57ed ("MEDIUM: ssl: provide our own BIO."), which means
that OpenSSL's socket BIO does not have this problem. And this one
does always clear the flags before proceeding. So let's just proceed
the same way. It was verified that it properly fixes the problem,
does not affect other implementations, and doesn't cause any freeze
nor spurious wakeups either.

Many thanks to Valentín Gutiérrez for providing a network capture
showing the incident as well as a reproducer. This is GH issue #2403.

This patch needs to be backported to all versions that include the
commit above, i.e. as far as 2.0.

17 months agoDOC: configuration: clarify http-request wait-for-body
Thayne McCombs [Mon, 29 Jan 2024 05:07:32 +0000 (22:07 -0700)] 
DOC: configuration: clarify http-request wait-for-body

Make it more explicit what happens in the various scenarios that cause
HAProxy to stop waiting when "http-request wait-for-body" is used.

Also fix a couple of grammatical errors.

Fixes: #2410
Signed-Off-By: Thayne McCombs <astrothayne@gmail.com>
17 months ago[RELEASE] Released version 3.0-dev2 v3.0-dev2
Willy Tarreau [Fri, 26 Jan 2024 19:11:39 +0000 (20:11 +0100)] 
[RELEASE] Released version 3.0-dev2

Released version 3.0-dev2 with the following main changes :
    - MINOR: ot: logsrv struct becomes logger
    - MINOR: ssl: Update ssl_fc_curve/ssl_bc_curve to use SSL_get0_group_name
    - CLEANUP: ssl: fix indentation in smp_fetch_ssl_fc_ec()
    - DEV: patchbot: produce a verdict for too long commit messages
    - CLEANUP: ssl: fix indentation in smp_fetch_ssl_fc_ec() (part 2)
    - CLEANUP: quic: Double quic_dgram_parse() prototype declaration.
    - BUG/MINOR: map: list-based matching potential ordering regression
    - REGTESTS: add a test to ensure map-ordering is preserved
    - DOC: config: fix typo about map_*_key converters
    - DOC: configuration: corrected description of keyword tune.ssl.ocsp-update.mindelay
    - MINOR: map: mapfile ordering also matters for tree-based match types
    - DEV: phash: add a trivial perfect hash generator for integers
    - OPTIM: http: simplify http_get_status_idx() using a hash
    - CLEANUP: http: avoid duplicating literals in find_http_meth()
    - MINOR: http: add infrastructure to choose status codes for err / fail
    - MEDIUM: http_act: check status codes against the bit fields for err/fail
    - MEDIUM: http: add the ability to redefine http-err-codes and http-fail-codes
    - CI: codespell: ignore some words in URLs
    - CI: codespell: add more words to whitelist
    - CLEANUP: fix spelling of "occured" in src/h3.c
    - BUILD: quic: missing include for quic_tp
    - BUG/MINOR: mux-quic: do not prevent non-STREAM sending on flow control
    - MEDIUM: ssl: allow multiple fallback certificate to allow ECDSA/RSA selection
    - MEDIUM: ssl: generate '*' SNI filters for default certificates
    - MEDIUM: ssl: does not use default_ctx for 'generate-certificate' option
    - REORG: ssl: move 'generate-certificates' code to ssl_gencert.c
    - DOC: configuration: update configuration on how to have multiple default certs
    - MEDIUM: ssl: implements 'default-crt' keyword for bind Lines
    - CI: github: update wolfSSL to 5.6.6
    - DOC: INSTALL: require at least WolfSSL 5.6.6
    - DEV: h2: add support for multiple flags in mkhdr
    - DEV: h2: support hex-encoded data sequences in mkhdr
    - BUG/MINOR: mux-h2: also count streams for refused ones
    - BUG/MEDIUM: quic: keylog callback not called (USE_OPENSSL_COMPAT)
    - MINOR: vars: fix indentation in var_clear_buffer()
    - DOC: configuration: fix set-dst in actions keywords matrix
    - BUG/MEDIUM: mux-h2: refine connection vs stream error on headers
    - MINOR: mux-h2/traces: add a missing trace on connection WU with negative inc
    - MINOR: mux-h2: add a counter of "glitches" on a connection
    - MINOR: connection: add a new mux_ctl to report number of connection glitches
    - MINOR: mux-h2: implement MUX_CTL_GET_GLITCHES
    - MINOR: connection: add sample fetches to report per-connection glitches
    - BUILD: stick-table: fix build error on 32-bit platforms
    - MINOR: quic: Transport parameters encoding without version_information
    - MINOR: quic: Enable early data at SSL session level (aws-lc)
    - MINOR: ssl_sock: Early data disabled during SSL_CTX switching (aws-lc)
    - MINOR: quic: Correctly wait for the completion of handshakes with early data (aws-lc)
    - BUG/MEDIUM: cli: some err/warn msg dumps add LR into CSV output on stat's CLI
    - BUG/MINOR: jwt: fix jwt_verify crash on 32-bit archs
    - BUILD: quic: fix build error when using the compatibility layer
    - BUILD: quic: Fix build error when building QUIC against wolfssl.
    - BUILD: quic: Fix build error when building QUIC against libressl.
    - BUG/MINOR: hlua: fix uninitialized var in hlua_core_get_var()
    - CLEANUP: hlua: fix indent, remove extra return in hlua_core_get_var()
    - BUG/MEDIUM: cache: Fix crash when deleting secondary entry
    - BUG/MINOR: quic: newreno QUIC congestion control algorithm no more available
    - CLEANUP: quic: Remove unused CUBIC_BETA_SCALE_FACTOR_SHIFT macro.
    - MINOR: quic: Stop hardcoding a scale shifting value (CUBIC_BETA_SCALE_FACTOR_SHIFT)
    - MINOR: quic: extract qc_stream_buf free in a dedicated function
    - BUG/MEDIUM: quic: remove unsent data from qc_stream_desc buf
    - CLEANUP: fix spelling of "elemt"
    - CI: extend spell check white list
    - CI: enable spell check on git push
    - BUILD: makefile: also define cmd_CXX to pretty-print C++ build commands
    - BUILD/MEDIUM: deviceatlas: addon build rework.
    - DOC: deviceatlas: update to be in line with the v3 api.
    - BUILD/MEDIUM: deviceatlas: updating the addon part.
    - BUILD: deviceatlas: remove unneeded depenency on libcurl / libzip
    - BUILD: deviceatlas: fix empty "-I" left on CFLAGS
    - Revert "CI: enable spell check on git push"

17 months agoRevert "CI: enable spell check on git push"
Willy Tarreau [Fri, 26 Jan 2024 18:58:14 +0000 (19:58 +0100)] 
Revert "CI: enable spell check on git push"

This reverts commit 413aa6e2e94a591d444ef9bd174a99b64eea8436.

It reports failures that neither the patch's author nor the committer
are able to check for before pushing, causing an excess of failure
reports that can hardly be acted upon. We need to find a better
solution, let's revert it for now.

17 months agoBUILD: deviceatlas: fix empty "-I" left on CFLAGS
Willy Tarreau [Fri, 26 Jan 2024 18:46:59 +0000 (19:46 +0100)] 
BUILD: deviceatlas: fix empty "-I" left on CFLAGS

The previous fix was incomplete, there was a leftover CURL_INC on the
CFLAGS which breaks Lua.

17 months agoBUILD: deviceatlas: remove unneeded depenency on libcurl / libzip
Willy Tarreau [Fri, 26 Jan 2024 18:36:11 +0000 (19:36 +0100)] 
BUILD: deviceatlas: remove unneeded depenency on libcurl / libzip

These were previously used for the "dadwsch" utility that's no longer
part of the addon, so we should not move the CFLAGS/LDFLAGS to the
global ones as this adds an undesired dependency on the libcurl and
libzip libs.

No backport is needed.

17 months agoBUILD/MEDIUM: deviceatlas: updating the addon part.
David Carlier [Thu, 25 Jan 2024 09:11:18 +0000 (09:11 +0000)] 
BUILD/MEDIUM: deviceatlas: updating the addon part.

- Reflecing the changes done in addons/deviceatlas/Makefile.inc.
 Enabling the cache feature and its disabling option as well.
- Now the `dadwsch` application is part of the API's package for more
general purposes, we remove it.
- Minor and transparent to user changes into da.c's workflow, also
making more noticeable some notices with appropriate logging levels.
- Adding support for the new `deviceatlas-cache-size` config keyword,
 a no-op when the cache support is disabled.
- Adding missing compilation units and relevant api updates to
the dummy library version.