]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
20 months agoMEDIUM: channel: don't look at iobuf to report an empty channel
Christopher Faulet [Tue, 25 Jul 2023 06:30:01 +0000 (08:30 +0200)] 
MEDIUM: channel: don't look at iobuf to report an empty channel

It is important to split channels and I/O buffers. When data are pushed in
an I/O buffer, we consider them as forwarded. The channel never sees
them. Fast-forwarded data are now handled in the SE only.

20 months agoMEDIUM: mux-h2: Add consumer-side fast-forwarding support
Christopher Faulet [Thu, 3 Aug 2023 16:18:45 +0000 (18:18 +0200)] 
MEDIUM: mux-h2: Add consumer-side fast-forwarding support

The H2 multiplexer now implements callbacks to consume fast-forwarded
data. It is the most usful case: A H2 client getting data from a H1
server. It is also the easiest case to implement. The producer side is
trickier because of multiplexing. It is not obvious this case would be
improved with data fast-forwarding.

20 months agoMINOR: h2: Set the BODYLESS_RESP flag on the HTX start-line if necessary
Christopher Faulet [Tue, 10 Oct 2023 14:30:52 +0000 (16:30 +0200)] 
MINOR: h2: Set the BODYLESS_RESP flag on the HTX start-line if necessary

When message headers are parsed and an HTX start-line is created, if we
detect the response must not have any payload, a specific flag must be set
on the HTX start-line. It happens for instance for response to HEAD
requests. This flag is useb by the multiplexers to know response payload, if
any, must be silently skipped.

This was not performed when h2 HEADERS frames were decoded. This HTX flag
was specifically added to fix a bug when the splicing is inuse. Thus the H2
multiplexer was not concerned. Because the mux-to-mux fast-forwarding will
be introduced, it is important handle this flag in the H2 multiplexer too.

20 months agoMEDIUM: mux-h1: Add fast-forwarding support
Christopher Faulet [Fri, 29 Sep 2023 12:25:40 +0000 (14:25 +0200)] 
MEDIUM: mux-h1: Add fast-forwarding support

The H1 multiplexer now implements callbacks function to produce and consume
fast-forwarded data.

20 months agoMEDIUM: mux-h1: Simplify payload formatting based on HTX blocks on sending path
Christopher Faulet [Wed, 27 Sep 2023 14:33:29 +0000 (16:33 +0200)] 
MEDIUM: mux-h1: Simplify payload formatting based on HTX blocks on sending path

Just like for the zero-copy, this patch tries to simplify the code
responsible to format the message payload before sending it. But here, we
take care to simplify the loop on the HTX blocks. The result should be
less errorrpone.

20 months agoMEDIUM: mux-h1: Simplify zero-copy on sending path
Christopher Faulet [Wed, 27 Sep 2023 14:28:32 +0000 (16:28 +0200)] 
MEDIUM: mux-h1: Simplify zero-copy on sending path

In h1_make_data(), the function responsible to format the message payload
before sending it, the code dealing with zero-copy was slighly simplified
(at least for me :).

There is no real change but there is a better split between messages with a
content-length and cunked messages.

20 months agoMINOR: mux-h1: Add function to add size of a chunk to an outgoind message
Christopher Faulet [Mon, 25 Sep 2023 09:05:14 +0000 (11:05 +0200)] 
MINOR: mux-h1: Add function to add size of a chunk to an outgoind message

This function should be used to send the chunk size, before appending the
chunk payload. It also takes care to add a CRLF to finish a previous chunk,
if necessary. This function will be used to fix the splicing for re-chunk
responses with an unknown length.

20 months agoMEDIUM: raw-sock: Specifiy amount of data to send via snd_pipe callback
Christopher Faulet [Tue, 26 Sep 2023 16:05:29 +0000 (18:05 +0200)] 
MEDIUM: raw-sock: Specifiy amount of data to send via snd_pipe callback

When data were sent using the kernel splicing, we tried to send all data
with no restriction. Most of time it is valid. However, because the payload
representation may differ between the producer and the consumer, it is
important to be able to specify how must data to send via the splicing.

Of course, for performance reason, it is important to maximize amount of
data send via splicing at each call. However, on edge-cases, this now can be
limited.

20 months agoMEDIUM: mux-h1: Properly handle state transitions of chunked outgoing messages
Christopher Faulet [Tue, 26 Sep 2023 16:00:49 +0000 (18:00 +0200)] 
MEDIUM: mux-h1: Properly handle state transitions of chunked outgoing messages

On the sending path, there are 3 states for chunked payload in H1:

  * H1_MSG_CHUNK_SIZE: the chunk size must be emitted
  * H1_MSH_CHUNK_CRLF: The end of the chunk must be emitted
  * H1_MSG_DATA: Chunked data must be emitted

However, some shortcuts were used on the sending path to avoid some
transitions. Especially, outgoing messages were never switched in
H1_MSG_CHUNK_SIZE state.

However, it will be necessary to properly handle all transitions on the payload
to implement mux-to-mux forwarding, to be sure to always known when the chunk
size or the end of the chunk must be emitted.

20 months agoMINOR: mux-h1: Use HTX extra field only for responses with known length
Christopher Faulet [Mon, 25 Sep 2023 13:59:07 +0000 (15:59 +0200)] 
MINOR: mux-h1: Use HTX extra field only for responses with known length

For now, it is not an issue, but it is safer to explicitly ignore HTX extra
field for responses with unknown length. This will be mandatory to future
fixes, to be able to re-chunk responses with an unknown length..

20 months agoMEDIUM: stconn: Add mux-to-mux fast-forward support
Christopher Faulet [Thu, 3 Aug 2023 15:51:58 +0000 (17:51 +0200)] 
MEDIUM: stconn: Add mux-to-mux fast-forward support

Now the kernel splicing support was removed, we can add mux-to-mux
fast-forward support. Of course, the splicing support will be reintroduced
in the muxes themselves but this will be transparent.

Changes are mainly located into sc_conn_recv() and sc_conn_send().

20 months agoMINOR: connection: Remove mux callbacks about splicing
Christopher Faulet [Thu, 3 Aug 2023 15:32:05 +0000 (17:32 +0200)] 
MINOR: connection: Remove mux callbacks about splicing

The kernel splicing support was totally remove waiting for the mux-to-mux
fast-forward implementation. So corresponding mux callbacks can be removed
now.

20 months agoMINOR: mux-h1: Temporarily remove splicing support
Christopher Faulet [Thu, 3 Aug 2023 15:30:19 +0000 (17:30 +0200)] 
MINOR: mux-h1: Temporarily remove splicing support

Because the kernel splicing support was removed from the stconn, it is
useless to keep it in muxes. In this patch, we remove the kernel splicing
support from the H1 multiplexer. It will be replaced by the mux-to-mux data
fast-forwarding.

20 months agoMINOR: mux-pt: Temporarily remove splicing support
Christopher Faulet [Thu, 3 Aug 2023 15:25:50 +0000 (17:25 +0200)] 
MINOR: mux-pt: Temporarily remove splicing support

Because the kernel splicing support was removed from the stconn, it is
useless to keep it in muxes. In this patch, we remove the kernel splicing
support from the passthough multiplexer. It will be replaced by the
mux-to-mux data fast-forwarding.

20 months agoMINOR: stconn: Temporarily remove kernel splicing support
Christopher Faulet [Thu, 3 Aug 2023 15:17:15 +0000 (17:17 +0200)] 
MINOR: stconn: Temporarily remove kernel splicing support

mux-to-mux fast-forwarding will be added. To avoid mix with the splicing and
simplify the commits, the kernel splicing support is removed from the
stconn. CF_KERN_SPLICING flag is removed and the support is no longer tested
in process_stream().

In the stconn part, rcv_pipe() callback function is no longer called.

Reg-tests scripts testing the kernel splicing are temporarly marked as
broken.

20 months agoMINOR: connection: Add new mux callbacks to perform data fast-forwarding
Christopher Faulet [Thu, 3 Aug 2023 13:47:49 +0000 (15:47 +0200)] 
MINOR: connection: Add new mux callbacks to perform data fast-forwarding

To perform the mux-to-mux data fast-forwarding, 4 new callbacks were added
into the mux_ops structure. 2 callbacks will be used from the stconn for
fast-forward data. The 2 other callbacks will be used by the endpoint to
request an iobuf to the opposite endpoint.

 * fastfwd() callback function is used by a producer to forward data

 * resume_fastfwd() callback function is used by a consumer if some data are
   blocked in the iobuf, to resume the data forwarding.

 * init_fastfwd() must be used by an endpoint (the producer one), inside the
   fastfwd() callback to request an iobuf to the opposite side (the consumer
   one).

 * done_fastfwd() must be used by an endpoint (the producer one) at the end
   of fastfwd() to notify the opposite endpoint (the consumer one) if data
   were forwarded or not.

