]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
7 months agoMINOR: startup: set HAPROXY_LOCALPEER only once
Valentine Krasnobaeva [Tue, 19 Nov 2024 13:22:08 +0000 (14:22 +0100)] 
MINOR: startup: set HAPROXY_LOCALPEER only once

Before this patch HAPROXY_LOCALPEER variable could be set in init_early(),
in init_args() and in cfg_parse_global(). In master-worker mode, if localpeer
keyword set in the global section, HAPROXY_LOCALPEER in the worker
environment is set to this keyword's value, but in the master environment it
still keeps the default, a localhost name. This is confusing.

To fix it, let's set HAPROXY_LOCALPEER only once, when a worker or process in a
standalone mode has finished to parse its configuration. And let's set this
variable only for the worker process or for the process in a standalone mode,
because the master doesn't need it.

HAPROXY_LOCALPEER takes the value saved in localpeer global variable, which is
always set by default in init_early() to the local hostname. Then, localpeer
could be reset in init_args (-L option) and in cfg_parse_global() (while
parsing "localpeer" keyword).

7 months agoBUILD: makefile: make ERR apply to build options as well
Willy Tarreau [Wed, 20 Nov 2024 13:44:28 +0000 (14:44 +0100)] 
BUILD: makefile: make ERR apply to build options as well

Once in a while we find some makefiles ignoring some outdated arguments
and just emit a warning. What's annoying is that if users (say, distro
packagers), have purposely added ERR=1 to their build scripts to make
sure to fail on any warning, these ones will be ignored and the build
can continue with invalid or missing options.

William rightfully suggested that ERR=1 should also catch make's warnings
so this patch implements this, by creating a new "complain" variable that
points either to "error" or "warning" depending on $(ERR), and that is
used to send the messages using $(call $(complain),...). This does the
job right at little effort (tested from GNU make 3.82 to 4.3).

Note that for this purpose the ERR declaration was upped in the makefile
so that it appears before the new errors.mk file is included.

7 months agoMINOR: systemd: replace SOCK_CLOEXEC by fcntl call to FD_CLOEXEC
William Lallemand [Wed, 20 Nov 2024 12:50:58 +0000 (13:50 +0100)] 
MINOR: systemd: replace SOCK_CLOEXEC by fcntl call to FD_CLOEXEC

Since we build systemd.o for every target, we need it to be more
portable.

The SOCK_CLOEXEC argument from socket() is not portable and won't build
on some OS like macOS X.

This patch fixes the issue by replace SOCK_CLOEXEC by a fnctl set to
FD_CLOEXEC.

7 months agoCI: vtest: temporarily build from the sd-notify PR
William Lallemand [Wed, 20 Nov 2024 09:48:54 +0000 (10:48 +0100)] 
CI: vtest: temporarily build from the sd-notify PR

Build VTest temporarily from the sd-notify PR until the
https://github.com/vtest/VTest/pull/41 is merged.

This PR allows starting with -Ws in order to have more reliables tests
in master-worker mode.

7 months agoMEDIUM: mworker: remove USE_SYSTEMD requirement for -Ws
William Lallemand [Wed, 20 Nov 2024 11:02:39 +0000 (12:02 +0100)] 
MEDIUM: mworker: remove USE_SYSTEMD requirement for -Ws

Since sd_notify() is now implemented in src/systemd.c, there is no need
anymore to build its support conditionnally with USE_SYSTEMD.

This patch add supports for -Ws for every build and removes the
USE_SYSTEMD build option. It also remove every reference to USE_SYSTEMD
in the documentation and the CI.

This also allows to run the reg-tests in -Ws with the new VTest support.

7 months agoBUG/MINOR: cfgparse-quic: fix renaming of max-window-size
Amaury Denoyelle [Wed, 20 Nov 2024 10:09:35 +0000 (11:09 +0100)] 
BUG/MINOR: cfgparse-quic: fix renaming of max-window-size

A patch has recently tried to rename QUIC max-window-size global
parameter to default-max-window-size to better reflect its usage.
However, only the documentation was edited but not cfgparse-quic.c.

Fix this by updating cfgparse-quic.c with the new default- naming.

No need to backport.

7 months agoMINOR: http-fetch: Add an option to 'query" to get the QS with the '?'
Christopher Faulet [Fri, 15 Nov 2024 16:25:47 +0000 (17:25 +0100)] 
MINOR: http-fetch: Add an option to 'query" to get the QS with the '?'

As mentionned by Thayne McCombs in #2728, it could be handy to have a sample
fetch function to retrieve the query string with the question mark
character.

Indeed, for now, "query" sample fetch function already extract the query
string from the path, but the question mark character is not
included. Instead of adding a new sample fetch function with a too similar
name, an optional argument is added to "query". If "with_qm" is passed as
argument, the question mark will be included in the query string, but only
if it is not empty.

Thanks to this patch, the following rule:

  http-request redirect location /destination?%[query] if { -m found query }  some_condition
  http-request redirect location /destination if some_condition

can now be expressed this way:

  http-request redirect location /destination%[query(with_qm)] if some_condition

7 months agoBUG/MINOR: http-ana: Adjust the server status before the L7 retries
Christopher Faulet [Tue, 19 Nov 2024 15:33:55 +0000 (16:33 +0100)] 
BUG/MINOR: http-ana: Adjust the server status before the L7 retries

The server status must be adjusted, if necessary, at each retry. It is
properly performed when "obersve layer4" directive is set. But for the layer
7, only the last attempt was considered.

When the L7 retries were implemented, all retries were added before the
server status adjutement. So only the last attempt was considered. To fix
the issue, we must adjut the server status first, and then try to perform a
L7 retry.

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

7 months agoDOC: configuration: wrap long line for "strstr()" conditional expression
Willy Tarreau [Wed, 20 Nov 2024 07:47:38 +0000 (08:47 +0100)] 
DOC: configuration: wrap long line for "strstr()" conditional expression

This keyword had too long a description line, let's split it. This can be
backported to 2.8.

7 months agoDOC: configuration: explain quotes and spaces in conditional blocks
Willy Tarreau [Wed, 20 Nov 2024 07:44:39 +0000 (08:44 +0100)] 
DOC: configuration: explain quotes and spaces in conditional blocks

Conditional blocks inherit the same tokenizer and argument parser as
the rest of the configuration, but are also silently concatenated
around groups of spaces and tabs. This can lead to subtle failures
for configs containing spaces around commas and parenthesis, where
a string comparison might silently fail for example. Let's better
document this particular case.

Thanks to Valentine for analysing and reporting the problem.

This can be backported to 2.4.

7 months agoDOC: configuration: explain the rules regarding spaces in arguments
Willy Tarreau [Wed, 20 Nov 2024 07:42:02 +0000 (08:42 +0100)] 
DOC: configuration: explain the rules regarding spaces in arguments

Spaces around commas or parenthesis in expressions are generally part
of the value due to the long history of supporting unquoted arguments.
But this tends to come as a surprise to new users and sometimes creates
subtly invalid configurations. Let's add some text covering this.

This can be backported to 2.4.

7 months agoMINOR: tasklet: support an optional set of wakeup flags to tasklet_wakeup_on()
Willy Tarreau [Tue, 19 Nov 2024 14:56:59 +0000 (15:56 +0100)] 
MINOR: tasklet: support an optional set of wakeup flags to tasklet_wakeup_on()

tasklet_wakeup_on() and its derivates (tasklet_wakeup_after() and
tasklet_wakeup()) do not support passing a wakeup cause like
task_wakeup(). This is essentially due to an API limitation cause by
the fact that for a very long time the only reason for waking up was
to process pending I/O. But with the growing complexity of mux tasks,
it is becoming important to be able to skip certain heavy processing
when not strictly needed.