This API is still under development, so it may evolved. Especially when the
fast-forward will be extended to applets.

2 helper functions were also added into the SE api to wrap init_fastfwd()
and done_fastfwd() callback function of the underlying endpoint.

For now, this API is unsed and not implemented at all in muxes.

20 months agoMINOR: stconn: Extend iobuf to handle a buffer in addition to a pipe
Christopher Faulet [Thu, 3 Aug 2023 13:30:55 +0000 (15:30 +0200)] 
MINOR: stconn: Extend iobuf to handle a buffer in addition to a pipe

It is unused for now, but the iobuf structure now owns a pointer to a
buffer. This buffer will be used to perform mux-to-mux fast-forwarding when
splicing is not supported or unusable. This pointer should be filled by an
endpoint to let the opposite one forward data.

Extra fields, in addition to the buffer, are mandatory because the buffer
may already contains some data. the ".offset" field may be used may be used
as the position to start to copy data. Finally, the amount of data copied in
this buffer must be saved in ".data" field.

Some flags are also added to prepare next changes. And helper stconn
fnuctions are updated to also count data in the buffer. For a first
implementation, it is not planned to handle data in the buffer and in the
pipe in same time. But it will be possible to do so.

20 months agoMINOR: stconn: Start to introduce mux-to-mux fast-forwarding notion
Christopher Faulet [Thu, 3 Aug 2023 07:45:09 +0000 (09:45 +0200)] 
MINOR: stconn: Start to introduce mux-to-mux fast-forwarding notion

Instead of talking about kernel splicing at stconn/sedesc level, we now try
to talk about mux-to-mux fast-forwarding. To do so, 2 functions were added
to know if there are fast-forwarded data and to retrieve this amount of
data. Of course, for now, there is only data in a pipe.

In addition, some flags were renamed to reflect this notion. Note the
channel's documentation was not updated yet.

20 months agoMEDIUM: stconn/channel: Move pipes used for the splicing in the SE descriptors
Christopher Faulet [Thu, 22 Jun 2023 09:39:29 +0000 (11:39 +0200)] 
MEDIUM: stconn/channel: Move pipes used for the splicing in the SE descriptors

The pipes used to put data when the kernel splicing is in used are moved in
the SE descriptors. For now, it is just a simple remplacement but there is a
major difference with the pipes in the channel. The data are pushed in the
consumer's pipe while it was pushed in the producer's pipe. So it means the
request data are now pushed in the pipe of the backend SE descriptor and
response data are pushed in the pipe of the frontend SE descriptor.

The idea is to hide the pipe from the channel/SC side and to be able to
handle fast-forwading in pipe but also in buffer. To do so, the pipe is
inside a new entity, called iobuf. This entity will be extended.

20 months agoBUG/MEDIUM: mux-h2: Don't report an error on shutr if a shutw is pending
Christopher Faulet [Mon, 16 Oct 2023 17:30:02 +0000 (19:30 +0200)] 
BUG/MEDIUM: mux-h2: Don't report an error on shutr if a shutw is pending

If a shutw is blocked because the mux is full or busy, we must defer the
shutr. In this case, the H2 stream is not in H2_SS_CLOSED state because the
shutw is also deferred. If the shutr is performed, this will lead to a
error.

Concretly, when the mux is unblocked, a RST_STREAM is sent while in some
cases, an empty DATA frame with ES flag set could be sent.

This patch should be backported to all stable versions.

20 months agoBUG/MINOR: htpp-ana/stats: Specify that HTX redirect messages have a C-L header
Christopher Faulet [Tue, 17 Oct 2023 09:43:43 +0000 (11:43 +0200)] 
BUG/MINOR: htpp-ana/stats: Specify that HTX redirect messages have a C-L header

Redirect responses sent during the HTTP analysis have no payload. However
there is still a "Content-Length" header. It is important to set the
corresponding flag on the HTX start-line to be sure to preserve this header
when the reponse is sent to the client. The same is true with the stats
applet, when it returns a redirect responses.

It is especially important because we no ignore in-fly modifications of
"Content-Length" or "Transfer-Encoding" headers without updating the HTX
start-line flags.

This patch may be backported to all stable versions but it is probably
useless because only the 2.9-dev is affected by the bug.

20 months agoBUG/MEDIUM: mux-h1: do not forget TLR/EOT even when no data is sent
Christopher Faulet [Tue, 17 Oct 2023 09:07:33 +0000 (11:07 +0200)] 
BUG/MEDIUM: mux-h1: do not forget TLR/EOT even when no data is sent

Since commit 723c73f8a ("MEDIUM: mux-h1: Split h1_process_mux() to make code
more readable"), outgoing H1 chunked messages with no data at all get
delayed by 200ms. It is due to the fact that we end processing too early and
we don't have the opportunity to process trailers in this case.

This fix addresses it by verifying if it's required to emit EOT or trailers,
if any, when retruning from h1_make_data()

No backport is needed, this was in 2.9-dev.

20 months agoCLEANUP: hlua: Remove dead-code on error path in hlua_socket_new()
Christopher Faulet [Tue, 17 Oct 2023 05:43:53 +0000 (07:43 +0200)] 
CLEANUP: hlua: Remove dead-code on error path in hlua_socket_new()

Since last fixes about the lua cosocket, the appctx is no longer initialized
in hlua_socket_new(). The code to deal with error at this stage can be
removed.

This patch should fix the issue #2308.

20 months agoBUG/MEDIUM: quic_conn: let the scheduler kill the task when needed
Willy Tarreau [Tue, 17 Oct 2023 15:00:10 +0000 (17:00 +0200)] 
BUG/MEDIUM: quic_conn: let the scheduler kill the task when needed

The two timer handlers qc_process_timer() and qc_idle_timer_task() would
inadvertently return NULL when they don't want to be requeued, instead
of just returning the task itself. The effect of returning NULL for the
scheduler is that it considers the task as freed, so it must not touch
it anymore. As such, the TASK_F_RUNNING flag is never removed from these
tasks, and when quic_conn_release() later tries to release these tasks
using task_destroy(), the latter sees the RUNNING flag and just sets
->process to NULL, hoping that the scheduler will kill them on return,
but there's no longer being executed so this never happens and they are
leaked.

Interestingly, this doesn't seem to happen as much when multi-queue is
set to off, but it's likely because the tasks are being replaced and the
first ones have already been woken up and leaked, while the latter might
only trigger on a timeout or timer renewal.

This should address github issue #2310. Thanks to @hpn0t0ad for the
numerous traces that helped understand this sequence.

This must be backported to 2.7 at least, and adapted for 2.6
(qc_idle_timer_task must return t there).

20 months agoDEBUG: pool: store the memprof bin on alloc() and update it on free()
Willy Tarreau [Tue, 17 Oct 2023 09:13:00 +0000 (11:13 +0200)] 
DEBUG: pool: store the memprof bin on alloc() and update it on free()

When looking at "show pools", it's often difficult to know which alloc()
corresponds to which free() since it's not often 1:1. But sometimes we
have all elements available to maintain a link between alloc and free.
Indeed, when the caller is recorded in the allocated area, we can store
the pointer to the just created bin instead of the caller address itself,
since the caller address is already in the memprof bin. By doing so, we
permit the pool_free() call to locate the allocator bin and update its
free count when caller tracing is enabled. This for example allows to
produce outputs like this on "show profiling" and a process started with
-dMcaller:

  1391967  1391968  22805987328  22806003712|  0x59f72f process_stream+0x19f/0x3a7a p_alloc(0) [delta=-16384] [pool=buffer]
  1391936  1391937  22805479424  22805495808|  0x6e1476 task_run_applet+0x426/0xea2 p_alloc(0) [delta=-16384] [pool=buffer]
  1391925  1391925  22805299200  22805299200|  0x58435a main+0xdf07a p_alloc(0) [delta=0] [pool=buffer]
        0  2087930            0  34208645120|  0x59b519 stream_release_buffers+0xf9/0x110 p_free(-16384) [pool=buffer]
   695993   695992  11403149312  11403132928|  0x66018f main+0x1baeaf p_alloc(0) [delta=16384] [pool=buffer]
        0  1391957            0  22805823488|  0x59b47c stream_release_buffers+0x5c/0x110 p_free(-16384) [pool=buffer]
   695968   695970  11402739712  11402772480|  0x587b85 h1_io_cb+0x9a5/0xe7c p_alloc(0) [delta=-32768] [pool=buffer]
        0  1391923            0  22805266432|  0x57f388 main+0xda0a8 p_free(-16384) [pool=buffer]
   695959   695960  11402592256  11402608640|  0x586add main+0xe17fd p_alloc(0) [delta=-16384] [pool=buffer]
          0      695978              0    11402903552|         0x59cc58 stream_free+0x178/0x9ea p_free(-16384) [pool=buffer]
(...)

Here it's quickly visible that all of them got properly released.

20 months agoBUG/MINOR: mux-h2: make up other blocked streams upon removal from list
Willy Tarreau [Tue, 17 Oct 2023 06:25:19 +0000 (08:25 +0200)] 
BUG/MINOR: mux-h2: make up other blocked streams upon removal from list

An interesting issue was met when testing the mux-to-mux forwarding code.

In order to preserve fairness, in h2_snd_buf() if other streams are waiting
in send_list or fctl_list, the stream that is attempting to send also goes
to its list, and will be woken up by h2_process_mux() or h2_send() when
some space is released. But on rare occasions, there are only a few (or
even a single) streams waiting in this list, and these streams are just
quickly removed because of a timeout or a quick h2_detach() that calls
h2s_destroy(). In this case there's no even to wake up the other waiting
stream in its list, and this will possibly resume processing after some
client WINDOW_UPDATE frames or even new streams, so usually it doesn't
last too long and it not much noticeable, reason why it was left that
long. In addition, measures have shown that in heavy network-bound
benchmark, this exact situation happens on less than 1% of the streams
(reached 4% with mux-mux).

The fix here consists in replacing these LIST_DEL_INIT() calls on
h2s->list with a function call that checks if other streams were queued
to the send_list recently, and if so, which also tries to resume them
by calling h2_resume_each_sending_h2s(). The detection of late additions
is made via a new flag on the connection, H2_CF_WAIT_INLIST, which is set
when a stream is queued due to other streams being present, and which is
cleared when this is function is called.

It is particularly difficult to reproduce this case which is particularly
timing-dependent, but in a constrained environment, a test involving 32
conns of 20 streams each, all downloading a 10 MB object previously
showed a limitation of 17 Gbps with lots of idle CPU time, and now
filled the cable at 25 Gbps.

This should be backported to all versions where it applies.

20 months agoMINOR: support for http-response set-timeout
Vladimir Vdovin [Mon, 16 Oct 2023 14:09:13 +0000 (17:09 +0300)] 
MINOR: support for http-response set-timeout

Added set-timeout action for http-response. Adapted reg-tests and
documentation.

21 months agoBUG/MINOR: mux-h1: Send a 400-bad-request on shutdown before the first request
Christopher Faulet [Fri, 6 Oct 2023 13:34:04 +0000 (15:34 +0200)] 
BUG/MINOR: mux-h1: Send a 400-bad-request on shutdown before the first request

Except if we must silently ignore empty connections by enabling
http-ignore-probes or dontlognull options, when a client connection is
closed before the first request, a 400-bad-request response must be sent
with the corresponding log message. However, that is broken since the commit
fc473a6453 ("MEDIUM: mux-h1: Rely on the H1C to deal with shutdown for
reads").

The bug is subtle. Parsing errors are no longer reported on connection errors
before the first request while it should be.

This patch must be backported where the above commit is (as far as 2.7).

21 months agoBUG/MEDIUM: applet: Report a send activity everytime data were sent
Christopher Faulet [Tue, 10 Oct 2023 16:23:05 +0000 (18:23 +0200)] 
BUG/MEDIUM: applet: Report a send activity everytime data were sent

In the same way than for stream-connectors (see "BUG/MEDIUM: stconn: Report
a send activity everytime data were sent" for details), we now report a send
activity everytime something was consumed by an applet, even if some output
data remains blocked into the channel's buffer.

This patch must be backported to 2.8.

21 months agoBUG/MEDIUM: stconn: Report a send activity everytime data were sent
Christopher Faulet [Tue, 10 Oct 2023 16:07:29 +0000 (18:07 +0200)] 
BUG/MEDIUM: stconn: Report a send activity everytime data were sent

When read/write timeouts were refactored in 2.8, we decided to change when a
send activity had to be reported. Before, everytime some data were sent a
send activity were reported. At this time, the channel's wex timer were
updated. During the refactoring, we decided to limit send activity to sends
that ampty te channel's buffer, consuming all outgoing data. Idea behind
this change was to protect haproxy against clients consumming data very
slowly.

However, it is too strict. Some congested muxes but still active can hit the
client or the server timeout. It seems a bit unfair. It is especially
visible with QUIC/H3 but it is probably also possible with H2 if the window
size is small.

The better is to restore the old behavior.

This patch must be backported to 2.8.

21 months agoMINOR: server: introduce "log-bufsize" kw
Aurelien DARRAGON [Wed, 4 Oct 2023 08:32:45 +0000 (10:32 +0200)] 
MINOR: server: introduce "log-bufsize" kw

"log-bufsize" may now be used for a log server (in a log backend) to
configure the bufsize of implicit ring associated to the server (which
defaults to BUFSIZE).

21 months agoREGTEST: add a test for log-backend used as a log target
Aurelien DARRAGON [Tue, 26 Sep 2023 14:31:21 +0000 (16:31 +0200)] 
REGTEST: add a test for log-backend used as a log target

This regtest declares and uses 3 log backends, one of which has TCP syslog
servers declared in it and other ones UDP syslog servers.

Some tests aims at testing log distribution reliability by leveraging the
log-balance hash algorithm with a key extracted from the request URL, and
the dummy vtest syslog servers ensure that messages are sent to the
correct endpoint. Overall this regtest covers essential parts of the log
message distribution and log-balancing logic involved with log backends.

It also leverages the log-forward section to perform the TCP->UDP
translation required to test UDP endpoints since vtest syslog servers
work in UDP mode.

Finally, we have some tests to ensure that the server queuing/dequeuing
and failover (backup) logics work properly.

21 months agoMEDIUM: log/balance: support for the "hash" lb algorithm
Aurelien DARRAGON [Tue, 19 Sep 2023 08:51:53 +0000 (10:51 +0200)] 
MEDIUM: log/balance: support for the "hash" lb algorithm

hash lb algorithm can be configured with the "log-balance hash <cnv_list>"
directive. With this algorithm, the user specifies a converter list with
<cnv_list>.

The produced log message will be passed as-is to the provided converter
list, and the resulting hash will be used to select the log server that
will receive the log message.

21 months agoMINOR: sample: add sample_process_cnv() function
Aurelien DARRAGON [Wed, 23 Aug 2023 15:22:37 +0000 (17:22 +0200)] 
MINOR: sample: add sample_process_cnv() function

split sample_process() in 2 parts in order to be able to only process
the converter part of a sample expression from an existing input sample
struct passed as parameter.

21 months agoMINOR: lbprm: compute the hash avalanche in gen_hash()
Aurelien DARRAGON [Wed, 11 Oct 2023 09:35:48 +0000 (11:35 +0200)] 
MINOR: lbprm: compute the hash avalanche in gen_hash()

Instead of systematically computing the avalanche hash right after the
gen_hash() call, do it inside the gen_hash() function directly to ensure
avalanche setting is always considered.

21 months agoMINOR: lbprm: support for the "none" hash-type function
Aurelien DARRAGON [Wed, 11 Oct 2023 07:57:35 +0000 (09:57 +0200)] 
MINOR: lbprm: support for the "none" hash-type function

Allow the use of the "none" hash-type function so that the key resulting
from the sample expression is directly used as the hash.

This can be useful to do the hashing manually using available hashing
converters, or even custom ones, and then inform haproxy that it can
directly rely on the sample expression result which is explictly handled
as an integer in this case.

21 months agoMINOR: log/balance: support for the "random" lb algorithm
Aurelien DARRAGON [Wed, 4 Oct 2023 15:30:02 +0000 (17:30 +0200)] 
MINOR: log/balance: support for the "random" lb algorithm

In this patch we add basic support for the random algorithm:

random algorithm picks a random server using the result of the
statistical_prng() function as if it was a hash key to then compute the
related server ID.

There is no support for the <draw> parameter (which is implemented for
tcp/http load-balancing), because we don't have the required metrics to
evaluate server's load in log backends for the moment. Plus it would add
more complexity to the __do_send_log_backend() function so we'll keep it
this way for now but this might be needed in the future.

21 months agoMINOR: log/balance: support for the "sticky" lb algorithm
Aurelien DARRAGON [Thu, 21 Sep 2023 18:24:14 +0000 (20:24 +0200)] 
MINOR: log/balance: support for the "sticky" lb algorithm

sticky algorithm always tries to send log messages to the first server in
the farm. The server will stay in front during queue and dequeue
operations (no other server can steal its place), unless it becomes
unavailable, in which case it will be replaced by another server from
the tree.

21 months agoMAJOR: log: introduce log backends
Aurelien DARRAGON [Wed, 13 Sep 2023 09:52:31 +0000 (11:52 +0200)] 
MAJOR: log: introduce log backends

Using "mode log" in a backend section turns the proxy in a log backend
which can be used to log-balance logs between multiple log targets
(udp or tcp servers)

log backends can be used as regular log targets using the log directive
with "backend@be_name" prefix, like so:

  | log backend@mybackend local0

A log backend will distribute log messages to servers according to the
log load-balancing algorithm that can be set using the "log-balance"
option from the log backend section. For now, only the roundrobin
algorithm is supported and set by default.

21 months agoMINOR: sink: add sink_new_from_srv() function
Aurelien DARRAGON [Thu, 14 Sep 2023 09:35:27 +0000 (11:35 +0200)] 
MINOR: sink: add sink_new_from_srv() function

This helper function can be used to create a new sink from an existing
server struct (and thus existing proxy as well), in order to spare some
resources when possible.

21 months agoMEDIUM: sink: inherit from caller fmt in ring_write() when rings didn't set one
Aurelien DARRAGON [Fri, 25 Aug 2023 07:50:27 +0000 (09:50 +0200)] 
MEDIUM: sink: inherit from caller fmt in ring_write() when rings didn't set one

implicit rings were automatically forced to the parent logger format, but
this was done upon ring creation.

This is quite restrictive because we might want to choose the desired
format right before generating the log header (ie: when producing the
log message), depending on the logger (log directive) that is
responsible for the log message, and with current logic this is not
possible. (To this day, we still have dedicated implicit ring per log
directive, but this might change)

In ring_write(), we check if the sink->fmt is specified:
 - defined: we use it since it is the most precise format
   (ie: for named rings)
 - undefined: then we fallback to the format from the logger

With this change, implicit rings' format is now set to UNSPEC upon
creation. This is safe because the log header building function
automatically enforces the "raw" format when UNSPEC is set. And since
logger->format also defaults to "raw", no change of default behavior
should be expected.

21 months agoMEDIUM: log/sink: simplify log header handling
Aurelien DARRAGON [Thu, 24 Aug 2023 18:46:12 +0000 (20:46 +0200)] 
MEDIUM: log/sink: simplify log header handling

Introduce log_header struct to easily pass log header data between
functions and use that to simplify the logic around log header
handling.

While at it, some outdated comments were updated as well.

No change in behavior should be expected.

21 months agoMINOR: log: remove the logger dependency in do_send_log()
Aurelien DARRAGON [Thu, 24 Aug 2023 17:11:11 +0000 (19:11 +0200)] 
MINOR: log: remove the logger dependency in do_send_log()

do_send_log() now exlusively relies on explicit parameters to remove
logger dependency in low-level log sending chain.

21 months agoMINOR: log: support explicit log target as argument in __do_send_log()
Aurelien DARRAGON [Thu, 17 Aug 2023 11:45:19 +0000 (13:45 +0200)] 
MINOR: log: support explicit log target as argument in __do_send_log()

__do_send_log() now takes an extra target parameter to pass an explicit
log target instead of getting it from logger->target.

This will allow __do_send_log() to be called multiple times within a
logger entry containing multiple log targets.

21 months agoMEDIUM: sink/log: stop relying on AF_UNSPEC for rings
Aurelien DARRAGON [Wed, 13 Sep 2023 17:28:34 +0000 (19:28 +0200)] 
MEDIUM: sink/log: stop relying on AF_UNSPEC for rings

Since a5b325f92 ("MINOR: protocol: add a real family for existing FDs"),
we don't rely anymore on AF_UNSPEC for buffer rings in do_send_log.

But we kept it as a parsing hint to differentiate between implicit and
named rings during ring buffer postparsing.

However it is still a bit confusing and forces us to systematically rely
on target->addr, even for named buffer rings where it doesn't make much
sense anymore.

Now that target->addr was made a pointer in a recent commit, we can
choose not to initialize it when not needed (i.e.: named rings) and use
this as a hint to distinguish implicit rings during init since they rely
on the addr struct to temporarily store the ring's address until the ring
is actually created during postparsing step.

21 months agoDOC: config: log <address> becomes log <target> in "log" related doc
Aurelien DARRAGON [Mon, 25 Sep 2023 14:38:39 +0000 (16:38 +0200)] 
DOC: config: log <address> becomes log <target> in "log" related doc

This is a follow up of the previous commit to emphasize that "log"
directive allows to provide a log target which may directly be a server
address but may also be a log transport facility such as rings. Thus we
use the term "target" instead of "address" to make it more generic.

21 months agoMEDIUM: log: introduce log target
Aurelien DARRAGON [Mon, 11 Sep 2023 14:10:37 +0000 (16:10 +0200)] 
MEDIUM: log: introduce log target

log targets were immediately embedded in logger struct (previously
named logsrv) and could not be used outside of this context.

In this patch, we're introducing log_target type with the associated
helper functions so that it becomes possible to declare and use log
targets outside of loggers scope.

21 months agoMEDIUM: tree-wide: logsrv struct becomes logger
Aurelien DARRAGON [Mon, 11 Sep 2023 13:06:53 +0000 (15:06 +0200)] 
MEDIUM: tree-wide: logsrv struct becomes logger

When 'log' directive was implemented, the internal representation was
named 'struct logsrv', because the 'log' directive would directly point
to the log target, which used to be a (UDP) log server exclusively at
that time, hence the name.

But things have become more complex, since today 'log' directive can point
to ring targets (implicit, or named) for example.

Indeed, a 'log' directive does no longer reference the "final" server to
which the log will be sent, but instead it describes which log API and
parameters to use for transporting the log messages to the proper log
destination.

So now the term 'logsrv' is rather confusing and prevents us from
introducing a new level of abstraction because they would be mixed
with logsrv.

So in order to better designate this 'log' directive, and make it more
generic, we chose the word 'logger' which now replaces logsrv everywhere
it was used in the code (including related comments).

This is internal rewording, so no functional change should be expected
on user-side.

21 months agoBUG/MEDIUM: quic-conn: free unsent frames on retransmit to prevent crash
Amaury Denoyelle [Thu, 12 Oct 2023 16:15:01 +0000 (18:15 +0200)] 
BUG/MEDIUM: quic-conn: free unsent frames on retransmit to prevent crash

Since the following patch :
  commit 33c49cec987c1dcd42d216c6d075fb8260058b16
  MINOR: quic: Make qc_dgrams_retransmit() return a status.
retransmission process is interrupted as soon as a fatal send error has
been encounted. However, this may leave frames in local list. This cause
several issues : a memory leak and a potential crash.

The crash happens because leaked frames are duplicated of an origin
frame via qc_dup_pkt_frms(). If an ACK arrives later for the origin
frame, all duplicated frames are also freed. During qc_frm_free(),
LIST_DEL_INIT() operation is invalid as it still references the local
list used inside qc_dgrams_retransmit().

This bug was reproduced using the following injection from another
machine :
  $ h2load --npn-list h3 -t 8 -c 10000 -m 1 -n 2000000000 \
      https://<host>:<port>/?s=4m

Haproxy was compiled using ASAN. The crash resulted in the following
trace :
==332748==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fff82bf9d78 at pc 0x556facd3b95a bp 0x7fff82bf8b20 sp 0x7fff82bf8b10
WRITE of size 8 at 0x7fff82bf9d78 thread T0
    #0 0x556facd3b959 in qc_frm_free include/haproxy/quic_frame.h:273
    #1 0x556facd59501 in qc_release_frm src/quic_conn.c:1724
    #2 0x556facd5a07f in quic_stream_try_to_consume src/quic_conn.c:1803
    #3 0x556facd5abe9 in qc_treat_acked_tx_frm src/quic_conn.c:1866
    #4 0x556facd5b3d8 in qc_ackrng_pkts src/quic_conn.c:1928
    #5 0x556facd60187 in qc_parse_ack_frm src/quic_conn.c:2354
    #6 0x556facd693a1 in qc_parse_pkt_frms src/quic_conn.c:3203
    #7 0x556facd7531a in qc_treat_rx_pkts src/quic_conn.c:4606
    #8 0x556facd7a528 in quic_conn_app_io_cb src/quic_conn.c:5059
    #9 0x556fad3284be in run_tasks_from_lists src/task.c:596
    #10 0x556fad32a3fa in process_runnable_tasks src/task.c:876
    #11 0x556fad24a676 in run_poll_loop src/haproxy.c:2968
    #12 0x556fad24b510 in run_thread_poll_loop src/haproxy.c:3167
    #13 0x556fad24e7ff in main src/haproxy.c:3857
    #14 0x7fae30ddd0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2)
    #15 0x556facc9375d in _start (/opt/haproxy-quic-2.8/haproxy+0x1ea75d)

Address 0x7fff82bf9d78 is located in stack of thread T0 at offset 40 in frame
    #0 0x556facd74ede in qc_treat_rx_pkts src/quic_conn.c:4580

This must be backported up to 2.7.

21 months agoBUG/MINOR: mux-quic: fix free on qcs-new fail alloc
Amaury Denoyelle [Wed, 11 Oct 2023 15:32:04 +0000 (17:32 +0200)] 
BUG/MINOR: mux-quic: fix free on qcs-new fail alloc

qcs_new() allocates several elements in intermediary steps. All elements
must first be properly initialized to be able to free qcs instance in
case of an intermediary failure.

Previously, qc_stream_desc allocation was done in the middle of
qcs_new() before some elements initializations. In case this fails, a
crash can happened as some elements are left uninitialized.

To fix this, move qc_stream_desc allocation at the end of qcs_new().
This ensures that all qcs elements are initialized first.

This should be backported up to 2.6.

21 months agoBUG/MINOR: quic: fix free on quic-conn fail alloc
Amaury Denoyelle [Wed, 11 Oct 2023 14:04:35 +0000 (16:04 +0200)] 
BUG/MINOR: quic: fix free on quic-conn fail alloc

qc_new_conn() allocates several elements in intermediary steps. If one
of the fails, a global free is done on the quic_conn and its elements.
This requires that most elements are first initialized to NULL or
equivalent to ensure freeing operation is done only on proper values.

Once of this element is qc.tx.cc_buf_area. It was initialized too late
which could caused crashes. This is introduced by
  9f7cfb0a56352188854bdaef9617ca836c2a30c9
  MEDIUM: quic: Allow the quic_conn memory to be asap released.

No need to backport.

21 months agoBUG/MINOR: quic: fix qc.cids access on quic-conn fail alloc
Amaury Denoyelle [Wed, 11 Oct 2023 13:40:38 +0000 (15:40 +0200)] 
BUG/MINOR: quic: fix qc.cids access on quic-conn fail alloc

CIDs tree is now allocated dynamically since the following commit :
  276697438d50456f92487c990f20c4d726dfdb96
  MINOR: quic: Use a pool for the connection ID tree.

This can caused a crash if qc_new_conn() is interrupted due to an
intermediary failed allocation. When freeing all connection members,
free_quic_conn_cids() is used. However, this function does not support a
NULL cids.

To fix this, simply check that cids is NULL during free_quic_conn_cids()
prologue.

This bug was reproduced using -dMfail.

No need to backport.

21 months agoBUG/MAJOR: connection: make sure to always remove a connection from the tree
Willy Tarreau [Thu, 12 Oct 2023 12:01:49 +0000 (14:01 +0200)] 
BUG/MAJOR: connection: make sure to always remove a connection from the tree

Since commit 5afcb686b ("MAJOR: connection: purge idle conn by last usage")
in 2.9-dev4, the test on conn->toremove_list added to conn_get_idle_flag()
in 2.8 by commit 3a7b539b1 ("BUG/MEDIUM: connection: Preserve flags when a
conn is removed from an idle list") becomes misleading. Indeed, now both
toremove_list and idle_list are shared by a union since the presence in
these lists is mutually exclusive. However, in conn_get_idle_flag() we
check for the presence in the toremove_list to decide whether or not to
delete the connection from the tree. This test now fails because instead
it sees the presence in the idle or safe list via the union, and concludes
the element must not be removed. Thus the element remains in the tree and
can be found later after the connection is released, causing crashes that
Tristan reported in issue #2292.

The following config is sufficient to reproduce it with 2 threads:

   defaults
        mode http
        timeout client 5s
        timeout server 5s
        timeout connect 1s

   listen front
        bind :8001
        server next 127.0.0.1:8002

   frontend next
        bind :8002
        timeout http-keep-alive 1
        http-request redirect location /

Sending traffic with a few concurrent connections and some short timeouts
suffices to instantly crash it after ~10k reqs:

   $ h2load -t 4 -c 16 -n 10000 -m 1 -w 1 http://0:8001/

With Amaury we analyzed the conditions in which the function is called
in order to figure a better condition for the test and concluded that
->toremove_list is never filled there so we can safely remove that part
from the test and just move the flag retrieval back to what it was prior
to the 2.8 patch above. Note that the patch is not reverted though, as
the parts that would drop the unexpected flags removal are unchanged.

This patch must NOT be backported. The code in 2.8 works correctly, it's
only the change in 2.9 that makes it misbehave.

21 months agoCLEANUP: connection: drop an uneeded leftover cast
Willy Tarreau [Thu, 12 Oct 2023 12:14:20 +0000 (14:14 +0200)] 
CLEANUP: connection: drop an uneeded leftover cast

In conn_delete_from_tree() there remains a cast of the toremove_list
to struct list while the introduction of the union precisely was to
avoid this cast. It's a leftover from the first version of patch
5afcb686b ("MAJOR: connection: purge idle conn by last usage") merged
into in 2.9-dev4, let's fix that.

No backport is needed.

21 months agoBUG/MINOR: h3: strengthen host/authority header parsing
Amaury Denoyelle [Mon, 9 Oct 2023 14:14:44 +0000 (16:14 +0200)] 
BUG/MINOR: h3: strengthen host/authority header parsing

HTTP/3 specification has several requirement when parsing authority or
host header inside a request. However, it was until then only partially
implemented.

This commit fixes this by ensuring the following :
* reject an empty authority/host header
* reject a host header if an authority was found with a different value
* no authority neither host header present

This must be backported up to 2.6.

21 months agoBUG/MINOR: mux-quic: support initial 0 max-stream-data
Amaury Denoyelle [Mon, 9 Oct 2023 14:15:20 +0000 (16:15 +0200)] 
BUG/MINOR: mux-quic: support initial 0 max-stream-data

Support stream opening with an initial max-stream-data of 0.

In normal case, QC_SF_BLK_SFCTL is set when a qcs instance cannot
transfer more data due to flow-control. This flag is set when
transfering data from MUX to quic-conn instance.

However, it's possible to define an initial value of 0 for
max-stream-data. In this case, qcs instance is blocked despite
QC_SF_BLK_SFCTL not set. No STREAM frame is prepared for this stream as
it's not possible to emit any byte, so QC_SF_BLK_SFCTL flag is never
set.

This behavior should cause no harm. However, this can cause a BUG_ON()
crash on qcc_io_send(). Indeed, when sending is retried, it ensures that
only qcs instance waiting for a new qc_stream_buf or with
QC_SF_BLK_SFCTL set is present in the send_list.

To fix this, initialize qcs with 0 value for msd and QC_SF_BLK_SFCTL.
The flag is removed only if transport parameter msd value is non null.

This should be backported up to 2.6.

21 months agoBUG/MEDIUM: mux-quic: fix RESET_STREAM on send-only stream
Amaury Denoyelle [Mon, 9 Oct 2023 08:42:04 +0000 (10:42 +0200)] 
BUG/MEDIUM: mux-quic: fix RESET_STREAM on send-only stream

When receiving a RESET_STREAM on a send-only stream, it is mandatory to
close the connection with an error STREAM_STATE error. However, this was
badly implemented as this caused two invocation of qcc_set_error() which
is forbidden by the mux-quic API.

To fix this, rely on qcc_get_qcs() to properly detect the error. Remove
qcc_set_error() usage from qcc_recv_reset_stream() instead.

This must be backported up to 2.7.

21 months agoBUG/MINOR: quic: reject packet with no frame
Amaury Denoyelle [Mon, 9 Oct 2023 08:42:35 +0000 (10:42 +0200)] 
BUG/MINOR: quic: reject packet with no frame

RFC 9000 indicates that a QUIC packet with no frame must trigger a
connection closure with PROTOCOL_VIOLATION error code. Implement this
via an early return inside qc_parse_pkt_frms().

This should be backported up to 2.6.

21 months agoREORG: quic: cleanup traces definition
Amaury Denoyelle [Fri, 6 Oct 2023 15:39:00 +0000 (17:39 +0200)] 
REORG: quic: cleanup traces definition

Move all QUIC trace definitions from quic_conn.h to quic_trace-t.h. Also
remove multiple definition trace_quic macro definition into
quic_trace.h. This forces all QUIC source files who relies on trace to
include it while reducing the size of quic_conn.h.

21 months agoBUG/MINOR: quic: Avoid crashing with unsupported cryptographic algos
Frédéric Lécaille [Wed, 11 Oct 2023 07:28:36 +0000 (09:28 +0200)] 
BUG/MINOR: quic: Avoid crashing with unsupported cryptographic algos

This bug was detected when compiling haproxy against aws-lc TLS stack
during QUIC interop runner tests. Some algorithms could be negotiated by haproxy
through the TLS stack but not fully supported by haproxy QUIC implentation.
This leaded tls_aead() to return NULL (same thing for tls_md(), tls_hp()).
As these functions returned values were never checked, they could triggered
segfaults.

To fix this, one closes the connection as soon as possible with a
handshake_failure(40) TLS alert. Note that as the TLS stack successfully
negotiates an algorithm, it provides haproxy with CRYPTO data before entering
->set_encryption_secrets() callback. This is why this callback
(ha_set_encryption_secrets() on haproxy side) is modified to release all
the CRYPTO frames before triggering a CONNECTION_CLOSE with a TLS alert. This is
done calling qc_release_pktns_frms() for all the packet number spaces.
Modify some quic_tls_keys_hexdump to avoid crashes when the ->aead or ->hp EVP_CIPHER
are NULL.
Modify qc_release_pktns_frms() to do nothing if the packet number space passed
as parameter is not intialized.

This bug does not impact the QUIC TLS compatibily mode (USE_QUIC_OPENSSL_COMPAT).

Thank you to @ilia-shipitsin for having reported this issue in GH #2309.

Must be backported as far as 2.6.

21 months agoCI: github: add awslc 1.16.0 to the push CI
William Lallemand [Wed, 11 Oct 2023 09:38:27 +0000 (11:38 +0200)] 
CI: github: add awslc 1.16.0 to the push CI

Add a awslc 1.16.0 to the push CI. Since this is a fixed version it
shouldn't cause problems.

21 months agoCI: github: update wolfssl to git revision d83f2fa
William Lallemand [Mon, 9 Oct 2023 22:29:06 +0000 (00:29 +0200)] 
CI: github: update wolfssl to git revision d83f2fa

WolfSSL 5.6.3 does not pass all the haproxy reg-tests since some fixes
are still unreleased in the master branch.

Build wolfSSL with a recent git revision to have passing reg-tests.

21 months agoCI: github: add a wolfssl entry to the CI
William Lallemand [Mon, 9 Oct 2023 21:36:13 +0000 (23:36 +0200)] 
CI: github: add a wolfssl entry to the CI

Add a build with wolfssl 5.6.3 to the github CI.

21 months agoCI: ssl: add git id support for wolfssl download
William Lallemand [Mon, 9 Oct 2023 22:26:46 +0000 (00:26 +0200)] 
CI: ssl: add git id support for wolfssl download

Allow to download a git revision directly with the git ID.

WOLFSSL_VERSION=git-d83f2fa ./scripts/build-ssl.sh

21 months agoCI: ssl: add wolfssl to build-ssl.sh
William Lallemand [Mon, 9 Oct 2023 21:34:44 +0000 (23:34 +0200)] 
CI: ssl: add wolfssl to build-ssl.sh

Add wolfssl support to the build-ssl script.

21 months agoREGTESTS: wolfssl: temporarly disable some failing reg-tests
William Lallemand [Mon, 9 Oct 2023 21:05:18 +0000 (23:05 +0200)] 
REGTESTS: wolfssl: temporarly disable some failing reg-tests

Temporarly disable the last failing reg-tests with WolfSSL in order to
be able to setup a CI.

21 months agoREGTESTS: ssl: disable ssl_dh.vtc for WolfSSL
William Lallemand [Mon, 9 Oct 2023 20:11:37 +0000 (22:11 +0200)] 
REGTESTS: ssl: disable ssl_dh.vtc for WolfSSL

Skip the ssl_dh reg-tests which is not working for WolfSSL.

21 months agoREGTESTS: ssl: update common.pem with the new pki
William Lallemand [Wed, 20 Sep 2023 16:06:03 +0000 (18:06 +0200)] 
REGTESTS: ssl: update common.pem with the new pki

Update the SSL reg-test in order to use the new pki.

21 months agoREGTESTS: pki: add a pki for SSL tests
William Lallemand [Wed, 20 Sep 2023 15:54:35 +0000 (17:54 +0200)] 
REGTESTS: pki: add a pki for SSL tests

Add a PKI generated with cfssl in order to generated easily certificates
for the reg-tests.

21 months agoBUILD: ssl: enable keylog for WolfSSL
William Lallemand [Mon, 9 Oct 2023 19:34:25 +0000 (21:34 +0200)] 
BUILD: ssl: enable keylog for WolfSSL

Enable the keylog feature when linking against an WolfSSL library which
has the 'HAVE_SECRET_CALLBACK' define.

Only supports <= TLSv1.2 secret dump.

21 months agoCLEANUP: ssl: remove compat functions for openssl < 1.0.0
William Lallemand [Mon, 9 Oct 2023 15:27:53 +0000 (17:27 +0200)] 
CLEANUP: ssl: remove compat functions for openssl < 1.0.0

The openssl-compat.h file has some function which were implemented in
order to provide compatibility with openssl < 1.0.0. Most of them where
to support the 0.9.8 version, but we don't support this version anymore.

This patch removes the deprecated code from openssl-compat.h

21 months agoBUILD: ssl: enable keylog for awslc
William Lallemand [Mon, 9 Oct 2023 14:17:30 +0000 (16:17 +0200)] 
BUILD: ssl: enable keylog for awslc

AWSLC suports SSL_CTX_set_keylog_callback(), this patch enables the
build with the keylog feature for this library.

21 months agoBUILD: ssl: add 'secure_memcmp' converter for WolfSSL and awslc
William Lallemand [Mon, 9 Oct 2023 13:44:50 +0000 (15:44 +0200)] 
BUILD: ssl: add 'secure_memcmp' converter for WolfSSL and awslc

CRYPTO_memcmp is supported by both awslc and wolfssl, lets add the
suport for the 'secure_memcmp' converter into the build.

21 months agoBUILD: ssl: add 'ssl_c_r_dn' fetch for WolfSSL
William Lallemand [Mon, 9 Oct 2023 13:09:47 +0000 (15:09 +0200)] 
BUILD: ssl: add 'ssl_c_r_dn' fetch for WolfSSL

WolfSSL supports SSL_get0_verified_chain() so we can activate this
feature.

21 months agoBUILD: ssl: enable 'ciphersuites' for WolfSSL
William Lallemand [Mon, 9 Oct 2023 12:56:43 +0000 (14:56 +0200)] 
BUILD: ssl: enable 'ciphersuites' for WolfSSL

WolfSSL supports setting the 'ciphersuites', lets enable the keyword for
it.

21 months agoMINOR: ssl: add an explicit error when 'ciphersuites' are not supported
William Lallemand [Mon, 9 Oct 2023 12:46:09 +0000 (14:46 +0200)] 
MINOR: ssl: add an explicit error when 'ciphersuites' are not supported

Add an explicit error when the support for 'ciphersuites' was not enable
into the build because of the SSL library.

21 months ago[RELEASE] Released version 2.9-dev7 v2.9-dev7
Willy Tarreau [Fri, 6 Oct 2023 20:03:17 +0000 (22:03 +0200)] 
[RELEASE] Released version 2.9-dev7

Released version 2.9-dev7 with the following main changes :
    - MINOR: support for http-request set-timeout client
    - BUG/MINOR: mux-quic: remove full demux flag on ncbuf release
    - CLEANUP: freq_ctr: make all freq_ctr readers take a const
    - CLEANUP: stream: make the dump code not depend on the CLI appctx
    - MINOR: stream: split stats_dump_full_strm_to_buffer() in two
    - CLEANUP: stream: use const filters in the dump function
    - CLEANUP: stream: make strm_dump_to_buffer() take a const stream
    - MINOR: stream: make strm_dump_to_buffer() take an arbitrary buffer
    - MINOR: stream: make strm_dump_to_buffer() show the list of filters
    - MINOR: stream: make stream_dump() always multi-line
    - MINOR: streams: add support for line prefixes to strm_dump_to_buffer()
    - MEDIUM: stream: now provide full stream dumps in case of loops
    - MINOR: debug: use the more detailed stream dump in panics
    - CLEANUP: stream: remove the now unused stream_dump() function
    - Revert "BUG/MEDIUM: quic: missing check of dcid for init pkt including a token"
    - MINOR: stream: fix output alignment of stuck thread dumps
    - BUG/MINOR: proto_reverse_connect: fix FD leak on connection error
    - BUG/MINOR: tcp_act: fix attach-srv rule ACL parsing
    - MINOR: connection: define error for reverse connect
    - MINOR: connection: define mux flag for reverse support
    - MINOR: tcp_act: remove limitation on protocol for attach-srv
    - BUG/MINOR: proto_reverse_connect: fix FD leak upon connect
    - BUG/MAJOR: plock: fix major bug in pl_take_w() introduced with EBO
    - Revert "MEDIUM: sample: Small fix in function check_operator for eror reporting"
    - DOC: sample: Add a comment in 'check_operator' to explain why 'vars_check_arg' should ignore the 'err' buffer
    - DEV: sslkeylogger: handle file opening error
    - MINOR: quic: define quic-socket bind setting
    - MINOR: quic: handle perm error on bind during runtime
    - MINOR: backend: refactor specific source address allocation
    - MINOR: proto_reverse_connect: support source address setting
    - BUILD: pool: Fix GCC error about potential null pointer dereference
    - MINOR: hlua: Set context's appctx when the lua socket is created
    - MINOR: hlua: Don't preform operations on a not connected socket
    - MINOR: hlua: Save the lua socket's timeout in its context
    - MINOR: hlua: Save the lua socket's server in its context
    - MINOR: hlua: Test the hlua struct first when the lua socket is connecting
    - BUG/MEDIUM: hlua: Initialize appctx used by a lua socket on connect only
    - DEBUG: mux-h1: Fix event label from trace messages about payload formatting
    - BUG/MINOR: mux-h1: Handle read0 in rcv_pipe() only when data receipt was tried
    - BUG/MINOR: mux-h1: Ignore C-L when sending H1 messages if T-E is also set
    - BUG/MEDIUM: h1: Ignore C-L value in the H1 parser if T-E is also set
    - REGTESTS: filters: Don't set C-L header in the successful response to CONNECT
    - MINOR: mux-h1: Add flags if outgoing msg contains a header about its payload
    - MINOR: mux-h1: Rely on H1S_F_HAVE_CHNK to add T-E in outgoing messages
    - BUG/MEDIUM: mux-h1: Add C-L header in outgoing message if it was removed
    - BUG/MEDIUM: mux-h1; Ignore headers modifications about payload representation
    - BUG/MINOR: h1-htx: Keep flags about C-L/T-E during HEAD response parsing
    - MINOR: h1-htx: Declare successful tunnel establishment as bodyless
    - BUILD: quic: allow USE_QUIC to work with AWSLC
    - CI: github: add USE_QUIC=1 to aws-lc build
    - BUG/MINOR: hq-interop: simplify parser requirement
    - MEDIUM: cache: Add "Origin" header to secondary cache key
    - MINOR: haproxy: permit to register features during boot
    - MINOR: tcp_rules: tcp-{request,response} requires TCP or HTTP mode
    - MINOR: stktable: "stick" requires TCP or HTTP mode
    - MINOR: filter: "filter" requires TCP or HTTP mode
    - MINOR: backend/balance: "balance" requires TCP or HTTP mode
    - MINOR: flt_http_comp: "compression" requires TCP or HTTP mode
    - MINOR: http_htx/errors: prevent the use of some keywords when not in tcp/http mode
    - MINOR: fcgi-app: "use-fcgi-app" requires TCP or HTTP mode
    - MINOR: cfgparse-listen: "http-send-name-header" requires TCP or HTTP mode
    - MINOR: cfgparse-listen: "dynamic-cookie-key" requires TCP or HTTP mode
    - MINOR: proxy: dynamic-cookie CLIs require TCP or HTTP mode
    - MINOR: cfgparse-listen: "http-reuse" requires TCP or HTTP mode
    - MINOR: proxy: report a warning for max_ka_queue in proxy_cfg_ensure_no_http()
    - MINOR: cfgparse-listen: warn when use-server rules is used in wrong mode
    - DOC: config: unify "log" directive doc
    - MINOR: sink/log: fix some typos around postparsing logic
    - MINOR: sink: remove useless check after sink creation
    - MINOR: sink: don't rely on p->parent in sink appctx
    - MINOR: sink: don't rely on forward_px to init sink forwarding
    - MINOR: sink: refine forward_px usage
    - MINOR: sink: function to add new sink servers
    - BUG/MEDIUM: stconn: Fix comparison sign in sc_need_room()
    - BUG/MEDIUM: actions: always apply a longest match on prefix lookup

21 months agoBUG/MEDIUM: actions: always apply a longest match on prefix lookup
Willy Tarreau [Fri, 6 Oct 2023 14:51:41 +0000 (16:51 +0200)] 
BUG/MEDIUM: actions: always apply a longest match on prefix lookup

Many actions take arguments after a parenthesis. When this happens, they
have to be tagged in the parser with KWF_MATCH_PREFIX so that a sub-word
is sufficient (since by default the whole block including the parenthesis
is taken).

The problem with this is that the parser stops on the first match. This
was OK years ago when there were very few actions, but over time new ones
were added and many actions are the prefix of another one (e.g. "set-var"
is the prefix of "set-var-fmt"). And what happens in this case is that the
first word is picked. Most often that doesn't cause trouble because such
similar-looking actions involve the same custom parser so actually the
wrong selection of the first entry results in the correct parser to be
used anyway and the error to be silently hidden.

But it's getting worse when accidentally declaring prefixes in multiple
files, because in this case it will solely depend on the object file link
order: if the longest name appears first, it will be properly detected,
but if it appears last, its other prefix will be detected and might very
well not be related at all and use a distinct parser. And this is random
enough to make some actions succeed or fail depending on the build options
that affect the linkage order. Worse: what if a keyword is the prefix of
another one, with a different parser but a compatible syntax ? It could
seem to work by accident but not do the expected operations.

The correct solution is to always look for the longest matching name.
This way the correct keyword will always be matched and used and there
will be no risk to randomly pick the wrong anymore.

This fix must be backported to the relevant stable releases.

21 months agoBUG/MEDIUM: stconn: Fix comparison sign in sc_need_room()
Christopher Faulet [Fri, 4 Aug 2023 08:36:06 +0000 (10:36 +0200)] 
BUG/MEDIUM: stconn: Fix comparison sign in sc_need_room()

sc_need_room() function may be called with a negative value. In this case,
the intent is to be notified if any space was made in the channel buffer. In
the function, we get the min between the requested room and the maximum
possible room in the buffer, considering it may be an HTX buffer.

However this max value is unsigned and leads to an unsigned comparison,
casting the negative value to an unsigned value. Of course, in this case,
this always leads to the wrong result. This bug seems to have no effect but
it is hard to be sure.

To fix the issue, we take care to respect the requested room sign by casting
the max value to a signed integer.

This patch must be backported to 2.8.

21 months agoMINOR: sink: function to add new sink servers
Aurelien DARRAGON [Mon, 18 Sep 2023 15:14:22 +0000 (17:14 +0200)] 
MINOR: sink: function to add new sink servers

Move the sft creation part out of sink_finalize() function so that it
becomes possible to register sink's servers without forward_px being
set.

21 months agoMINOR: sink: refine forward_px usage
Aurelien DARRAGON [Thu, 14 Sep 2023 23:49:08 +0000 (01:49 +0200)] 
MINOR: sink: refine forward_px usage

now forward_px only serves as a hint to know if a proxy was created
specifically for the sink, in which case the sink is responsible for it.

Everywhere forward_px was used in appctx context: get the parent proxy from
the sft->srv instead.

This permits to finally get rid of the double link dependency between sink
and proxy.

21 months agoMINOR: sink: don't rely on forward_px to init sink forwarding
Aurelien DARRAGON [Mon, 18 Sep 2023 15:21:19 +0000 (17:21 +0200)] 
MINOR: sink: don't rely on forward_px to init sink forwarding

Instead, we check if at least one sft has been registered into the sink,
if it is the case, then we need to init the forwarding for the sink.

21 months agoMINOR: sink: don't rely on p->parent in sink appctx
Aurelien DARRAGON [Thu, 14 Sep 2023 22:29:53 +0000 (00:29 +0200)] 
MINOR: sink: don't rely on p->parent in sink appctx

Removing unnecessary dependency on proxy->parent pointer in
sink appctx functions by directly using the sink sft from the
applet->svcctx to get back to sink related structs.

Thanks to this, proxy used for a ringbuf does not have to be exclusive
to a single sink anymore.

21 months agoMINOR: sink: remove useless check after sink creation
Aurelien DARRAGON [Thu, 14 Sep 2023 09:41:46 +0000 (11:41 +0200)] 
MINOR: sink: remove useless check after sink creation

It's useless to check if sink has been created with BUF type after
calling sink_new_buf() since the goal of the function is to create
a new sink of BUF type.

21 months agoMINOR: sink/log: fix some typos around postparsing logic
Aurelien DARRAGON [Wed, 13 Sep 2023 15:34:58 +0000 (17:34 +0200)] 
MINOR: sink/log: fix some typos around postparsing logic

Fixing some typos that have been overlooked during the recent log/sink
API improvements. Using this patch to make sink_new_from_logsrv() static
since it is not used outside of sink.c

21 months agoDOC: config: unify "log" directive doc
Aurelien DARRAGON [Mon, 25 Sep 2023 14:10:02 +0000 (16:10 +0200)] 
DOC: config: unify "log" directive doc

"log" directive description was found 2 times in the configuration file:

First, in 3.1 in the "global parameters" chapter, and then in 4.2 in the
per-proxy keyword options.

Both descriptions are almost identical: having to maintain the "same"
documentation in 2 different places is error-prone. Due to this, some
precisions have been added in one of them, and were missing from
the other, and vice-versa, probably because one didn't see that the
"log" directive was also documented elsewhere.

To prevent the 2 descriptions from further diverging, and make it easier
to maintain, we merge them in the per-proxy "log" directive description
(in 4.2 chapter), and we add a pointer to it in the global "log" to
encourage the user to refer to the per-proxy "log" documentation for
usage details.

21 months agoMINOR: cfgparse-listen: warn when use-server rules is used in wrong mode
Aurelien DARRAGON [Fri, 22 Sep 2023 13:07:25 +0000 (15:07 +0200)] 
MINOR: cfgparse-listen: warn when use-server rules is used in wrong mode

haproxy will report a warning when "use-server" keyword is used within a
backend that doesn't support server rules to inform the user that rules
will be ignored.

To this day, only TCP and HTTP backends can make use of it.

21 months agoMINOR: proxy: report a warning for max_ka_queue in proxy_cfg_ensure_no_http()
Aurelien DARRAGON [Tue, 19 Sep 2023 16:48:23 +0000 (18:48 +0200)] 
MINOR: proxy: report a warning for max_ka_queue in proxy_cfg_ensure_no_http()

Display a warning when max_ka_queue is set (it is the case when
"max-keep-alive-queue" directive is used within a proxy section) to inform
the user that this directives depends on the "http" mode to work and thus
will safely be ignored.

21 months agoMINOR: cfgparse-listen: "http-reuse" requires TCP or HTTP mode
Aurelien DARRAGON [Tue, 19 Sep 2023 16:41:58 +0000 (18:41 +0200)] 
MINOR: cfgparse-listen: "http-reuse" requires TCP or HTTP mode

Prevent the use of the "http-reuse" keyword in proxy section when neither
the TCP nor the HTTP mode is set.

21 months agoMINOR: proxy: dynamic-cookie CLIs require TCP or HTTP mode
Aurelien DARRAGON [Wed, 20 Sep 2023 08:54:06 +0000 (10:54 +0200)] 
MINOR: proxy: dynamic-cookie CLIs require TCP or HTTP mode

Prevent the use of "dynamic-cookie" related CLI commands if the backend
is not in TCP or HTTP mode.

21 months agoMINOR: cfgparse-listen: "dynamic-cookie-key" requires TCP or HTTP mode
Aurelien DARRAGON [Tue, 19 Sep 2023 16:37:29 +0000 (18:37 +0200)] 
MINOR: cfgparse-listen: "dynamic-cookie-key" requires TCP or HTTP mode

Prevent the use of the "dynamic-cookie-key" keyword in proxy sections
when TCP or HTTP modes are not set.

21 months agoMINOR: cfgparse-listen: "http-send-name-header" requires TCP or HTTP mode
Aurelien DARRAGON [Tue, 19 Sep 2023 16:34:15 +0000 (18:34 +0200)] 
MINOR: cfgparse-listen: "http-send-name-header" requires TCP or HTTP mode

Prevent the use of the "http-send-name-header" keyword in proxy section
when neither TCP or HTTP mode is set.

21 months agoMINOR: fcgi-app: "use-fcgi-app" requires TCP or HTTP mode
Aurelien DARRAGON [Tue, 19 Sep 2023 16:28:44 +0000 (18:28 +0200)] 
MINOR: fcgi-app: "use-fcgi-app" requires TCP or HTTP mode

Prevent the use of the "use-fcgi-app" keyword in proxy sections where
neither TCP nor HTTP mode is set.

21 months agoMINOR: http_htx/errors: prevent the use of some keywords when not in tcp/http mode
Aurelien DARRAGON [Tue, 19 Sep 2023 16:16:56 +0000 (18:16 +0200)] 
MINOR: http_htx/errors: prevent the use of some keywords when not in tcp/http mode

Prevent the use of "errorfile", "errorfiles" and various errorloc options
in proxies that are neither in TCP or HTTP mode.

21 months agoMINOR: flt_http_comp: "compression" requires TCP or HTTP mode
Aurelien DARRAGON [Tue, 19 Sep 2023 16:02:00 +0000 (18:02 +0200)] 
MINOR: flt_http_comp: "compression" requires TCP or HTTP mode

Prevent the use of "compression" keyword in proxy sections when the proxy
is neither in tcp or http mode.

21 months agoMINOR: backend/balance: "balance" requires TCP or HTTP mode
Aurelien DARRAGON [Tue, 19 Sep 2023 15:39:25 +0000 (17:39 +0200)] 
MINOR: backend/balance: "balance" requires TCP or HTTP mode

Prevent the use of "balance" and associated keywords when proxy is neither
in tcp or http mode.

21 months agoMINOR: filter: "filter" requires TCP or HTTP mode
Aurelien DARRAGON [Tue, 19 Sep 2023 15:34:36 +0000 (17:34 +0200)] 
MINOR: filter: "filter" requires TCP or HTTP mode

Prevent the use of "filter" when proxy is not in TCP or HTTP mode.

21 months agoMINOR: stktable: "stick" requires TCP or HTTP mode
Aurelien DARRAGON [Tue, 19 Sep 2023 15:20:24 +0000 (17:20 +0200)] 
MINOR: stktable: "stick" requires TCP or HTTP mode

Prevent the use of "stick-table" and "stick *" when proxy is neither in
tcp or http mode.

21 months agoMINOR: tcp_rules: tcp-{request,response} requires TCP or HTTP mode
Aurelien DARRAGON [Tue, 19 Sep 2023 14:40:09 +0000 (16:40 +0200)] 
MINOR: tcp_rules: tcp-{request,response} requires TCP or HTTP mode

Prevent the use of tcp-{request,response} keyword in proxies that are
neither in TCP or HTTP modes.

21 months agoMINOR: haproxy: permit to register features during boot
Willy Tarreau [Fri, 6 Oct 2023 08:45:16 +0000 (10:45 +0200)] 
MINOR: haproxy: permit to register features during boot

The regtests are using the "feature()" predicate but this one can only
rely on build-time options. It would be nice if some runtime-specific
options could be detected at boot time so that regtests could more
flexibly adapt to what is supported (capabilities, splicing, etc).

Similarly, certain features that are currently enabled with USE_XXX
could also be automatically detected at build time using ifdefs and
would simplify the configuration, but then we'd lose the feature
report in the feature list which is convenient for regtests.

This patch makes sure that haproxy -vv shows the variable's contents
and not the macro's contents, and adds a new hap_register_feature()
to allow the code to register a new keyword.