One possibility is to permit the caller of tasklet_wakeup() to pass
flags like task_wakeup(). Instead of going with a complex naming scheme,
let's simply make the flags optional and be zero when not specified. This
means that tasklet_wakeup_on() now takes either 2 or 3 args, and that the
third one is the optional flags to be passed to the callee. Eligible flags
are essentially the non-persistent ones (TASK_F_UEVT* and TASK_WOKEN_*)
which are cleared when the tasklet is executed. This way the handler
will find them in its <state> argument and will be able to distinguish
various causes for the call.

7 months agoMINOR: tasklet: make the low-level tasklet API take a flag
Willy Tarreau [Tue, 19 Nov 2024 14:33:39 +0000 (15:33 +0100)] 
MINOR: tasklet: make the low-level tasklet API take a flag

Everything in the tasklet layer supports flags, except that they are
just not implemented in the wakeup functions, while they are in the
task_wakeup functions. Initially it was not considered useful to pass
wakeup causes because these were essentially I/O, but with the growing
number of I/O handlers having to deal with various types of operations
(typically cheap I/O notifications on subscribe vs heavy parsing on
application-level wakeups), it would be nice to start to make this
distinction possible.

This commit extends _tasklet_wakeup_on() and _tasklet_wakeup_after()
to pass a set of flags that continues to be set as zero. For now this
changes nothing, but new functions will come.

7 months agoMINOR: tools: add new macro DEFZERO to provide a default zero argument
Willy Tarreau [Tue, 19 Nov 2024 14:44:32 +0000 (15:44 +0100)] 
MINOR: tools: add new macro DEFZERO to provide a default zero argument

This is the equivalent of DEFNULL except that it sets a zero value instead
of a NULL for a missing argument.

7 months agoMINOR: sched: add TASK_F_WANTS_TIME to make the scheduler update the call date
Willy Tarreau [Tue, 19 Nov 2024 15:27:46 +0000 (16:27 +0100)] 
MINOR: sched: add TASK_F_WANTS_TIME to make the scheduler update the call date

Currently tasks being profiled have th_ctx->sched_call_date set to the
current nanosecond in monotonic time. But there's no other way to have
this, despite the scheduler being capable of it. Let's just declare a
new task flag, TASK_F_WANTS_TIME, that makes the scheduler take the time
just before calling the handler. This way, a task that needs nanosecond
resolution on the call date will be able to be called with an up-to-date
date without having to abuse now_mono_time() if not needed. In addition,
if CLOCK_MONOTONIC is not supported (now_mono_time() always returns 0),
the date is set to the most recently known now_ns, which is guaranteed
to be atomic and is only updated once per poll loop.

This date can be more conveniently retrieved using task_mono_time().

This can be useful, e.g. for pacing. The code was slightly adjusted so
as to merge the common parts between the profiling case and this one.

7 months agoMINOR: tinfo/clock: turn sched_call_date to 64-bits
Willy Tarreau [Tue, 19 Nov 2024 17:14:05 +0000 (18:14 +0100)] 
MINOR: tinfo/clock: turn sched_call_date to 64-bits

We used to store it in 32-bits since we'd only use it for latency and CPU
usage calculation but usages will evolve so let's not truncate the value
anymore. Now we store the full 64 bits. Note that this doesn't even
increase the storage size due to alignment. The 3 usage places were
verified to still be valid (most were already cast to 32 bits anyway).

7 months agoMINOR: stream: don't update s->lat_time when the wakeup date is not set
Willy Tarreau [Tue, 19 Nov 2024 15:42:40 +0000 (16:42 +0100)] 
MINOR: stream: don't update s->lat_time when the wakeup date is not set

In 2.7 was added a stream wakeup latency calculation with commit
6a28a30efa ("MINOR: tasks: do not keep cpu and latency times in struct
task"). However, due to the transformation of the previous code, it
kept unconditionally updating s->lat_time even of the sched_wake_date
was zero. In other words, s->lat_time is constantly updated for the
huge majority of calls that are made without profiling. Let's just
check the sched_wake_date status before doing so.

7 months agoCLEANUP: tinfo: move sched_*_date/*_mono_time to the thread-local area
Willy Tarreau [Tue, 19 Nov 2024 17:00:47 +0000 (18:00 +0100)] 
CLEANUP: tinfo: move sched_*_date/*_mono_time to the thread-local area

These ones are never atomically accessed, they have nothing to do in
the atomic ops cache line, let's move them to the thread-local area.

7 months agoDOC: sched: document the missing TASK_F_UEVT* flags
Willy Tarreau [Tue, 19 Nov 2024 15:26:04 +0000 (16:26 +0100)] 
DOC: sched: document the missing TASK_F_UEVT* flags

These are user-defined one-shot events that are application-specific
and reset upon wakeup and were not documented. No backport is needed
since these were added to 3.1.

7 months agoDOC: sched: add missing scheduler API documentation for tasklet_wakeup_after()
Willy Tarreau [Tue, 19 Nov 2024 15:04:09 +0000 (16:04 +0100)] 
DOC: sched: add missing scheduler API documentation for tasklet_wakeup_after()

This was added to 2.6 but the doc was forgotten. Let's add it. It's not
needed to backport this since it's only used for new developments.

7 months agoDOC: lua: fix yield-dependent methods expected contexts
Aurelien DARRAGON [Tue, 19 Nov 2024 18:28:16 +0000 (19:28 +0100)] 
DOC: lua: fix yield-dependent methods expected contexts

Contrary to what the doc states, it is not expected (nor relevant) to
use yield-dependent methods such as core.yield() or core.(m)sleep() from
contexts that don't support yielding. Such contexts include body, init,
fetches and converters.

Thus the doc got it wrong since the beginning, because such methods were
never supported from the above contexts, yet it was listed in the list
of compatible contexts (probably the result of a copy-paste), which is
error-prone because it could either cause a Lua runtime error to be
thrown, or be ignored in some other cases.

It should be backported to all stable versions.

7 months agoREGTESTS: use -dW by default on every reg-tests
William Lallemand [Tue, 19 Nov 2024 15:51:30 +0000 (16:51 +0100)] 
REGTESTS: use -dW by default on every reg-tests

Every reg-test now runs without any warning, so let's acivate -dW by
default so the new ones will inheritate the option.

This patch reverts 9d511b3c ("REGTESTS: enable -dW on almost all tests
to fail on warnings") and adds -dW in the default HAPROXY_ARGS of
scripts/run-regtests.sh instead.

7 months agoMEDIUM: stats-file: silently ignore be/fe mistmatch
William Lallemand [Tue, 19 Nov 2024 15:39:55 +0000 (16:39 +0100)] 
MEDIUM: stats-file: silently ignore be/fe mistmatch

Most of the invalid or unknow field in the stats-file parser are ignored
silently, which is not the case of the frontend/backend mismatch on a
guid, which is kind of strange.

Since this is ""documented"" to be ignored in the
reg-tests/stats/sample-stats-file file, let's also ignore this kind of
line. This will allow to run the associated reg-test with -dW.

7 months agoMINOR: mux_quic/pacing: display pacing info on show quic
Amaury Denoyelle [Tue, 19 Nov 2024 10:27:00 +0000 (11:27 +0100)] 
MINOR: mux_quic/pacing: display pacing info on show quic

To improve debugging, extend "show quic" output to report if pacing is
activated on a connection. Two values will be displayed for pacing :

* a new counter paced_sent_ctr is defined in QCC structure. It will be
  incremented each time an emission is interrupted due to pacing.

* pacing engine now saves the number of datagrams sent in the last paced
  emission. This will be helpful to ensure burst parameter is valid.

7 months agoMEDIUM: quic: define cubic-pacing congestion algorithm
Amaury Denoyelle [Mon, 18 Nov 2024 10:05:28 +0000 (11:05 +0100)] 
MEDIUM: quic: define cubic-pacing congestion algorithm

Define a new QUIC congestion algorithm token 'cubic-pacing' for
quic-cc-algo bind keyword. This is identical to default cubic
implementation, except that pacing is used for STREAM frames emission.

This algorithm supports an extra argument to specify a burst size. This
is stored into a new bind_conf member named quic_pacing_burst which can
be reuse to initialize quic path.

Pacing support is still considered experimental. As such, 'cubic-pacing'
can only be used with expose-experimental-directives set.

7 months agoMINOR: quic: extend quic-cc-algo optional parameters
Amaury Denoyelle [Tue, 19 Nov 2024 14:38:53 +0000 (15:38 +0100)] 
MINOR: quic: extend quic-cc-algo optional parameters

Modify quic-cc-algo for better extensability of optional parameters
parsing. This will be useful to support a new parameter for maximum
allowed pacing burst size.

Take this opportunity to refine quic-cc-algo documentation. Optional
parameters are now presented as a list which would be soon extended.

7 months agoMINOR: quic: use dynamic cc_algo on bind_conf
Amaury Denoyelle [Tue, 19 Nov 2024 09:12:27 +0000 (10:12 +0100)] 
MINOR: quic: use dynamic cc_algo on bind_conf

A QUIC congestion algorithm can be specified on the bind line via
keyword quic-cc-algo. As such, bind_conf structure has a member
quic_cc_algo.

Previously, if quic-cc-algo was set, bind_conf member was initialized to
one of the globally defined CC algo structure. This patch changes
bind_conf quic_cc_algo initialization to point to a dynamically
allocated copy of CC algo structure.

With this change, it will be possible to tweak individually each CC algo
of a bind line. This will be used to activate pacing on top of the
congestion algorithm.

As bind_conf member is dynamically allocated now, its member is now
freed via free_proxy() to prevent any leak.

7 months agoMAJOR: mux-quic: support pacing emission
Amaury Denoyelle [Mon, 18 Nov 2024 13:55:41 +0000 (14:55 +0100)] 
MAJOR: mux-quic: support pacing emission

Support pacing emission for STREAM frames at the QUIC MUX layer. This is
implemented by adding a quic_pacer engine into QCC structure.

The main changes have been written into qcc_io_send(). It now
differentiates cases when some frames have been rejected by transport
layer. This can occur as previously due to congestion or FD buffer full,
which requires subscribing on transport layer. The new case is when
emission has been interrupted due to pacing timing. In this case, QUIC
MUX I/O tasklet is rescheduled to run with the flag TASK_F_USR1.

On tasklet execution, if TASK_F_USR1 is set, all standard processing for
emission and reception is skipped. Instead, a new function
qcc_purge_sending() is called. Its purpose is to retry emission with the
saved STREAM frames list. Either all remaining frames can now be send,
subscribe is done on transport error or tasklet must be rescheduled for
pacing purging.

In the meantime, if tasklet is rescheduled due to other conditions,
TASK_F_USR1 is reset. This will trigger a full regeneration of STREAM
frames. In this case, pacing expiration must be check before calling
qcc_send_frames() to ensure emission is now allowed.

7 months agoMINOR: mux-quic: encapsulate QCC tasklet wakeup
Amaury Denoyelle [Wed, 16 Oct 2024 15:56:15 +0000 (17:56 +0200)] 
MINOR: mux-quic: encapsulate QCC tasklet wakeup

QUIC MUX will be responsible to drive emission with pacing. This will be
implemented via setting TASK_F_USR1 before I/O tasklet wakeup. To
prepare this, encapsulate each I/O tasklet wakeup into a new function
qcc_wakeup().

This commit is purely refactoring prior to pacing implementation into
QUIC MUX.

7 months agoMINOR: mux-quic: define a tx STREAM frame list member
Amaury Denoyelle [Mon, 18 Nov 2024 08:53:39 +0000 (09:53 +0100)] 
MINOR: mux-quic: define a tx STREAM frame list member

For STREAM emission, MUX QUIC previously used a local list defined under
qcc_io_send(). This was suitable as either all frames were sent, or
emission must be interrupted due to transport congestion or fatal error.
In the latter case, the list was emptied anyway and a new frame list was
built on future qcc_io_send() invokation.

For pacing, MUX QUIC may have to save the frame list if pacing should be
applied across emission. This is necessary to avoid to unnecessarily
rebuilt stream frame list between each paced emission. To support this,
STREAM list is now stored as a member of QCC structure.

Ensure frame list is always deleted, even on QCC release, using newly
defined utility function qcc_tx_frms_free().

7 months agoMINOR: quic/pacing: add burst support
Amaury Denoyelle [Mon, 18 Nov 2024 14:31:12 +0000 (15:31 +0100)] 
MINOR: quic/pacing: add burst support

qc_send_mux() has been extended previously to support pacing emission.
This will ensure that no more than one datagram will be emitted during
each invokation. However, to achieve better performance, it may be
necessary to emit a batch of several datagrams one one turn.

A so-called burst value can be specified by the user in the
configuration. However, some congestion control algos may defined their
owned dynamic value. As such, a new CC callback pacing_burst is defined.

quic_cc_default_pacing_burst() can be used for algo without pacing
interaction, such as cubic. It will returns a static value based on user
selected configuration.

7 months agoMINOR: quic/pacing: support pacing emission on quic_conn layer
Amaury Denoyelle [Thu, 24 Oct 2024 14:06:48 +0000 (16:06 +0200)] 
MINOR: quic/pacing: support pacing emission on quic_conn layer

Pacing will be implemented for STREAM frames emission. As such,
qc_send_mux() API has been extended to add an argument to a quic_pacer
engine.

If non NULL, engine will be used to pace emission. In short, no more
than one datagram will be emitted for each qc_send_mux() invokation.
Pacer is then notified about the emission and a timer for a future
emission is calculated. qc_send_mux() will return PACING error value, to
inform QUIC MUX layer that it will be responsible to retry emission
after some delay.

7 months agoMINOR: quic/pacing: implement quic_pacer engine
Amaury Denoyelle [Mon, 18 Nov 2024 13:57:39 +0000 (14:57 +0100)] 
MINOR: quic/pacing: implement quic_pacer engine

Extend quic_pacer engine to support pacing emission. Several functions
are defined.
* quic_pacing_sent_done() to notify engine about an emission of one or
  several datagrams
* quic_pacing_expired() to check if emission should be delayed or can be
  conducted immediately

7 months agoMINOR: quic: define quic_pacing module
Amaury Denoyelle [Thu, 24 Oct 2024 13:53:17 +0000 (15:53 +0200)] 
MINOR: quic: define quic_pacing module

Add a new module quic_pacing. A new structure quic_pacer is defined.
This will be used as a pacing engine to implement smooth emission of
QUIC data.

7 months agoMINOR: quic: extend qc_send_mux() return type with a dedicated enum
Amaury Denoyelle [Fri, 25 Oct 2024 14:31:26 +0000 (16:31 +0200)] 
MINOR: quic: extend qc_send_mux() return type with a dedicated enum

This commit is part of a adjustment on QUIC transport send API to
support pacing. Here, qc_send_mux() return type has been changed to use
a new enum quic_tx_err.

This is useful to explain different failure causes of emission. For now,
only two values have been defined : NONE and FATAL. When pacing will be
implemented, a new value would be added to specify that emission was
interrupted on pacing. This won't be a fatal error as this allows to
retry emission but not immediately.

7 months agoMINOR: quic: support a max number of built packet per send iteration
Amaury Denoyelle [Fri, 11 Oct 2024 15:57:57 +0000 (17:57 +0200)] 
MINOR: quic: support a max number of built packet per send iteration

Extend QUIC transport emission function to support a maximum datagram
argument. The purpose is to ensure that qc_send() won't emit more than
the specified value, unless it is 0 which is considered as unlimited.

In qc_prep_pkts(), a counter of built datagram has been added to support
this. The packet building loop is interrupted if it reaches a specified
maximum value. Also, its return value has been changed to the number of
prepared datagrams. This is reused by qc_send() to interrupt its work if
a specified max datagram argument value is reached over one or several
iteration of prepared/sent datagrams.

This change is necessary to support pacing emission. Note that ideally,
the total length in bytes of emitted datagrams should be taken into
account instead of the raw number of datagrams. However, for a first
implementation, it was deemed easier to implement it with the latter.

7 months agoMINOR: quic: simplify qc_prep_pkts() exit path
Amaury Denoyelle [Wed, 16 Oct 2024 15:50:30 +0000 (17:50 +0200)] 
MINOR: quic: simplify qc_prep_pkts() exit path

To prepare pacing support, qc_prep_pkts() exit path have been rewritten
to be easily modified. This is purely refactoring which should not have
any functional change :
* a dedicated error path has been added
* ensure qc_txb_store() is always called to finalize datagram on normal
  exit path if first_pkt is not NULL. Needed to support breaking from
  packet building loop in a easier way.

7 months agoMINOR: mux-quic: add missing values for show flags
Amaury Denoyelle [Tue, 19 Nov 2024 10:01:57 +0000 (11:01 +0100)] 
MINOR: mux-quic: add missing values for show flags

Add QCC QC_CF_WAIT_FOR_HS and QCS QC_SF_TXBUB_OOB flags to their
respective show_flags to be able to decipher them via dev flags utility.

These values have been added in the current dev version, thus no need to
backport this patch.

7 months agoDOC: quic: rename max-window-size as with default prefix
Amaury Denoyelle [Tue, 19 Nov 2024 14:11:20 +0000 (15:11 +0100)] 
DOC: quic: rename max-window-size as with default prefix

Rename 'tune.quic.frontend.max-window-size' with the prefix 'default-'.
This highlights the fact that it is not a hard limit, as it can be
overriden if specifying an optional window size via quic-cc-algo on a
bind line.

No need to backport as this keyword was added on the current dev
version.

7 months agoMEDIUM: stats-file: explicitely ignore comments starting by //
William Lallemand [Tue, 19 Nov 2024 14:43:35 +0000 (15:43 +0100)] 
MEDIUM: stats-file: explicitely ignore comments starting by //

Explicitely ignore comments starting by // so they don't emit a warning.

7 months agoMINOR: stats-file: add the filename in the warning
William Lallemand [Tue, 19 Nov 2024 14:42:05 +0000 (15:42 +0100)] 
MINOR: stats-file: add the filename in the warning

Add the name of the stats-file in the warning so it's clear that the
warning was provoked by the stats-file and not the config file.

7 months agoDOC: config: Move fs.* and bs.* in section about L5 samples
Christopher Faulet [Tue, 19 Nov 2024 07:49:05 +0000 (08:49 +0100)] 
DOC: config: Move fs.* and bs.* in section about L5 samples

These sample fetch functions were added in the wrong section. Move them in
the section about sample fetch functions at L5 layer.

7 months agoDOC: config: Move wait_end in section about internal samples
Christopher Faulet [Tue, 19 Nov 2024 07:45:29 +0000 (08:45 +0100)] 
DOC: config: Move wait_end in section about internal samples

wait_end is an internal sample fetch functions and not a L6 one. So move it
in the corresponding section.

7 months agoDOC: config: Slightly improve the %Tr documentation
Christopher Faulet [Mon, 18 Nov 2024 21:48:23 +0000 (22:48 +0100)] 
DOC: config: Slightly improve the %Tr documentation

Specify -1 can also be reported for %Tr delay when the response is invalid.

7 months agoBUG/MINOR: http_ana: Report -1 for %Tr for invalid response only
Christopher Faulet [Mon, 18 Nov 2024 21:37:52 +0000 (22:37 +0100)] 
BUG/MINOR: http_ana: Report -1 for %Tr for invalid response only

The server response time is erroneously reported as -1 when it is
intercepted by HAProxy.

As stated in the documentation, the server response time is reported as -1
when the last response header was never seen. It happens when a server
timeout is triggered before the server managed to process the request. It
also happens if the response is invalid. This may be reported by the mux
during the response parsing, but also by the HTTP analyzers. However, in
this last case, the response time must only be reported as -1 on 502.

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

7 months agoMINIR: mux-h1: Return 414 or 431 when appropriate
Christopher Faulet [Mon, 18 Nov 2024 21:19:00 +0000 (22:19 +0100)] 
MINIR: mux-h1: Return 414 or 431 when appropriate

When the request is too large to fit in a buffer a 414 or a 431 error
message is returned depending on the error state of the request parser. A
414 is returned if the URI is too long, otherwise a 431 is returned.

This patch should fix the issue #1309.

7 months agoDEV: phash: Update 414 and 431 status codes to phash
Christopher Faulet [Mon, 18 Nov 2024 21:12:28 +0000 (22:12 +0100)] 
DEV: phash: Update 414 and 431 status codes to phash

The phash tool was updated to reflect the previous change. 414 and 431 are
now part of the handled status codes.

7 months agoMINOR: http: Add support for HTTP 414/431 status codes
Christopher Faulet [Mon, 18 Nov 2024 21:06:17 +0000 (22:06 +0100)] 
MINOR: http: Add support for HTTP 414/431 status codes

414-Uri-Too-Long and 431-Request-Header-Fields-Too-Large are now part of
supported status codes that can be define as error files. The hash table
defined in http_get_status_idx() was updated accordingly.

7 months agoDOC: config: Fix a typo in "1.3.1. The Request line"
Christopher Faulet [Mon, 18 Nov 2024 17:11:04 +0000 (18:11 +0100)] 
DOC: config: Fix a typo in "1.3.1. The Request line"

At the beginning of the last paragraph of this section, HTTP/3 was used
instead of HTTP/2. It is not fixed.

7 months agoDOC: config: A a space before ':' for {bs,fs}.aborted and {bs,fs}.rst_code
Christopher Faulet [Mon, 18 Nov 2024 14:34:54 +0000 (15:34 +0100)] 
DOC: config: A a space before ':' for {bs,fs}.aborted and {bs,fs}.rst_code

A space was missing before the ':' for the sample fetch functions above. It
was an issue for the text to HTML conversion script. So, let's fix it.

7 months agoMINOR: stream: Add an option to "show sess" command to dump the captured URI
Christopher Faulet [Mon, 18 Nov 2024 14:17:13 +0000 (15:17 +0100)] 
MINOR: stream: Add an option to "show sess" command to dump the captured URI

"show sess" command now supports a list of options that can be set after all
other possible arguments (<id>, all...). For now, "show-uri" is the only
supported option. With this options, the captured URI, if non-null, is added
to the dump of a stream, complete or now. The URI may be anonymized if
necessary.

This patch should fix the issue #663.

7 months agoMINOR: agent-check: Be able to set absolute weight via an agent
Christopher Faulet [Mon, 18 Nov 2024 07:35:22 +0000 (08:35 +0100)] 
MINOR: agent-check: Be able to set absolute weight via an agent

Historically, an agent-check program is only able to set a proportial weight
to the initial server's weight. However, it could be handy to also set an
absolute value. It is the purpose of this patch.

Instead of changing the current way to set a server's weight, a new
agent-check command is introduced. The string "weight:", followed by an
positive interger or a positive interger percentage, can now be used. If the
value ends with the '%' sign, then the new weight will be proportional to
the initially weight of the server. Otherwise, the value is considered as an
absolute weight and must be between 0 and 256.

This patch should fix the issue #360.

7 months agoMINOR: http-ana: Add support for "set-cookie-fmt" option to redirect rules
Christopher Faulet [Mon, 18 Nov 2024 17:03:23 +0000 (18:03 +0100)] 
MINOR: http-ana: Add support for "set-cookie-fmt" option to redirect rules

It is now possible to use a log-format string to define the "Set-Cookie"
header value of a response generated by a redirect rule. There is no special
check on the result format and it is not possible during the configuration
parsing. It is proably not a big deal because already existing "set-cookie"
and "clear-cookie" options don't perform any check.

Here is an example:

  http-request redirect location https://someurl.com/ set-cookie haproxy="%[var(txn.var)]"

This patch should fix the issue #1784.

7 months agoMINOR: http-ana: Add option to keep query-string on a localtion-based redirect
Christopher Faulet [Fri, 15 Nov 2024 16:03:06 +0000 (17:03 +0100)] 
MINOR: http-ana: Add option to keep query-string on a localtion-based redirect

On prefix-based redirect, there is an option to drop the query-string of the
location. Here it is the opposite. an option is added to preserve the
query-string of the original URI for a localtion-based redirect.

By setting "keep-query" option, for a location-based redirect only, the
query-string of the original URI is appended to the location. If there is no
query-string, nothing is added (no empty '?'). If there is already a
non-empty query-string on the localtion, the original one is appended with
'&' separator.

This patch should fix issue #2728.

7 months agoMINOR: config: show HAPROXY_BRANCH in "show env" output
Valentine Krasnobaeva [Mon, 18 Nov 2024 16:54:25 +0000 (17:54 +0100)] 
MINOR: config: show HAPROXY_BRANCH in "show env" output

Before this patch HAPROXY_BRANCH was unset just after configuration parsing.
Let's keep it, as it could be used in conditional blocks and some
configuration directives and it's handy to check its runtime value via "show
env".

In master-worker mode, this variable is set to the same value for both
processes.

7 months agoMINOR: cli: make "show env" accessible via master CLI without enabling debug
Valentine Krasnobaeva [Mon, 18 Nov 2024 09:46:33 +0000 (10:46 +0100)] 
MINOR: cli: make "show env" accessible via master CLI without enabling debug

Before this patch, we have need to put the master CLI in debug mode to be able
to issue 'show env' command for the master process. Output of this command is
handy even for the master process context, as it allows to control its
environment variables, which could be used/modified in the 'global' section.

So, let's provide in 'show env' command structure the level ACCESS_MASTER.
This allows to see and to access this command in master CLI without putting it
in debug mode.

7 months agoBUG/MINOR: mworker-prog: don't warn about deprecated section with expose-deprecated...
Valentine Krasnobaeva [Tue, 19 Nov 2024 09:32:28 +0000 (10:32 +0100)] 
BUG/MINOR: mworker-prog: don't warn about deprecated section with expose-deprecated-directives

As master parses now expose-deprecated-directives option, let's emit warning
about deprecated 'progam' section only in case, if this option wasn't set in
the 'global' section. This allows to people, who don't prefer to remove the
'program' section immediately to continue to start the process in zero-warning
mode.

Adjust the warning message accordingly and mcli_start_progs.vtc test. As
expose-deprecated-directives option is a 'global' section keyword, this section
must always precede any 'program' section, if users still continue to keep
'program' section.

This doesn't need to be backported, as related to the latest changes in
the master-worker architecture.

7 months agoMINOR: cfgparse-global: parse options to allow non std keywords in discovery mode
Valentine Krasnobaeva [Tue, 19 Nov 2024 09:47:38 +0000 (10:47 +0100)] 
MINOR: cfgparse-global: parse options to allow non std keywords in discovery mode

'Program' section is considered as deprecated now, see the commit 581c8a27d98c
("MEDIUM: mworker: depreciate the 'program' section"). So, the 'program'
section parser emits a warning every time since this commit, if its section is
presented. This makes impossible to launch the process in zero-warning mode.

After master-worker refactoring only the master process parses the 'program'
section. So, at first, in order to be able to start in zero-warning mode, we
need to parse in master process option, which allows deprecated keywords. Thus,
let's set in this commit KWF_DISCOVERY flag to
cfg_parse_global_non_std_directives parser, which parses
'expose-deprecated-directives' and 'expose-deprecated-directives' options.

7 months agoMINOR: ring: support unit suffixes in the size
Willy Tarreau [Tue, 19 Nov 2024 09:56:45 +0000 (10:56 +0100)] 
MINOR: ring: support unit suffixes in the size

The ring size used to take only numbers and silently ignore letters (due
to atol()), resulting it tiny buffers when trying to collect traces and
using e.g. "size 10g". Let's make use of parse_size_err() to properly
parse units.

7 months agoMINOR: tools: make parse_size_err() support 32/64 bits
Willy Tarreau [Tue, 19 Nov 2024 08:15:19 +0000 (09:15 +0100)] 
MINOR: tools: make parse_size_err() support 32/64 bits

parse_size_err() currently is a function working only on an uint. It's
not convenient for certain elements such as rings on large machines.

This commit addresses this by having one function for uints and one
for ullong, and making parse_size_err() a macro that automatically
calls one or the other. It also has the benefit of automatically
supporting compatible types (long, size_t etc).

7 months agoMEDIUM: config: warn on unitless timeouts < 100 ms
Willy Tarreau [Mon, 18 Nov 2024 18:47:59 +0000 (19:47 +0100)] 
MEDIUM: config: warn on unitless timeouts < 100 ms

From time to time we face a configuration with very small timeouts which
look accidental because there could be expectations that they're expressed
in seconds and not milliseconds.

This commit adds a check for non-nul unitless values smaller than 100
and emits a warning suggesting to append an explicit unit if that was
the intent.

Only the common timeouts, the server check intervals and the resolvers
hold and timeout values were covered for now. All the code needs to be
manually reviewed to verify if it supports emitting warnings.

This may break some configs using "zero-warning", but greps in existing
configs indicate that these are extremely rare and solely intentionally
done during tests. At least even if a user leaves that after a test, it
will be more obvious when reading 10ms that something's probably not
correct.

7 months agoREGTESTS: enable -dW on almost all tests to fail on warnings
Willy Tarreau [Tue, 19 Nov 2024 06:11:02 +0000 (07:11 +0100)] 
REGTESTS: enable -dW on almost all tests to fail on warnings

Now that warnings were almost all removed, let's enable zero-warning
via -dW. All tests were adjusted, but two:

  - mcli/mcli_start_progs.vtc:
      the programs section currently cannot be silenced

  - stats/stats-file.vtc:
      the warning comes from the stats file itself on comment lines.

All other ones are now OK.

7 months agoREGTESTS: only use tune.ssl.default-dh-param when not using AWS-LC
Willy Tarreau [Tue, 19 Nov 2024 08:26:12 +0000 (09:26 +0100)] 
REGTESTS: only use tune.ssl.default-dh-param when not using AWS-LC

This option is not available with AWS-LC and emits a warning, so let's
properly enclose the test to cover this special case.

7 months agoREGTESTS: add missing timeouts to 30 tests
Willy Tarreau [Tue, 19 Nov 2024 06:43:04 +0000 (07:43 +0100)] 
REGTESTS: add missing timeouts to 30 tests

No less than 30 tests were missing timeouts, preventing them from being
started with zero-warning. Since they were not supposed to trigger, they
have been set to 30s so as never to trigger, and now they do not produce
any warning anymore.

7 months agoREGTESTS: silence warning "L6 sample fetches ignored" in cond_set_var
Willy Tarreau [Tue, 19 Nov 2024 07:27:47 +0000 (08:27 +0100)] 
REGTESTS: silence warning "L6 sample fetches ignored" in cond_set_var

This reg-test uses req.len in an HTTP backend. It does work but emits a
warning suggesting that this is ignored, so most likely its days are
counted now. Let's just use req.hdrs,length instead.

7 months agoREGTESTS: remove a duplicate "option httpslog" in the defaults section
Willy Tarreau [Tue, 19 Nov 2024 07:05:27 +0000 (08:05 +0100)] 
REGTESTS: remove a duplicate "option httpslog" in the defaults section

This triggers the following warning:

  'option httpslog' overrides previous 'option httpslog' in 'defaults' section.

7 months agoREGTESTS: silence warnings about content-type being ignored
Willy Tarreau [Tue, 19 Nov 2024 06:59:21 +0000 (07:59 +0100)] 
REGTESTS: silence warnings about content-type being ignored

The following rules are triggering warnings about content-type being
ignored:

  http-request return content-type "text/plain" if { path /def-4 }
  http-request return content-type "text/plain" file /dev/null hdr "x-custom-hdr" "%[url]"  if { path /empty-file }

Annoyingly, the content-type is mandatory when the file is not empty,
that might be something to revisit in the future to relax at least one
of the rules so that the config doesn't strictly require to know the
file contents upfront.

7 months agoREGTESTS: make the unit explicit for very short timeouts
Willy Tarreau [Tue, 19 Nov 2024 06:50:54 +0000 (07:50 +0100)] 
REGTESTS: make the unit explicit for very short timeouts

Two tests were using "timeout {client,server} 1" to forcefully trigger
them, but a forthcoming patch will emit a warning for such small unitless
values, so let's be explicit about the unit.

7 months agoREGTESTS: silence warning "previous 'http-response' action is final"
Willy Tarreau [Tue, 19 Nov 2024 06:48:01 +0000 (07:48 +0100)] 
REGTESTS: silence warning "previous 'http-response' action is final"

The regtest "h1or2_to_h1c" contains both an allow and a deny at the end,
likely to help catch rare bugs. But this triggers a warning that we can
silence by placing a condition on the penultimate rule.

7 months agoREGTESTS: silence the "log format ignored" warnings
Willy Tarreau [Tue, 19 Nov 2024 06:46:26 +0000 (07:46 +0100)] 
REGTESTS: silence the "log format ignored" warnings

Several tests were declaring a log format without having an explicit
log server configured, causing a warning. Let's clean them up.

7 months agoMINOR: cfgparse: parse tune.bufsize.small as a size
Willy Tarreau [Mon, 18 Nov 2024 18:07:05 +0000 (19:07 +0100)] 
MINOR: cfgparse: parse tune.bufsize.small as a size

Till now this value was parsed as raw integer using atol() and would
silently ignore any trailing suffix, causing unexpected behaviors when
set, e.g. to "4k". Let's make use of parse_size_err() on it so that
units are supported. This requires to turn it to uint as well, which
was verified to be OK.

7 months agoMINOR: cfgparse: parse tune.bufsize as a size
Willy Tarreau [Mon, 18 Nov 2024 18:04:57 +0000 (19:04 +0100)] 
MINOR: cfgparse: parse tune.bufsize as a size

Till now this value was parsed as raw integer using atol() and would
silently ignore any trailing suffix, preventing from starting when set
e.g. to "64k". Let's make use of parse_size_err() on it so that units are
supported. This requires to turn it to uint as well, and to explicitly
limit its range to INT_MAX - 2*sizeof(void*), which was previously
partially handled as part of the sign check.

7 months agoMINOR: cfgparse: parse tune.recv_enough as a size
Willy Tarreau [Mon, 18 Nov 2024 18:01:28 +0000 (19:01 +0100)] 
MINOR: cfgparse: parse tune.recv_enough as a size

Till now this value was parsed as raw integer using atol() and would
silently ignore any trailing suffix, causing unexpected behaviors when
set, e.g. to "512k". Let's make use of parse_size_err() on it so that
units are supported. This requires to turn it to uint as well, and
since it's sometimes compared to an int, we limit its range to
0..INT_MAX.

7 months agoMINOR: cfgparse: parse tune.pipesize as a size
Willy Tarreau [Mon, 18 Nov 2024 17:51:31 +0000 (18:51 +0100)] 
MINOR: cfgparse: parse tune.pipesize as a size

Till now this value was parsed as raw integer using atol() and would
silently ignore any trailing suffix, causing unexpected behaviors when
set, e.g. to "512k". Let's make use of parse_size_err() on it so that
units are supported. This requires to turn it to uint as well, which
was verified to be OK.

7 months agoMINOR: cfgparse: parse tune.{rcvbuf,sndbuf}.{frontend,backend} as sizes
Willy Tarreau [Mon, 18 Nov 2024 17:50:02 +0000 (18:50 +0100)] 
MINOR: cfgparse: parse tune.{rcvbuf,sndbuf}.{frontend,backend} as sizes

Till now these values were parsed as raw integer using atol() and would
silently ignore any trailing suffix, causing unexpected behaviors when
set, e.g. to "512k". Let's make use of parse_size_err() on them so that
units are supported. This requires to turn them to uint as well, which
is OK.

7 months agoMINOR: cfgparse: parse tune.{rcvbuf,sndbuf}.{client,server} as sizes
Willy Tarreau [Mon, 18 Nov 2024 17:45:45 +0000 (18:45 +0100)] 
MINOR: cfgparse: parse tune.{rcvbuf,sndbuf}.{client,server} as sizes

Till now these values were parsed as raw integer using atol() and would
silently ignore any trailing suffix, causing unexpected behaviors when
set, e.g. to "512k". Let's make use of parse_size_err() on them so that
units are supported. This requires to turn them to uint as well, which
is OK.

7 months agoMINOR: sample: extend the "when" converter to support an ACL
Willy Tarreau [Mon, 18 Nov 2024 14:27:28 +0000 (15:27 +0100)] 
MINOR: sample: extend the "when" converter to support an ACL

Sometimes conditions to decide of an anomaly are not as easy to define
as just an error or a success. One example use case would be to monitor
the transfer time and fix a threshold.

An idea suggested by Tristan would be to make permit the "when"
converter to refer to a more variable or dynamic condition.

Here we make this possible by making "when" rely on a named ACL. The
ACL then needs to be specified in either the proxy or the defaults
section. Since it is evaluated inline, it may even refer to information
available at the end (at log time) such as the data transfer time. If
the ACL evalutates to true, the converter passes the data.

Example: log "dbg={-}" when fine, or "dbg={... debug info ...}" on slow
transfers:

  acl slow_xfer res.timer.data ge 10000   # more than 10s is slow
  log-format "$HAPROXY_HTTP_LOG_FMT                                \
              fsdbg={%[fs.debug_str,when(acl,slow_xfer)]}          \
              bsdbg={%[bs.debug_str,when(acl,slow_xfer)]}"

7 months agoMINOR: acl: export find_acl_default()
Willy Tarreau [Mon, 18 Nov 2024 14:15:54 +0000 (15:15 +0100)] 
MINOR: acl: export find_acl_default()

It will be needed in a future patch, so let's export it (it was static).

7 months ago[RELEASE] Released version 3.1-dev13 v3.1-dev13
Willy Tarreau [Fri, 15 Nov 2024 17:42:29 +0000 (18:42 +0100)] 
[RELEASE] Released version 3.1-dev13

Released version 3.1-dev13 with the following main changes :
    - MEDIUM: mworker: depreciate the 'program' section
    - BUILD: ot: use a cebtree instead of a list for variable names
    - MINOR: startup: replace HAPROXY_LOAD_SUCCESS with global load_status
    - BUG/MINOR: startup: set HAPROXY_CFGFILES in read_cfg
    - BUG/MINOR: cli: don't show sockpairs in HAPROXY_CLI and HAPROXY_MASTER_CLI
    - BUG/MEDIUM: stconn: Don't forward shut for SC in connecting state
    - BUG/MEDIUM: resolvers: Insert a non-executed resulution in front of the wait list
    - MINOR: debug: explicitly permit the counter condition to be empty
    - MINOR: debug: add a new counter type for glitches
    - MINOR: mux-h2: count glitches when they're reported
    - BUG/MINOR: deinit: release uri_auth admin rules
    - MINOR: uri_auth: add stats_uri_auth_free helper
    - MEDIUM: uri_auth: implement clean uri_auth cleaning
    - MINOR: mux-quic/h3: count glitches when they're reported
    - BUG/MEDIUM: mux-h2: Don't send RST_STREAM frame for streams with no ID
    - BUG/MINOR: Don't report early srv aborts on request forwarding in DONE state
    - MINOR: promex: Expose the global node and description in process metrics
    - MINOR: promex: Add global and proxies description as labels to all metrics
    - OPTIM: pattern: only apply LRU cache for large enough lists
    - BUG/MEDIUM: checks: make sure to always apply offsets to now_ms in expiration
    - BUG/MINOR: debug: do not set task expiration to TICK_ETERNITY
    - BUG/MEDIUM: mailers: make sure to always apply offsets to now_ms in expiration
    - BUG/MINOR: mux_quic: make sure to always apply offsets to now_ms in expiration
    - BUG/MINOR: peers: make sure to always apply offsets to now_ms in expiration
    - BUG/MEDIUM: clock: make sure now_ms cannot be TICK_ETERNITY
    - MINOR: debug/cli: replace "debug dev counters" with "debug counters"
    - DOC: config: add tune.h2.{be,fe}.rxbuf to the global keywords index
    - MINOR: chunk: add a BUG_ON upon the next init_trash_buffer()

7 months agoMINOR: chunk: add a BUG_ON upon the next init_trash_buffer()
William Lallemand [Fri, 15 Nov 2024 16:15:06 +0000 (17:15 +0100)] 
MINOR: chunk: add a BUG_ON upon the next init_trash_buffer()

The trash pool is initialized twice in haproxy, first during STG_POOL,
and 2nd after configuration parsing.

Doing alloc_trash_chunk() between this 2 phases can lead to strange
things if we are using it after, indeed the pool is destroyed and
trying to do a free_trash_chunk() or accessing the pointer will lead to
crashes.

This patch checks that we don't have used buffers from the trash pool
before initializing the pool again.

7 months agoDOC: config: add tune.h2.{be,fe}.rxbuf to the global keywords index
Willy Tarreau [Fri, 15 Nov 2024 15:32:37 +0000 (16:32 +0100)] 
DOC: config: add tune.h2.{be,fe}.rxbuf to the global keywords index

These two keywords were missing from the index, let's add them.

7 months agoMINOR: debug/cli: replace "debug dev counters" with "debug counters"
Willy Tarreau [Fri, 15 Nov 2024 15:19:05 +0000 (16:19 +0100)] 
MINOR: debug/cli: replace "debug dev counters" with "debug counters"

"debug dev" commands are not meant to be used by end-users, and are
purposely not documented. Yet due to their usefulness in troubleshooting
sessions, users are increasingly invited by developers to use some of
them.

"debug dev counters" is one of them. Better move it to "debug counters"
and document it so that users can check them even if the output can look
cryptic at times. This, combined with DEBUG_GLITCHES, can be convenient
to observe suspcious activity. The doc however precises that the format
may change between versions and that new entries/types might appear
within a stable branch.

7 months agoBUG/MEDIUM: clock: make sure now_ms cannot be TICK_ETERNITY
Willy Tarreau [Fri, 15 Nov 2024 14:52:17 +0000 (15:52 +0100)] 
BUG/MEDIUM: clock: make sure now_ms cannot be TICK_ETERNITY

In clock ticks, 0 is TICK_ETERNITY. Long ago we used to make sure now_ms
couldn't be zero so that it could be assigned to expiration timers, but
it has long changed after functions like tick_add() were instrumented to
make the check. The problem is that aside the rare few accidental direct
assignments to expiration dates, it's also used to mark the beginning of
an event that's later checked against TICK_ETERNITY to know if it has
already struck. The problem in this case is that certain events may just
be replaced or dropped just because they apparently never appeared. It's
probably the case for stconn's "lra" and "fsb" fields, just like it is
for all those involving tick_add_ifset(), like h2c->idle_start.

The right approach would be to change the type of now_ms to something
else that cannot take direct computations and that represents a timestamp,
forcing to always use the conversion functions. The variables holding such
timestamps would also be distinguished from intervals. At first glance we
could have for timestamps:
  - 0 = never happened (for the past), eternity (for the future)
  - X = date
and for intervals:
  - 0 = not set
  - X = interval

However this requires significant changes. Instead for now, let's just
make sure again that now_ms is never 0 by setting it to 1 when this
happens (1 / 4 billion times, or 1ms every 49.7 days).

This will need to be carefully backported to older versions. Note that
with this patch backported, the previous ones fixing the zero date are
not strictly needed.

7 months agoBUG/MINOR: peers: make sure to always apply offsets to now_ms in expiration
Willy Tarreau [Fri, 15 Nov 2024 14:44:05 +0000 (15:44 +0100)] 
BUG/MINOR: peers: make sure to always apply offsets to now_ms in expiration

Now_ms can be zero nowadays, so it's not suitable for direct assignment to
t->expire, as there's a risk that the timer never wakes up once assigned
(TICK_ETERNITY). Let's use tick_add(now_ms, 0) for an immediate wakeup
instead. The impact here might be a reconnect programmed upon signal
receipt at the wrapping date not having a working timeout.

This should be backported where it applies.

7 months agoBUG/MINOR: mux_quic: make sure to always apply offsets to now_ms in expiration
Willy Tarreau [Fri, 15 Nov 2024 14:41:21 +0000 (15:41 +0100)] 
BUG/MINOR: mux_quic: make sure to always apply offsets to now_ms in expiration

Now_ms can be zero nowadays, so it's not suitable for direct assignment to
t->expire, as there's a risk that the timer never wakes up once assigned
(TICK_ETERNITY). Let's use tick_add(now_ms, 0) for an immediate wakeup
instead. The impact looks nul since the task is also woken up, but better
not leave such tasks in the timer tree anyway.

This should be backported where it applies.

7 months agoBUG/MEDIUM: mailers: make sure to always apply offsets to now_ms in expiration
Willy Tarreau [Fri, 15 Nov 2024 14:39:58 +0000 (15:39 +0100)] 
BUG/MEDIUM: mailers: make sure to always apply offsets to now_ms in expiration

Now_ms can be zero nowadays, so it's not suitable for direct assignment to
t->expire, as there's a risk that the timer never wakes up once assigned
(TICK_ETERNITY). Let's use tick_add(now_ms, 0) for an immediate wakeup
instead. The impact here might be mailers suddenly stopping.

This should be backported where it applies.

7 months agoBUG/MINOR: debug: do not set task expiration to TICK_ETERNITY
Willy Tarreau [Fri, 15 Nov 2024 14:37:38 +0000 (15:37 +0100)] 
BUG/MINOR: debug: do not set task expiration to TICK_ETERNITY

Using "debug task", it's possible to change a task's expiration, but
we must be careful not to set it to TICK_ETERNITY. Let's use tick_add()
instead. The risk is basically nul since it's a debugging command, so
no backport is needed.

7 months agoBUG/MEDIUM: checks: make sure to always apply offsets to now_ms in expiration
Willy Tarreau [Fri, 15 Nov 2024 14:34:46 +0000 (15:34 +0100)] 
BUG/MEDIUM: checks: make sure to always apply offsets to now_ms in expiration

Now_ms can be zero nowadays, so it's not suitable for direct assignment to
t->expire, as there's a risk that the timer never wakes up once assigned
(TICK_ETERNITY). Let's use tick_add(now_ms, 0) for an immediate wakeup
instead. The impact here might be health checks suddenly stopping.

This should be backported where it applies.

7 months agoOPTIM: pattern: only apply LRU cache for large enough lists
Willy Tarreau [Sun, 3 Nov 2024 17:42:26 +0000 (18:42 +0100)] 
OPTIM: pattern: only apply LRU cache for large enough lists

As shown in issue #1518, the LRU cache has a non-null cost that can
sometimes be above the match cost it's trying to avoid. After a number
of tests, it appears that:
  - "simple" match operations (sub, beg, end, int etc) reach a break-even
    after ~20 patterns in list
  - "heavy" match operations (reg) reach a break-even after ~5 patterns in
    list

Let's only consult the LRU cache when the number of patterns in the
expression is at least as large as this limit. Of course there will
always be outliers but it already starts good.

Another improvement consists in reducing the cache size to further
speed up lookups, which makes sense if less expressions use the cache.

7 months agoMINOR: promex: Add global and proxies description as labels to all metrics
Christopher Faulet [Fri, 15 Nov 2024 13:15:43 +0000 (14:15 +0100)] 
MINOR: promex: Add global and proxies description as labels to all metrics

While the global description is exposed, when defined, in a dedicated
metric, it is not possible to dump the description defined in a
frontend/listen/backend sections. So, thanks to this patch, it is now
possible to dump it as a label of all metrics of the corresponding
section. To do so, "desc-labels" parameter must be provided on the URL:

    /metrics?desc-labels

When this parameter is set, if a description is provided in a section,
including the global one, the "desc" label will be added to all metrics of
this section. For instance:

  haproxy_frontend_current_sessions{proxy="front-http",desc="..."} 1

Note that servers metrics inherit the description of their backend/listen
section.

This patch should solve the issue #1531.

7 months agoMINOR: promex: Expose the global node and description in process metrics
Christopher Faulet [Fri, 15 Nov 2024 13:09:15 +0000 (14:09 +0100)] 
MINOR: promex: Expose the global node and description in process metrics

The global node value is now exposed via "haproxy_process_node" metrics. The
metric value is always set to 1 and the node name itself is the "node"
label. The same is performed for the global description. But only if it is
defined. In that case "haproxy_process_description" metric is defined, with
1 as value and the description itself is set in the "desc" label.

7 months agoBUG/MINOR: Don't report early srv aborts on request forwarding in DONE state
Christopher Faulet [Fri, 15 Nov 2024 09:51:18 +0000 (10:51 +0100)] 
BUG/MINOR: Don't report early srv aborts on request forwarding in DONE state

L7-retries may be ignored if server aborts are detected during the request
forwarding, when the request is already in DONE state.

When a request was fully processed (so in HTTP_MSG_DONE state) and is
waiting for be forwarded to the server, there is a test to detect server
aborts, to be able to report the error. However, this test must be skipped
if the response was not received yet, to let the reponse analyszers handle
the abort. It is important to properly handle the retries. This test must
only be performed if the response analysis was finished. It means the
response must be at least in HTTP_MSG_BODY state.

This patch should be backported as far as 2.8.

7 months agoBUG/MEDIUM: mux-h2: Don't send RST_STREAM frame for streams with no ID
Christopher Faulet [Fri, 15 Nov 2024 09:25:20 +0000 (10:25 +0100)] 
BUG/MEDIUM: mux-h2: Don't send RST_STREAM frame for streams with no ID

On server side, the H2 stream is first created with an unassigned ID (ID ==
0). Its ID is assigned when the request is emitted, before formatting the
HEADERS frame. However, the session may be aborted during that stage. We
must take care to not emit RST_STREAM frame for this stream, because it does
not exist yet for the server.

It is especially important to do so because, depending on the timing, it may
also happens before the H2 PREFACE was sent.

This patch must be backported to all stable versions. It is related to issue

7 months agoMINOR: mux-quic/h3: count glitches when they're reported
Willy Tarreau [Thu, 14 Nov 2024 14:38:25 +0000 (15:38 +0100)] 
MINOR: mux-quic/h3: count glitches when they're reported

The qcc_report_glitch() function is now replaced with a macro to support
enumerating counters for each individual glitch line. For now this adds
36 such counters. The macro supports an optional description, though that
is not being used for now.

As a reminder, this requires to build with -DDEBUG_GLITCHES=1.

7 months agoMEDIUM: uri_auth: implement clean uri_auth cleaning
Aurelien DARRAGON [Wed, 13 Nov 2024 18:54:32 +0000 (19:54 +0100)] 
MEDIUM: uri_auth: implement clean uri_auth cleaning

proxy auth_uri struct was manually cleaned up during deinit, but the logic
behind was kind of akward because it was required to find out which ones
were shared or not. Instead, let's switch to a proper refcount mechanism
and free the auth_uri struct directly in proxy_free_common().

7 months agoMINOR: uri_auth: add stats_uri_auth_free helper
Aurelien DARRAGON [Wed, 13 Nov 2024 18:14:10 +0000 (19:14 +0100)] 
MINOR: uri_auth: add stats_uri_auth_free helper

Let's now leverage stats_uri_auth_free() helper to free uri_auth struct
instead of manually performing the cleanup, which is error-prone.

7 months agoBUG/MINOR: deinit: release uri_auth admin rules
Aurelien DARRAGON [Wed, 13 Nov 2024 17:26:34 +0000 (18:26 +0100)] 
BUG/MINOR: deinit: release uri_auth admin rules

When uri_auth admin rules were implemented in 474be415
("[MEDIUM] stats: add an admin level") no attempt was made to free the
list of allocated rules, which makes valgrind unhappy upon deinit when
"stats admin" is used in the config.

To fix the issue, let's cleanup the admin rules list upon deinit where
uri_auth freeing is already handled.

While this could be backported to every stable versions, given how minor
this is and has no impact on the dying process, it is probably not worth
the effort.

7 months agoMINOR: mux-h2: count glitches when they're reported
Willy Tarreau [Thu, 14 Nov 2024 07:54:32 +0000 (08:54 +0100)] 
MINOR: mux-h2: count glitches when they're reported

The h2c_report_glitch() function is now replaced with a macro to support
enumerating counters for each individual glitch line. For now this adds
43 such counters. The macro supports an optional description, though that
is not being used for now. It gives outputs like this (note that the last
one was purposely instrumented to pass a description):

   > debug dev counters glt all
   0          GLT mux_h2.c:5976 h2c_dec_hdrs()
   0          GLT mux_h2.c:5960 h2c_dec_hdrs()
   (...)
   0          GLT mux_h2.c:2207 h2c_frt_recv_preface()
   0          GLT mux_h2.c:1954 h2c_frt_stream_new(): new stream too early

As a reminder, this requires to build with -DDEBUG_GLITCHES=1.

7 months agoMINOR: debug: add a new counter type for glitches
Willy Tarreau [Thu, 14 Nov 2024 07:49:38 +0000 (08:49 +0100)] 
MINOR: debug: add a new counter type for glitches

COUNT_GLITCH() will implement an unconditional counter on its declaration
line when DEBUG_GLITCHES is set, and do nothing otherwise. The output will
be reported as "GLT" and can be filtered as "glt" on the CLI. The purpose
is to help figure what's happening if some glitches counters start going
through the roof. The macro supports an optional string argument to
describe the cause of the glitch (e.g. "truncated header"), which is then
reported in the dump.

For now this is conditioned by DEBUG_GLITCHES but if it turns out to be
light enough, maybe we'll keep it enabled full time. In this case it
might have to be moved away from debug dev, or at least documented (or
done as debug counters maybe so that dev can remain undocumented and
updatable within a branch?).

7 months agoMINOR: debug: explicitly permit the counter condition to be empty
Willy Tarreau [Thu, 14 Nov 2024 07:47:00 +0000 (08:47 +0100)] 
MINOR: debug: explicitly permit the counter condition to be empty

In order to count new event types, we'll need to support empty conditions
so that we don't have to fake if (1) that would pollute the output. This
change checks if #cond is an empty string before concatenating it with
the optional var args, and avoids dumping the colon on the dump if the
whole description is empty.