]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
4 years agoMINOR: http-ana: Perform L7 retries because of status codes in response analyser
Christopher Faulet [Wed, 26 May 2021 11:14:39 +0000 (13:14 +0200)] 
MINOR: http-ana: Perform L7 retries because of status codes in response analyser

L7 retries because of status codes are now performed in the response
analyser. This way, it is no longer required to handle L7 retries in
si_cs_recv(). It is also useless to set CF_READ_ERROR on the response
channel to be able to trigger such retries.

In addition, if no L7 retries are performed when the response is received,
the L7 buffer is immediately released. Before in this case, it was only
released with the stream.

4 years agoBUG/MINOR: http-ana: Handle L7 retries on refused early data before K/A aborts
Christopher Faulet [Wed, 26 May 2021 10:15:37 +0000 (12:15 +0200)] 
BUG/MINOR: http-ana: Handle L7 retries on refused early data before K/A aborts

When a network error occurred on the server side, if it is not the first
request (in case of keep-alive), nothing is returned to the client and its
connexion is closed to be sure it may retry. However L7 retries on refused
early data (0rtt-rejected) must be performed first.

In addition, such L7 retries must also be performed before incrementing the
failed responses counter.

This patch must be backported as far as 2.0.

4 years agoBUG/MINOR: http-ana: Send the right error if max retries is reached on L7 retry
Christopher Faulet [Wed, 26 May 2021 08:31:06 +0000 (10:31 +0200)] 
BUG/MINOR: http-ana: Send the right error if max retries is reached on L7 retry

This bug was introduced by the previous commit (9f5382e45 Revert "MEDIUM:
http-ana: Deal with L7 retries in HTTP analysers") because I failed the
revert.

On L7 retry, if the maximum connection retries is reached, an error must be
return to the client. Depending the situation, it may be a 502-Bad-Gateway
(empty-response or junk-response), a 504-Gateway-Timeout (response-timeout)
or a 425-Too-Early (0rtt-rejected). But contrary to what the comment says,
the do_l7_retry() function always returns a success.

Note it is not a problem for L7 retries on the response status code because
the stream-interface already takes care to have not reached the maximum
connection retries counter to trigger a L7 retry.

This patch must be backported to 2.4 because the commit must also be
backported to 2.4.

4 years agoRevert "MEDIUM: http-ana: Deal with L7 retries in HTTP analysers"
Christopher Faulet [Fri, 21 May 2021 11:46:14 +0000 (13:46 +0200)] 
Revert "MEDIUM: http-ana: Deal with L7 retries in HTTP analysers"

This reverts commit 5b82cc5b5c350c7cfa194cc6bc16ad9308784541. The purpose of
this commit was to fully handle L7 retries in HTTP analysers and stop to
deal with the L7 buffer in si_cs_send()/si_cs_recv(). It is of course
cleaner this way. But there is a huge drawback. The L7 buffer is reserved
from the time the request analysis is finished until the moment the response
is received. For a small request, the analysis is finished before the
connection to the server. Thus for the L7 buffer will be kept for queued
sessions while it is not mandatory.

So, for now, the commit is reverted to go back to the less expensive
solution. This patch must be backported to 2.4.

4 years agoCLEANUP: mux-h1: Rename functions parsing input buf and filling output buf
Christopher Faulet [Tue, 16 Feb 2021 17:32:08 +0000 (18:32 +0100)] 
CLEANUP: mux-h1: Rename functions parsing input buf and filling output buf

Main functions are renamed h1_process_demux() and h1_process_mux() to be
consistent with the H2 mux. For the same reason,
h1_process_header/data/tralers) functions, responsible to parse incoming
data are renamed with "h1_handle_" prefix.

4 years agoMINOR: muxes/h1-htx: Realign input buffer using b_slow_realign_ofs()
Christopher Faulet [Thu, 4 Feb 2021 10:01:51 +0000 (11:01 +0100)] 
MINOR: muxes/h1-htx: Realign input buffer using b_slow_realign_ofs()

Input buffers have never output data. So, use b_slow_realign_ofs() function
instead of b_slow_realign(). It is a slighly simpler function. And in the H1
mux, it allows a realign by setting the input buffer head to permit
zero-copies.

4 years agoMINOR: buf: Add function to realign a buffer with a specific head position
Christopher Faulet [Thu, 4 Feb 2021 09:54:37 +0000 (10:54 +0100)] 
MINOR: buf: Add function to realign a buffer with a specific head position

b_slow_realign() function may be used to realign a buffer with a given
amount of output data, eventually 0. In such case, the head is set to
0. This function is not designed to be used with input only buffers, like
those used in the muxes. It is the purpose of b_slow_realign_ofs()
function. It does almost the same, realign a buffer. But it do so by setting
the buffer head to a specific offset.

4 years agoMINOR: h1-htx: Use a correlation table to speed-up small chunks parsing
Christopher Faulet [Fri, 21 May 2021 09:31:35 +0000 (11:31 +0200)] 
MINOR: h1-htx: Use a correlation table to speed-up small chunks parsing

Instead of using hex2i() to convert an hexa digit to an integer in the
function parsing small chunks, we now use a table because it is faster.

4 years agoMEDIUM: h1-htx: Add a function to parse contiguous small chunks
Christopher Faulet [Fri, 21 May 2021 09:05:12 +0000 (11:05 +0200)] 
MEDIUM: h1-htx: Add a function to parse contiguous small chunks

Add h1_parse_full_contig_chunks() function to parse full contiguous chunks.
This function neither handles incomplete chunks nor wrapping buffers. It is
designed to efficiently parse a buffer with several small chunks. Of course,
there is no zero copy here because it is not possible. This function is a
bit tricky and all changes may a have a impact. This one may probably be
optimized, but it is good enough for now and not too complex.

The main function (h1_parse_msg_chunks) always tries to use this function
when the HTTP parser is waiting for a chunk size. In this case, there is no
zero-copy, so there is no reason to call the generic version to parse the
chunk. However, if some unparsed data remain after this step, the generic
function is called. This way, wrapping data and incomplete chunks may be
parsed.

Quick tests show it is now slightly faster in all cases than the legacy
mode.

4 years agoMEDIUM: h1-htx: Split function to parse a chunk and the loop on the buffer
Christopher Faulet [Fri, 21 May 2021 08:56:24 +0000 (10:56 +0200)] 
MEDIUM: h1-htx: Split function to parse a chunk and the loop on the buffer

A generic function is now used to only parse the current chunk (h1_parse_chunk)
and the main one (h1_parse_msg_chunks) is used to loop on the buffer and relies
on the first one. This change is mandatory to be able to use an optimized
function to parse contiguous small chunks.

4 years agoMINOR: h1-htx: Move HTTP chunks parsing into a dedicated function
Christopher Faulet [Wed, 3 Feb 2021 10:51:24 +0000 (11:51 +0100)] 
MINOR: h1-htx: Move HTTP chunks parsing into a dedicated function

Chunked data are now parsed in a dedicated function. This way, it will be
possible to have two functions to parse chunked messages. The current one
for messages with large chunks and an other one to parse messages with small
chunks.

The parsing of small chunks is really sensitive because it may be used as a
DoS attack. So we must be carefull to have an optimized function to parse
such messages.

4 years agoMINOR: mux-h1/mux-fcgi: Don't needlessly loop on data parsing
Christopher Faulet [Tue, 2 Feb 2021 20:16:03 +0000 (21:16 +0100)] 
MINOR: mux-h1/mux-fcgi: Don't needlessly loop on data parsing

Because the function parsing H1 data is now able to handle wrapping input
buffers, there is no reason to loop anymore in the muxes to be sure to parse
wrapping data.

4 years agoMEDIUM: h1-htx: Adapt H1 data parsing to copy wrapping data in one call
Christopher Faulet [Tue, 2 Feb 2021 18:40:07 +0000 (19:40 +0100)] 
MEDIUM: h1-htx: Adapt H1 data parsing to copy wrapping data in one call

Since the beginning, wrapping input data are parsed and copied in 2 steps to
not deal with the wrapping in H1 parsing functions. But there is no reason
to do so. This needs 2 calls to parsing functions. This also means, most of
time, when the input buffer does not wrap, there is an extra call for
nothing.

Thus, now, the data parsing functions try to copy as much data as possible,
handling wrapping buffer if necessary.

4 years agoMINOR: h1-htx: Update h1 parsing functions to return result as a size_t
Christopher Faulet [Mon, 1 Feb 2021 15:37:28 +0000 (16:37 +0100)] 
MINOR: h1-htx: Update h1 parsing functions to return result as a size_t

h1 parsing functions (h1_parse_msg_*) returns the number of bytes parsed or
0 if nothing is parsed because an error occurred or some data are
missing. But they never return negative values. Thus, instead of a signed
integer, these function now return a size_t value.

The H1 and FCGI muxes are updated accordingly. Note that h1_parse_msg_data()
has been slightly adapted because the parsing of chunked messages still need
to handle negative values when a parsing error is reported by
h1_parse_chunk_size() or h1_skip_chunk_crlf().

4 years agoCLEANUP: pattern: remove export of non-existent function pattern_delete()
Dragan Dosen [Fri, 21 May 2021 15:01:08 +0000 (17:01 +0200)] 
CLEANUP: pattern: remove export of non-existent function pattern_delete()

4 years agoMINOR: map/acl: print the count of all the map/acl entries in "show map/acl"
Dragan Dosen [Fri, 21 May 2021 14:59:15 +0000 (16:59 +0200)] 
MINOR: map/acl: print the count of all the map/acl entries in "show map/acl"

The output of "show map/acl" now contains the 'entry_cnt' value that
represents the count of all the entries for each map/acl, not just the
active ones, which means that it also includes entries currently being
added.

4 years agoBUG/MINOR: http-comp: Preserve HTTP_MSGF_COMPRESSIONG flag on the response
Christopher Faulet [Fri, 21 May 2021 07:49:20 +0000 (09:49 +0200)] 
BUG/MINOR: http-comp: Preserve HTTP_MSGF_COMPRESSIONG flag on the response

This flag is set on the response when its payload is compressed by HAProxy.
It must be preserved because it may be used when the log message is emitted.

When the compression filter was refactored to support the HTX, an
optimization was added to not perform extra proessing on the trailers.
HTTP_MSGF_COMPRESSIONG flag is removed when the last data block is
compressed. It is not required, it is just an optimization and unfortunately
a bug. This optimization must be removed to preserve the flag.

This patch must be backported as far as 2.0. On the HTX is affected.

4 years agoBUG/MEDIUM: filters: Exec pre/post analysers only one time per filter
Christopher Faulet [Thu, 20 May 2021 16:00:55 +0000 (18:00 +0200)] 
BUG/MEDIUM: filters: Exec pre/post analysers only one time per filter

For each filter, pre and post callback functions must only be called one
time. To do so, when one of them is finished, the corresponding analyser bit
must be removed from pre_analyzers or post_analyzers bit field. It is only
an issue with pre-analyser callback functions if the corresponding analyser
yields. It may happens with lua action for instance. In this case, the
filters pre analyser callback function is unexpectedly called several times.

This patch should fix the issue #1263. It must be backported is all stable
versions.

4 years agoBUILD/MINOR: opentracing: fixed build when using clang
Miroslav Zagorac [Tue, 18 May 2021 18:05:10 +0000 (20:05 +0200)] 
BUILD/MINOR: opentracing: fixed build when using clang

The arguments of the snprintf() function are now consistent with the
format used.

This should fix the github issue #1242.

4 years agoBUG/MAJOR: server: prevent deadlock when using 'set maxconn server'
Amaury Denoyelle [Mon, 17 May 2021 08:47:18 +0000 (10:47 +0200)] 
BUG/MAJOR: server: prevent deadlock when using 'set maxconn server'

A deadlock is possible with 'set maxconn server' command, if there is
pending connection ready to be dequeued. This is caused by the locking
of server spinlock in both cli_parse_set_maxconn_server and
process_srv_queue.

Fix this by reducing the scope of the server lock into
server_parse_maxconn_change_request. If connection are dequeued, the
lock is taken a second time. This can be seen as suboptimal but as it
happens only during 'set maxconn server' it can be considered as
tolerable.

This issue was reported on the mailing list, for the 1.8.x branch.
It must be backported up to the 1.8.

4 years agoBUG/MEDIUM: ebtree: Invalid read when looking for dup entry
Remi Tricot-Le Breton [Tue, 18 May 2021 16:56:42 +0000 (18:56 +0200)] 
BUG/MEDIUM: ebtree: Invalid read when looking for dup entry

The first item inserted into an ebtree will be inserted directly below
the root, which is a simple struct eb_root which only holds two branch
pointers (left and right).
If we try to find a duplicated entry to this first leaf through a
ebmb_next_dup, our leaf_p pointer will point to the eb_root instead of a
complete eb_node so we cannot look for the bit part of our leaf_p since
it would try to cast our eb_root into an eb_node and perform an out of
bounds access when reading "eb_root_to_node(eb_untag(t,EB_LEFT)))->bit".
This bug was found by address sanitizer running on a CRL hot update VTC
test.

Note that the bug has been there since the import of the eb_next_dup()
and eb_prev_dup() function in 1.5-dev19 by commit 2b5702030 ("MINOR:
ebtree: add new eb_next_dup/eb_prev_dup() functions to visit duplicates").

It can be backported to all stable branches.

4 years agoCI: github actions: add OpenTracing builds
Ilya Shipitsin [Tue, 18 May 2021 09:46:43 +0000 (09:46 +0000)] 
CI: github actions: add OpenTracing builds

let us add OpenTracing module to "all features" builds

4 years agoCLEANUP: ssl: Fix coverity issues found in CA file hot update code
Remi Tricot-Le Breton [Tue, 18 May 2021 08:06:00 +0000 (10:06 +0200)] 
CLEANUP: ssl: Fix coverity issues found in CA file hot update code

Coverity found a few uninitialized values and some dead code in the
CA/CRL file hot update code as well as a missing return value check.

4 years agoCI: introduce scripts/build-vtest.sh for installing VTest
Ilya Shipitsin [Sat, 15 May 2021 06:46:15 +0000 (11:46 +0500)] 
CI: introduce scripts/build-vtest.sh for installing VTest

we install VTest for all CI systems, let us unify instalation

4 years agoBUILD/MINOR: ssl: Fix compilation with OpenSSL 1.0.2
Remi Tricot-Le Breton [Mon, 17 May 2021 16:38:34 +0000 (18:38 +0200)] 
BUILD/MINOR: ssl: Fix compilation with OpenSSL 1.0.2

The following functions used in CA/CRL file hot update were not defined
in OpenSSL 1.0.2 so they need to be defined in openssl-compat :
- X509_CRL_get_signature_nid
- X509_CRL_get0_lastUpdate
- X509_CRL_get0_nextUpdate
- X509_REVOKED_get0_serialNumber
- X509_REVOKED_get0_revocationDate

4 years agoBUILD/MINOR: ssl: Fix compilation with SSL enabled
Remi Tricot-Le Breton [Mon, 17 May 2021 09:45:55 +0000 (11:45 +0200)] 
BUILD/MINOR: ssl: Fix compilation with SSL enabled

The CA/CRL hot update patches did not compile on some targets of the CI
(mainly gcc + ssl). This patch should fix almost all of them. It adds
missing variable initializations and return value checks to the
BIO_reset calls in show_crl_detail.

4 years agoDOC: ssl: Add documentation about CRL file hot update commands
Remi Tricot-Le Breton [Tue, 27 Apr 2021 14:28:25 +0000 (16:28 +0200)] 
DOC: ssl: Add documentation about CRL file hot update commands

Add description for new "abort/commit/del/new/set/show ssl crl-file" CLI
commands.

4 years agoREGTESTS: ssl: Add "set/commit ssl crl-file" test
Remi Tricot-Le Breton [Fri, 23 Apr 2021 16:35:25 +0000 (18:35 +0200)] 
REGTESTS: ssl: Add "set/commit ssl crl-file" test

This file adds tests for the new "set ssl crl-file" and "commit ssl
crl-file" commands which allow the hot update of CRL file through CLI
commands.

4 years agoREGTESTS: ssl: Add "new/del ssl crl-file" tests
Remi Tricot-Le Breton [Thu, 22 Apr 2021 09:02:16 +0000 (11:02 +0200)] 
REGTESTS: ssl: Add "new/del ssl crl-file" tests

This vtc tests the "new ssl crl-file" which allows to create a new empty
CRL file that can then be set through a "set+commit ssl crl-file"
command pair. It also tests the "del ssl crl-file" command which allows
to delete an unused CRL file.

4 years agoMEDIUM: ssl: Add "show ssl crl-file" CLI command
Remi Tricot-Le Breton [Tue, 20 Apr 2021 15:58:01 +0000 (17:58 +0200)] 
MEDIUM: ssl: Add "show ssl crl-file" CLI command

This patch adds the "show ssl crl-file [<crlfile>]" CLI command. This
command can be used to display the list of all the known CRL files when
no specific file name is specified, or to display the details of a
specific CRL file when a name is given.
The details displayed for a specific CRL file are inspired by the ones
shown by a "openssl crl -text -noout -in <filename>".

4 years agoMINOR: ssl: Add "abort ssl crl-file" CLI command
Remi Tricot-Le Breton [Tue, 20 Apr 2021 15:42:02 +0000 (17:42 +0200)] 
MINOR: ssl: Add "abort ssl crl-file" CLI command

The "abort" command aborts an ongoing transaction started by a "set ssl
crl-file" command. Since the updated CRL file data is not pushed into
the CA file tree until a "commit ssl crl-file" call is performed, the
abort command simply deleted the new cafile_entry (storing the new CRL
file data) stored in the transaction.

4 years agoMEDIUM: ssl: Add "new+del crl-file" CLI commands
Remi Tricot-Le Breton [Mon, 26 Apr 2021 09:00:42 +0000 (11:00 +0200)] 
MEDIUM: ssl: Add "new+del crl-file" CLI commands

This patch adds the "new ssl crl-file" and "del ssl crl-file" CLI
commands.
The "new" command can be used to create a new empty CRL file that can be
filled in thanks to a "set ssl crl-file" command. It can then be used in
a new crt-list line.
The newly created CRL file is added to the CA file tree so any call to
"show ssl crl-file" will display its name.
The "del" command allows to delete an unused CRL file. A CRL file will
be considered unused if its list of ckch instances is empty. It does not
work on an uncommitted CRL file transaction created via a "set ssl
crl-file" command call.

4 years agoMEDIUM: ssl: Add "set+commit ssl crl-file" CLI commands
Remi Tricot-Le Breton [Tue, 20 Apr 2021 15:38:14 +0000 (17:38 +0200)] 
MEDIUM: ssl: Add "set+commit ssl crl-file" CLI commands

This patch adds the "set ssl crl-file" and "commit ssl crl-file"
commands, following the same logic as the certificate and CA file update
equivalents.
When trying to update a Certificate Revocation List (CRL) file via a
"set" command, we start by looking for the entry in the CA file tree and
then building a new cafile_entry out of the payload, without adding it
to the tree yet. It will only be added when a "commit" command is
called.
During a "commit" command, we insert the newly built cafile_entry in the
CA file tree while keeping the previous entry. We then iterate over all
the instances that used the CRL file and rebuild a new one and its
dedicated SSL context for every one of them.
When all the contexts are properly created, the old instances get
replaced by the new ones and the old CRL file is removed from the tree.

4 years agoMINOR: ssl: Chain instances in ca-file entries
Remi Tricot-Le Breton [Tue, 20 Apr 2021 14:54:21 +0000 (16:54 +0200)] 
MINOR: ssl: Chain instances in ca-file entries

In order for crl-file hot update to be possible, we need to add an extra
link between the CA file tree entries that hold Certificate Revocation
Lists and the instances that use them. This way we will be able to
rebuild each instance upon CRL modification.
This mechanism is similar to what was made for the actual CA file update
since both the CA files and the CRL files are stored in the same CA file
tree.

4 years agoDOC: internals: update the SSL architecture schema
Remi Tricot-Le Breton [Mon, 12 Apr 2021 13:56:23 +0000 (15:56 +0200)] 
DOC: internals: update the SSL architecture schema

Add the new relation between the CA file tree entries and the ckch
instances introduced during CA file hot update implementation (see
GitHub #1057).

4 years agoDOC: ssl: Add documentation about CA file hot update commands
Remi Tricot-Le Breton [Thu, 8 Apr 2021 13:30:23 +0000 (15:30 +0200)] 
DOC: ssl: Add documentation about CA file hot update commands

Add documentations for "abort/commit/del/new/set/show ssl ca-file" CLI
commands.

These commands were added to answer to GitHub #1057.

4 years agoREGTESTS: ssl: Add "new/del ssl ca-file" tests
Remi Tricot-Le Breton [Mon, 29 Mar 2021 09:55:40 +0000 (11:55 +0200)] 
REGTESTS: ssl: Add "new/del ssl ca-file" tests

This vtc tests the "new ssl ca-file" which allows to create a new empty
CA file that can then be set through a "set+commit ssl ca-file" command
pair. It also tests the "del ssl ca-file" command which allows to delete
an unused CA file.

4 years agoMINOR: ssl: Add "del ssl ca-file" CLI command
Remi Tricot-Le Breton [Thu, 25 Mar 2021 17:13:57 +0000 (18:13 +0100)] 
MINOR: ssl: Add "del ssl ca-file" CLI command

This patch adds the "del ssl ca-file <cafile>" CLI command which can be
used to delete an unused CA file.
The CA file will be considered unused if its list of ckch instances is
empty. This command cannot be used to delete the uncommitted CA file of
a previous "set ssl ca-file" without commit. It only acts on
CA file entries already inserted in the CA file tree.

This fixes a subpart of GitHub issue #1057.

4 years agoMEDIUM: ssl: Add "new ssl ca-file" CLI command
Remi Tricot-Le Breton [Tue, 16 Mar 2021 15:21:27 +0000 (16:21 +0100)] 
MEDIUM: ssl: Add "new ssl ca-file" CLI command

This patch adds the "new ssl ca-file <cafile>" CLI command. This command
can be used to create a new empty CA file that can be filled in thanks
to a "set ssl ca-file" command. It can then be used in a new crt-list
line.
The newly created CA file is added directly in the cafile tree so any
following "show ssl ca-file" call will display its name.

This fixes a subpart of GitHub issue #1057.

4 years agoMEDIUM: ssl: Add "show ssl ca-file" CLI command
Remi Tricot-Le Breton [Tue, 16 Mar 2021 10:19:33 +0000 (11:19 +0100)] 
MEDIUM: ssl: Add "show ssl ca-file" CLI command

This patch adds the "show ssl ca-file [<cafile>[:index]]" CLI command.
This command can be used to display the list of all the known CA files
when no specific file name is specified, or to display the details of a
specific CA file when a name is given. If an index is given as well, the
command will only display the certificate having the specified index in
the CA file (if it exists).
The details displayed for each certificate are the same as the ones
showed when using the "show ssl cert" command on a single certificate.

This fixes a subpart of GitHub issue #1057.

4 years agoMINOR: ssl: Refactorize the "show certificate details" code
Remi Tricot-Le Breton [Tue, 16 Mar 2021 09:11:44 +0000 (10:11 +0100)] 
MINOR: ssl: Refactorize the "show certificate details" code

Move all the code that dumps the details of a specific certificate into
a dedicated function so that it can be used elsewhere.

4 years agoMINOR: ssl: Add a cafile_entry type field
Remi Tricot-Le Breton [Fri, 16 Apr 2021 15:59:23 +0000 (17:59 +0200)] 
MINOR: ssl: Add a cafile_entry type field

The CA files and CRL files are stored in the same cafile_tree so this
patch adds a new field the the cafile_entry structure that specifies the
type of the entry. Since a ca-file can also have some CRL sections, the
type will be based on the option used to load the file and not on its
content (ca-file vs crl-file options).

4 years agoMINOR: ssl: Add "abort ssl ca-file" CLI command
Remi Tricot-Le Breton [Thu, 11 Mar 2021 09:22:52 +0000 (10:22 +0100)] 
MINOR: ssl: Add "abort ssl ca-file" CLI command

The "abort" command aborts an ongoing transaction started by a "set ssl
ca-file" command. Since the updated CA file data is not pushed into the
cafile tree until a "commit ssl ca-file" call is performed, the abort
command simply clears the new cafile_entry that was stored in the
cafile_transaction.

This fixes a subpart of GitHub issue #1057.

4 years agoREGTESTS: ssl: Add new ca-file update tests
Remi Tricot-Le Breton [Fri, 5 Mar 2021 13:42:40 +0000 (14:42 +0100)] 
REGTESTS: ssl: Add new ca-file update tests

This vtc tests the "set ssl ca-file" and "commit ssl ca-file" cli
commands. Those commands allow the hot update of CA files through cli
commands.

4 years agoMEDIUM: ssl: Add "set+commit ssl ca-file" CLI commands
Remi Tricot-Le Breton [Wed, 24 Feb 2021 16:35:43 +0000 (17:35 +0100)] 
MEDIUM: ssl: Add "set+commit ssl ca-file" CLI commands

This patch adds the "set ssl ca-file" and "commit ssl ca-file" commands,
following the same logic as the certificate update equivalents.
When trying to update a ca-file entry via a "set" command, we start by
looking for the entry in the cafile_tree and then building a new
cafile_entry out of the given payload. This new object is not added to
the cafile_tree until "commit" is called.
During a "commit" command, we insert the newly built cafile_entry in the
cafile_tree, while keeping the previous entry as well. We then iterate
over all the instances linked in the old cafile_entry and rebuild a new
ckch instance for every one of them. The newly inserted cafile_entry is
used for all those new instances and their respective SSL contexts.
When all the contexts are properly created, the old instances get
replaced by the new ones and the old cafile_entry is removed from the
tree.

This fixes a subpart of GitHub issue #1057.

4 years agoMINOR: ssl: Ckch instance rebuild and cleanup factorization in CLI handler
Remi Tricot-Le Breton [Wed, 24 Feb 2021 11:20:48 +0000 (12:20 +0100)] 
MINOR: ssl: Ckch instance rebuild and cleanup factorization in CLI handler

The process of rebuilding a ckch_instance when a certificate is updated
through a cli command will be roughly the same when a ca-file is updated
so this factorization will avoid code duplication.

4 years agoMINOR: ssl: Add helper function to add cafile entries
Remi Tricot-Le Breton [Tue, 23 Feb 2021 15:28:43 +0000 (16:28 +0100)] 
MINOR: ssl: Add helper function to add cafile entries

Adds a way to insert a new uncommitted cafile_entry in the tree. This
entry will be the one fetched by any lookup in the tree unless the
oldest cafile_entry is explicitely looked for. This way, until a "commit
ssl ca-file" command is completed, there could be two cafile_entries
with the same path in the tree, the original one and the newly updated
one.

4 years agoMEDIUM: ssl: Add a way to load a ca-file content from memory
Remi Tricot-Le Breton [Mon, 22 Feb 2021 17:26:14 +0000 (18:26 +0100)] 
MEDIUM: ssl: Add a way to load a ca-file content from memory

The updated CA content coming from the CLI during a ca-file update will
directly be in memory and not on disk so the way CAs are loaded in a
cafile_entry for now (via X509_STORE_load_locations calls) cannot be
used.
This patch adds a way to fill a cafile_entry directly from memory and to
load the contained certificate and CRL sections into an SSL store.
CRL sections are managed as well as certificates in order to mimic the
way CA files are processed when specified in an option. Indeed, when
parsing a CA file given through a ca-file or ca-verify-file option, we
iterate over the different sections in ssl_set_cert_crl_file and load
them regardless of their type. This ensures that a file that was
properly parsed when given as an option will also be accepted by the
CLI.

4 years agoMINOR: ssl: Add helper functions to create/delete cafile entries
Remi Tricot-Le Breton [Mon, 22 Feb 2021 14:54:55 +0000 (15:54 +0100)] 
MINOR: ssl: Add helper functions to create/delete cafile entries

Add ssl_store_create_cafile_entry and ssl_store_delete_cafile_entry
functions.

4 years agoMINOR: ssl: Add reference to default ckch instance in bind_conf
Remi Tricot-Le Breton [Tue, 13 Apr 2021 14:07:29 +0000 (16:07 +0200)] 
MINOR: ssl: Add reference to default ckch instance in bind_conf

In order for the link between the cafile_entry and the default ckch
instance to be built, we need to give a pointer to the instance during
the ssl_sock_prepare_ctx call.

4 years agoMEDIUM: ssl: Chain ckch instances in ca-file entries
Remi Tricot-Le Breton [Fri, 19 Feb 2021 16:41:55 +0000 (17:41 +0100)] 
MEDIUM: ssl: Chain ckch instances in ca-file entries

Each ca-file entry of the tree will now hold a list of the ckch
instances that use it so that we can iterate over them when updating the
ca-file via a cli command. Since the link between the SSL contexts and
the CA file tree entries is only built during the ssl_sock_prepare_ctx
function, which are called after all the ckch instances are created, we
need to add a little post processing after each ssl_sock_prepare_ctx
that builds the link between the corresponding ckch instance and CA file
tree entries.
In order to manage the ca-file and ca-verify-file options, any ckch
instance can be linked to multiple CA file tree entries and any CA file
entry can link multiple ckch instances. This is done thanks to a
dedicated list of ckch_inst references stored in the CA file tree
entries over which we can iterate (during an update for instance). We
avoid having one of those instances go stale by keeping a list of
references to those references in the instances.
When deleting a ckch_inst, we can then remove all the ckch_inst_link
instances that reference it, and when deleting a cafile_entry, we
iterate over the list of ckch_inst reference and clear the corresponding
entry in their own list of ckch_inst_link references.

4 years agoMINOR: ssl: Allow duplicated entries in the cafile_tree
Remi Tricot-Le Breton [Fri, 19 Feb 2021 14:06:28 +0000 (15:06 +0100)] 
MINOR: ssl: Allow duplicated entries in the cafile_tree

In order to ease ca-file hot update via the CLI, the ca-file tree will
need to allow duplicate entries for a given path. This patch simply
enables it and offers a way to select either the oldest entry or the
latest entry in the tree for a given path.

4 years agoCLEANUP: ssl: Move ssl_store related code to ssl_ckch.c
Remi Tricot-Le Breton [Tue, 13 Apr 2021 08:10:37 +0000 (10:10 +0200)] 
CLEANUP: ssl: Move ssl_store related code to ssl_ckch.c

This patch moves all the ssl_store related code to ssl_ckch.c since it
will mostly be used there once the CA file update CLI commands are all
implemented. It also makes the cafile_entry structure visible as well as
the cafile_tree.

4 years ago[RELEASE] Released version 2.5-dev0 v2.5-dev0
Willy Tarreau [Fri, 14 May 2021 07:36:37 +0000 (09:36 +0200)] 
[RELEASE] Released version 2.5-dev0

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

4 years agoMINOR: version: it's development again
Willy Tarreau [Fri, 14 May 2021 07:36:08 +0000 (09:36 +0200)] 
MINOR: version: it's development again

this essentially reverts 46fb37c70cd43f39de533f13639c29855dfec91e.

4 years ago[RELEASE] Released version 2.4.0 v2.4.0
Willy Tarreau [Fri, 14 May 2021 07:03:30 +0000 (09:03 +0200)] 
[RELEASE] Released version 2.4.0

Released version 2.4.0 with the following main changes :
    - BUG/MINOR: http_fetch: fix possible uninit sockaddr in fetch_url_ip/port
    - CLEANUP: cli/activity: Remove double spacing in set profiling command
    - CI: Build VTest with clang
    - CI: extend spellchecker whitelist, add "ists" as well
    - CLEANUP: assorted typo fixes in the code and comments
    - BUG/MINOR: memprof: properly account for differences for realloc()
    - MINOR: memprof: also report the method used by each call
    - MINOR: memprof: also report the totals and delta alloc-free
    - CLEANUP: pattern: remove the unused and dangerous pat_ref_reload()
    - BUG/MINOR: http_act: Fix normalizer names in error messages
    - MINOR: uri_normalizer: Add `fragment-strip` normalizer
    - MINOR: uri_normalizer: Add `fragment-encode` normalizer
    - IMPORT: slz: use the generic function for the last bytes of the crc32
    - IMPORT: slz: do not produce the crc32_fast table when CRC is natively supported
    - BUILD/MINOR: opentracing: fixed compilation with filter enabled
    - BUILD: makefile: add a few popular ARMv8 CPU targets
    - BUG/MEDIUM: stick_table: fix crash when using tcp smp_fetch_src
    - REGTESTS: stick-table: add src_conn_rate test
    - CLEANUP: stick-table: remove a leftover of an old keyword declaration
    - BUG/MINOR: stats: fix lastchk metric that got accidently lost
    - EXAMPLES: add a "basic-config-edge" example config
    - EXAMPLES: add a trivial config for quick testing
    - DOC: management: Correct example reload command in the document
    - Revert "CI: Build VTest with clang"
    - MINOR: activity/cli: optionally support sorting by address on "show profiling"
    - DEBUG: ssl: export ssl_sock_close() to see its symbol resolved in profiling
    - BUG/MINOR: lua/vars: prevent get_var() from allocating a new name
    - DOC: config: Fix configuration example for mqtt
    - BUG/MAJOR: config: properly initialize cpu_map.thread[] up to MAX_THREADS
    - BUILD: config: avoid a build warning on numa_detect_topology() without threads
    - DOC: update min requirements in INSTALL
    - IMPORT: slz: use inttypes.h instead of stdint.h
    - BUILD: sample: use strtoll() instead of atoll()
    - MINOR: version: mention that it's LTS now.

4 years agoMINOR: version: mention that it's LTS now.
Willy Tarreau [Fri, 14 May 2021 07:02:22 +0000 (09:02 +0200)] 
MINOR: version: mention that it's LTS now.

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

4 years agoBUILD: sample: use strtoll() instead of atoll()
Willy Tarreau [Fri, 14 May 2021 06:51:53 +0000 (08:51 +0200)] 
BUILD: sample: use strtoll() instead of atoll()

atoll() is not portable, but strtoll() is more common. We must pass NULL
to the end pointer however since the parser must consume digits and stop
at the first non-digit char. No backport is needed as this was introduced
in 2.4-dev17 with commit 51c8ad45c ("MINOR: sample: converter: Add json_query
converter").

4 years agoIMPORT: slz: use inttypes.h instead of stdint.h
Willy Tarreau [Fri, 14 May 2021 06:44:52 +0000 (08:44 +0200)] 
IMPORT: slz: use inttypes.h instead of stdint.h

stdint.h is not as portable as inttypes.h. It doesn't exist at least
on AIX 5.1 and Solaris 7, while inttypes.h is present there and does
include stdint.h on platforms supporting it.

This is equivalent to libslz upstream commit e36710a ("slz: use
inttypes.h instead of stdint.h")

4 years agoDOC: update min requirements in INSTALL
Willy Tarreau [Fri, 14 May 2021 06:03:00 +0000 (08:03 +0200)] 
DOC: update min requirements in INSTALL

gcc 11 was tested, and the build dir now needs more like 60 MB than 15 MB.

4 years agoBUILD: config: avoid a build warning on numa_detect_topology() without threads
Willy Tarreau [Fri, 14 May 2021 06:30:46 +0000 (08:30 +0200)] 
BUILD: config: avoid a build warning on numa_detect_topology() without threads

The function is defined when using linux+cpu affinity but is only used
if threads are enabled, so let's add this condition to avoid aa build
warning about an unused function when building with thread disabled.
This came in 2.4-dev17 with commit b56a7c89a ("MEDIUM: cfgparse: detect
numa and set affinity if needed") so no backport is needed.

4 years agoBUG/MAJOR: config: properly initialize cpu_map.thread[] up to MAX_THREADS
Willy Tarreau [Fri, 14 May 2021 06:26:38 +0000 (08:26 +0200)] 
BUG/MAJOR: config: properly initialize cpu_map.thread[] up to MAX_THREADS

A mistake was introduced in 2.4-dev17 by commit 982fb5339 ("MEDIUM:
config: use platform independent type hap_cpuset for cpu-map"), it
initializes cpu_map.thread[] from 0 to MAX_PROCS-1 instead of
MAX_THREADS-1 resulting in crashes when the two differ, e.g. when
building with USE_THREAD= but still with USE_CPU_AFFINITY=1.

No backport is needed.

4 years agoDOC: config: Fix configuration example for mqtt
Daniel Corbett [Thu, 13 May 2021 14:46:07 +0000 (10:46 -0400)] 
DOC: config: Fix configuration example for mqtt

This patch fixes the example for mqtt_is_valid(), it was missing
curly braces within the ACL.

4 years agoBUG/MINOR: lua/vars: prevent get_var() from allocating a new name
Willy Tarreau [Thu, 13 May 2021 11:30:12 +0000 (13:30 +0200)] 
BUG/MINOR: lua/vars: prevent get_var() from allocating a new name

Variable names are stored into a unified list that helps compare them
just based on a pointer instead of duplicating their name with every
variable. This is convenient for those declared in the configuration
but this started to cause issues with Lua when random names would be
created upon each access, eating lots of memory and CPU for lookups,
hence the work in 2.2 with commit 4e172c93f ("MEDIUM: lua: Add
`ifexist` parameter to `set_var`") to address this.

But there remains a corner case with get_var(), which also allocates
a new variables. After a bit of thinking and discussion, it never
makes sense to allocate a new variable name on get_var():
  - if the name exists, it will be returned ;
  - if it does not exist, then the only way for it to appear will
    be that some code calls set_var() on it
  - a call to get_var() after a careful set_var(ifexist) ruins the
    effort on set_var().

For this reason, this patch addresses this issue by making sure that
get_var() will never cause a variable to be allocated. This is done
by modifying vars_get_by_name() to always call register_name() with
alloc=0, since vars_get_by_name() is exclusively used by Lua and the
new CLI's "get/set var" which also benefit from this protection.

It probably makes sense to backport this as far as 2.2 after some
observation period and feedback from users.

For more context and discussions about the issues this was causing,
see https://www.mail-archive.com/haproxy@formilux.org/msg40451.html
and in issue #664.

4 years agoDEBUG: ssl: export ssl_sock_close() to see its symbol resolved in profiling
Willy Tarreau [Thu, 13 May 2021 08:11:03 +0000 (10:11 +0200)] 
DEBUG: ssl: export ssl_sock_close() to see its symbol resolved in profiling

This function is one of the few high-profile, unresolved ones in the memory
profile output, let's have it resolve to ease matching of SSL allocations,
which are not easy to follow.

4 years agoMINOR: activity/cli: optionally support sorting by address on "show profiling"
Willy Tarreau [Thu, 13 May 2021 08:00:17 +0000 (10:00 +0200)] 
MINOR: activity/cli: optionally support sorting by address on "show profiling"

"show profiling" by default sorts by usage/counts, which is suitable for
occasional use. But when called from scripts to monitor/search variations,
this is not very convenient. Let's add a new "byaddr" option to support
sorting the output by address. It also eases matching alloc/free calls
from within a same library, or reading grouped tasks costs by library.

4 years agoRevert "CI: Build VTest with clang"
Tim Duesterhus [Wed, 12 May 2021 19:08:49 +0000 (21:08 +0200)] 
Revert "CI: Build VTest with clang"

The issue with VTest not building properly in gcc is fixed since commit
vtest/VTest@0730540c43a2a23436b43f46327d6bac644d816d. Revert the patch to keep
the CI configuration simple.

This reverts commit e61f53eb44a390f9a8c8c4f34077c365942e0729.

4 years agoDOC: management: Correct example reload command in the document
varnav [Mon, 10 May 2021 14:29:57 +0000 (10:29 -0400)] 
DOC: management: Correct example reload command in the document

Current example is:

  `echo "reload" | socat /var/run/haproxy-master.sock`

it will cause socat error:

  `exactly 2 addresses required (there are 1); use option "-h" for help`

Correct working command is:

  `echo "reload" | socat /var/run/haproxy-master.sock stdin`

4 years agoEXAMPLES: add a trivial config for quick testing
Willy Tarreau [Wed, 12 May 2021 15:51:49 +0000 (17:51 +0200)] 
EXAMPLES: add a trivial config for quick testing

This config was taken from the example provided in the dpbench project.
It uses minimalistic keywords and is trivial to setup and adapt on any
test machine for a quick test. It can be convenient when comparing
different server platforms to pick the one delivering the best
performance in various dimensions (conn rate, req rate, ssl rate,
bit rate). It uses a single listener (optionally a second one with
SSL), a single server, power-of-two-choices (random(2)) algorithm,
and no privileged directive.

4 years agoEXAMPLES: add a "basic-config-edge" example config
Willy Tarreau [Wed, 12 May 2021 15:42:49 +0000 (17:42 +0200)] 
EXAMPLES: add a "basic-config-edge" example config

This config uses TLS, HSTS, redirects, cache, compression, stats,
log to stderr, and simple load balancing in a simple and commented
config which could be used as a starter for many other ones,
especially in containers.

4 years agoBUG/MINOR: stats: fix lastchk metric that got accidently lost
Willy Tarreau [Wed, 12 May 2021 15:29:14 +0000 (17:29 +0200)] 
BUG/MINOR: stats: fix lastchk metric that got accidently lost

Commit d3a9a4992 ("MEDIUM: stats: allow to select one field in
`stats_fill_sv_stats`") left one occurrence of a direct assignment
of stats[] instead of placing it into the <metric> variable, and it
was on ST_F_CHECK_STATUS. This resulted in the field being overwritten
with an empty one immediately after being set in stats_fill_sv_stats()
and the field to appear empty on the stats page.

No backport is needed as this was only for 2.4.

4 years agoCLEANUP: stick-table: remove a leftover of an old keyword declaration
Willy Tarreau [Wed, 12 May 2021 15:49:10 +0000 (17:49 +0200)] 
CLEANUP: stick-table: remove a leftover of an old keyword declaration

There was a leftover of an antique declaration commented out that has
now been superseded by new ones, let's remove it.

4 years agoREGTESTS: stick-table: add src_conn_rate test
Amaury Denoyelle [Wed, 12 May 2021 08:51:22 +0000 (10:51 +0200)] 
REGTESTS: stick-table: add src_conn_rate test

Add a simple test which uses src_conn_rate stick table fetch. Limit the
connection rate to 3. The 4th connection should return a 403.

4 years agoBUG/MEDIUM: stick_table: fix crash when using tcp smp_fetch_src
Amaury Denoyelle [Wed, 12 May 2021 08:17:47 +0000 (10:17 +0200)] 
BUG/MEDIUM: stick_table: fix crash when using tcp smp_fetch_src

Since the introduction of bc_src, smp_fetch_src from tcp_sample inspect
the kw argument to choose between the frontend or the backend source
address. However, for the stick tables, the argument is left to NULL.
This causes a segfault.

Fix the crash by explicitely set the kw argument to "src" to retrieve
the source address of the frontend side.

This bug was introduced by the following commit :
  7d081f02a43651d781a3a30a51ae19abdceb5683
  MINOR: tcp_samples: Add samples to get src/dst info of the backend connection

It does not need a backport as it is integrated in the current 2.4-dev
branch.

To reproduce the crash, I used the following config :

frontend fe
bind :20080
http-request track-sc0 src table foo
http-request reject if { src_conn_rate(foo) gt 10 }
use_backend h1

backend foo
stick-table type ip size 200k expire 30s store conn_rate(60s)

backend h1
server nginx 127.0.0.1:30080 check

This should fix the github issue #1247.

4 years agoBUILD: makefile: add a few popular ARMv8 CPU targets
Willy Tarreau [Wed, 12 May 2021 07:47:30 +0000 (09:47 +0200)] 
BUILD: makefile: add a few popular ARMv8 CPU targets

This adds the following CPUs to the makefile:
  - armv81    : modern ARM cores (Cortex A55/A75/A76/A78/X1, Neoverse, Graviton2)
  - a72       : ARM Cortex-A72 or A73 (e.g. RPi4, Odroid N2, VIM3, AWS Graviton)
  - a53       : ARM Cortex-A53 or any of its successors in 64-bit mode (e.g. RPi3)
  - armv8-auto: both older and newer ARMv8 cores, with a minor runtime penalty

The reasons for these ones are:
  - a53 is the common denominator of all of its successors, and does
    support CRC32 which is used by the gzip compression, that the generic
    armv8-a does not ;

  - a72 supports the same features but is an out-of-order one that deserves
    better optimizations; it's found in a number of high-performance
    multi-core CPUs mainly oriented towards I/O and network processing
    (Armada 8040, NXP LX2160A, AWS Graviton), and more recently the
    Raspberry Pi 4. The A73 found in VIM3 and Odroid-N2 can use the same
    optimizations ;

  - armv81 is for generic ARMv8.1-A and above, automatically enables LSE
    atomics which are way more scalable, and CRC32. This one covers modern
    ARMv8 cores such as Cortex A55/A75/A76/A77/A78/X1 and the Neoverse
    family such as found in AWS's Graviton2. The LSE instructions are
    essential for large numbers of cores (8 and above).

  - armv8-auto dynamically enables support for LSE extensions when
    detected while still being compatible with older cores. There is a
    small performance penalty in doing this (~3%) but a same executable
    will perform optimally on a wider range of hardware. This should be
    the best option for distros. It requires gcc-10 or gcc-9.4 and above.

When no CPU is specified, GCC version 10.2 and above will automatically
implement the wrapper used to detect the LSE extensions.

4 years agoBUILD/MINOR: opentracing: fixed compilation with filter enabled
Miroslav Zagorac [Tue, 11 May 2021 17:21:54 +0000 (19:21 +0200)] 
BUILD/MINOR: opentracing: fixed compilation with filter enabled

The inclusion of header files proxy.h and tools.h was added to the
addons/ot/include/include.h file.  Without this HAProxy cannot be
compiled if the OpenTracing filter is to be used.

4 years agoIMPORT: slz: do not produce the crc32_fast table when CRC is natively supported
Willy Tarreau [Wed, 12 May 2021 06:36:09 +0000 (08:36 +0200)] 
IMPORT: slz: do not produce the crc32_fast table when CRC is natively supported

On ARM with native CRC support, no need to inflate the executable with
a 4kB CRC table, let's just drop it.

This is slz upstream commit d8715db20b2968d1f3012a734021c0978758f911.

4 years agoIMPORT: slz: use the generic function for the last bytes of the crc32
Willy Tarreau [Wed, 12 May 2021 06:34:36 +0000 (08:34 +0200)] 
IMPORT: slz: use the generic function for the last bytes of the crc32

This is the only place where we conditionally use the crc32_fast table,
better call the crc32_char inline function for this. This should also
reduce by ~1kB the L1 cache footprint of the compression when dealing
with small blocks, and at least shows a consistent 0.5% perf improvement.

This is slz upstream commit 075351b6c2513b548bac37d6582e46855bc7b36f.

4 years agoMINOR: uri_normalizer: Add `fragment-encode` normalizer
Tim Duesterhus [Mon, 10 May 2021 15:28:26 +0000 (17:28 +0200)] 
MINOR: uri_normalizer: Add `fragment-encode` normalizer

This normalizer encodes '#' as '%23'.

See GitHub Issue #714.

4 years agoMINOR: uri_normalizer: Add `fragment-strip` normalizer
Tim Duesterhus [Mon, 10 May 2021 15:28:25 +0000 (17:28 +0200)] 
MINOR: uri_normalizer: Add `fragment-strip` normalizer

This normalizer strips the URI's fragment component which should never be sent
to the server.

See GitHub Issue #714.

4 years agoBUG/MINOR: http_act: Fix normalizer names in error messages
Tim Duesterhus [Mon, 10 May 2021 21:21:20 +0000 (23:21 +0200)] 
BUG/MINOR: http_act: Fix normalizer names in error messages

These places were forgotten when the normalizers were renamed.

Bug introduced in 5be6ab269e5606aef954f39d6717b024f97b3789, which is 2.4.
No backport needed.

4 years agoCLEANUP: pattern: remove the unused and dangerous pat_ref_reload()
Willy Tarreau [Tue, 11 May 2021 14:49:55 +0000 (16:49 +0200)] 
CLEANUP: pattern: remove the unused and dangerous pat_ref_reload()

This function was not used anymore after the atomic updates were
implemented in 2.3, and it must not be used given that it does not
yield and can easily make the process hang for tens of seconds on
large acls/maps. Let's remove it before someone uses it as an
example to implement something else!

4 years agoMINOR: memprof: also report the totals and delta alloc-free
Willy Tarreau [Tue, 11 May 2021 12:06:24 +0000 (14:06 +0200)] 
MINOR: memprof: also report the totals and delta alloc-free

Already had to perform too many additions by external scripts, it's
time to add the totals and delay alloc-free as a last line in the
output of the "show memory profiling".

4 years agoMINOR: memprof: also report the method used by each call
Willy Tarreau [Tue, 11 May 2021 07:26:23 +0000 (09:26 +0200)] 
MINOR: memprof: also report the method used by each call

This was planned but missing in the previous attempt, we really need to
see what is used at each place, especially due to realloc(). Now we
print the function used in front of the caller's address, as well as
the average alloc/free size per call.

4 years agoBUG/MINOR: memprof: properly account for differences for realloc()
Willy Tarreau [Tue, 11 May 2021 07:12:56 +0000 (09:12 +0200)] 
BUG/MINOR: memprof: properly account for differences for realloc()

The realloc() function checks if the size grew or reduced in order to
count an allocation or a free, but it does so with the absolute (new
or old) value instead of the difference, resulting in realloc() often
being credited for allocating too much.

No backport is needed.

4 years agoCLEANUP: assorted typo fixes in the code and comments
Ilya Shipitsin [Mon, 10 May 2021 07:50:00 +0000 (12:50 +0500)] 
CLEANUP: assorted typo fixes in the code and comments

This is 23rd iteration of typo fixes

4 years agoCI: extend spellchecker whitelist, add "ists" as well
Ilya Shipitsin [Mon, 10 May 2021 07:45:18 +0000 (12:45 +0500)] 
CI: extend spellchecker whitelist, add "ists" as well

codespell does not handle plurals, we already whitelusted "ist", let us
whitelist "ists" as well

4 years agoCI: Build VTest with clang
Tim Duesterhus [Mon, 10 May 2021 20:54:31 +0000 (22:54 +0200)] 
CI: Build VTest with clang

Current VTest master fails to build using gcc, see vtest/VTest#27.

This patch is to be reverted once VTest is fixed.

4 years agoCLEANUP: cli/activity: Remove double spacing in set profiling command
Daniel Corbett [Mon, 10 May 2021 18:08:40 +0000 (14:08 -0400)] 
CLEANUP: cli/activity: Remove double spacing in set profiling command

It was found that when viewing the help output from the CLI that
"set profiling" had 2 spaces in it, which was pushing it out from
the rest of similar commands.

i.e. it looked like this:
  prepare acl <acl>
  prepare map <acl>
  set  profiling  <what>  {auto|on|off}
  set dynamic-cookie-key backend <bk> <k>
  set map <map> [<key>|#<ref>] <value>
  set maxconn frontend <frontend> <value>

This patch removes all of the double spaces within the command and
unifies them to single spacing, which is what is observed within the
rest of the commands.

4 years agoBUG/MINOR: http_fetch: fix possible uninit sockaddr in fetch_url_ip/port
Amaury Denoyelle [Mon, 10 May 2021 09:23:34 +0000 (11:23 +0200)] 
BUG/MINOR: http_fetch: fix possible uninit sockaddr in fetch_url_ip/port

Check the return value of url2sa in smp_fetch_url_ip/port. If negative,
the address result is uninitialized and the sample fetch is aborted.
Also, the sockaddr is prelimiary zero'ed before calling url2sa to ensure
that it is not used by upper functions even if the sample returns 0.

Without the check, the value returned by the url_ip/url_port fetches is
unspecified. This can be triggered with the following curl :
$ curl -iv --request-target "xxx://127.0.0.1:20080/" http://127.0.0.1:20080/

This should be backported to all stable branches. However, note that
between the 1.8 and 2.0, the targetted functions have been extracted
from proto_http.c to http_fetch.c.

This should fix in part coverity report from the github issue #1244.

4 years ago[RELEASE] Released version 2.4-dev19 v2.4-dev19
Willy Tarreau [Mon, 10 May 2021 05:50:26 +0000 (07:50 +0200)] 
[RELEASE] Released version 2.4-dev19

Released version 2.4-dev19 with the following main changes :
    - BUG/MINOR: hlua: Don't rely on top of the stack when using Lua buffers
    - BUG/MEDIUM: cli: prevent memory leak on write errors
    - BUG/MINOR: ssl/cli: fix a lock leak when no memory available
    - MINOR: debug: add a new "debug dev sym" command in expert mode
    - MINOR: pools/debug: slightly relax DEBUG_DONT_SHARE_POOLS
    - CI: Github Actions: switch to LibreSSL-3.3.3
    - MINOR: srv: close all idle connections on shutdown
    - MINOR: connection: move session_list member in a union
    - MEDIUM: mux_h1: release idling frontend conns on soft-stop
    - MEDIUM: connection: close front idling connection on soft-stop
    - MINOR: tools: add functions to retrieve the address of a symbol
    - CLEANUP: activity: mark the profiling and task_profiling_mask __read_mostly
    - MINOR: activity: add a "memory" entry to "profiling"
    - MINOR: activity: declare the storage for memory usage statistics
    - MEDIUM: activity: collect memory allocator statistics with USE_MEMORY_PROFILING
    - MINOR: activity: clean up the show profiling io_handler a little bit
    - MINOR: activity: make "show profiling" support a few arguments
    - MINOR: activity: make "show profiling" also dump the memoery usage
    - MINOR: activity: add the profiling.memory global setting
    - BUILD: makefile: add new option USE_MEMORY_PROFILING
    - MINOR: channel: Rely on HTX version if appropriate in channel_may_recv()
    - BUG/MINOR: stream-int: Don't block reads in si_update_rx() if chn may receive
    - MINOR: conn-stream: Force mux to wait for read events if abortonclose is set
    - MEDIUM: mux-h1: Don't block reads when waiting for the other side
    - BUG/MEDIUM: mux-h1: Properly report client close if abortonclose option is set
    - REGTESTS: Add script to test abortonclose option
    - MINOR: mux-h1: clean up conditions to enabled and disabled splicing
    - MINOR: mux-h1: Subscribe for sends if output buffer is not empty in h1_snd_pipe
    - MINOR: mux-h1: Always subscribe for reads when splicing is disabled
    - MEDIUM: mux-h1: Wake H1 stream when both sides a synchronized
    - CLEANUP: mux-h1: rename WAIT_INPUT/WAIT_OUTPUT flags
    - MINOR: mux-h1: Manage processing blocking flags on the H1 stream
    - BUG/MINOR: stream: Decrement server current session counter on L7 retry
    - BUG/MINOR: config: fix uninitialized initial state in ".if" block evaluator
    - BUG/MINOR: config: add a missing "ELIF_TAKE" test for ".elif" condition evaluator
    - BUG/MINOR: config: .if/.elif should also accept negative integers
    - MINOR: config: centralize the ".if"/".elif" condition parser and evaluator
    - MINOR: config: keep up-to-date current file/line/section in the global struct
    - MINOR: config: support some pseudo-variables for file/line/section
    - BUILD: activity: do not include malloc.h
    - MINOR: arg: improve the error message on missing closing parenthesis
    - MINOR: global: export the build features string list
    - MINOR: global: add version comparison functions
    - MINOR: config: improve .if condition error reporting
    - MINOR: config: make cfg_eval_condition() support predicates with arguments
    - MINOR: config: add predicate "defined()" to conditional expression blocks
    - MINOR: config: add predicates "streq()" and "strneq()" to conditional expressions
    - MINOR: config: add predicate "feature" to detect certain built-in features
    - MINOR: config: add predicates "version_atleast" and "version_before" to cond blocks
    - BUG/MINOR: activity: use the new pointer to calculate the new size in realloc()
    - BUG/MINOR: stream: properly clear the previous error mask on L7 retries
    - MEDIUM: log: slightly refine the output format of alerts/warnings/etc
    - MINOR: config: add a new message directive: .diag
    - CLEANUP: cli/tree-wide: properly re-align the CLI commands' help messages
    - BUG/MINOR: stream: Reset stream final state and si error type on L7 retry
    - BUG/MINOR: checks: Handle synchronous connect when a tcpcheck is started
    - BUG/MINOR: checks: Reschedule check on observe mode only if fastinter is set
    - MINOR: global: define tainted flag
    - MINOR: cfgparse: add a new field flags in cfg_keyword
    - MINOR: cfgparse: implement experimental config keywords
    - MINOR: action: replace match_pfx by a keyword flags field
    - MINOR: action: implement experimental actions
    - MINOR: cli: set tainted when using CLI expert/experimental mode
    - MINOR: stats: report tainted on show info
    - MINOR: http_act: mark normalize-uri as experimental
    - BUILD: fix usage of ha_alert without format string
    - MINOR: proxy: define PR_CAP_LB
    - BUG/MINOR: server: do not report diag for peer servers with null weight
    - DOC: ssl: Extra files loading now works for backends too
    - ADDONS: make addons/ discoverable by git via .gitignore
    - DOC: ssl: Add information about crl-file option
    - MINOR: sample: improve error reporting on missing arg to strcmp() converter
    - DOC: management: mention that some fields may be emitted as floats
    - MINOR: tools: implement trimming of floating point numbers
    - MINOR: tools: add a float-to-ascii conversion function
    - MINOR: freq_ctr: add new functions to report float measurements
    - MINOR: stats: avoid excessive padding of float values with trailing zeroes
    - MINOR: stats: add the HTML conversion for float types
    - MINOR: stats: pass the appctx flags to stats_fill_info()
    - MINOR: stats: support an optional "float" option to "show info"
    - MINOR: stats: use tv_remain() to precisely compute the uptime
    - MINOR: stats: report uptime and start time as floats with subsecond resolution
    - MINOR: stats: make "show info" able to report rates as floats when asked
    - MINOR: config: mark tune.fd.edge-triggered as experimental
    - REORG: vars: move the "proc" scope variables out of the global struct
    - REORG: threads: move all_thread_mask() to thread.h
    - BUILD: wdt: include signal-t.h
    - BUILD: auth: include missing list.h
    - REORG: mworker: move proc_self from global to mworker
    - BUILD: ssl: ssl_utils requires chunk.h
    - BUILD: config: cfgparse-ssl.c needs tools.h
    - BUILD: wurfl: wurfl.c needs tools.h
    - BUILD: spoe: flt_spoe.c needs tools.h
    - BUILD: promex: service-prometheus.c needs tools.h
    - BUILD: resolvers: include tools.h
    - BUILD: config: include tools.h in cfgparse-listen.c
    - BUILD: htx: include tools.h in http_htx.c
    - BUILD: proxy: include tools.h in proxy.c
    - BUILD: session: include tools.h in session.c
    - BUILD: cache: include tools.h in cache.c
    - BUILD: sink: include tools.h in sink.c
    - BUILD: connection: include tools.h in connection.c
    - BUILD: server-state: include tools.h from server_state.c
    - BUILD: dns: include tools.h in dns.c
    - BUILD: payload: include tools.h in payload.c
    - BUILD: vars: include tools.h in vars.c
    - BUILD: compression: include tools.h in compression.c
    - BUILD: mworker: include tools.h from mworker.c
    - BUILD: queue: include tools.h from queue.c
    - BUILD: udp: include tools.h from proto_udp.c
    - BUILD: stick-table: include freq_ctr.h from stick_table.h
    - BUILD: server: include tools.h from server.c
    - BUILD: server: include missing proxy.h in server.c
    - BUILD: sink: include proxy.h in sink.c
    - BUILD: mworker: include proxy.h in mworker.c
    - BUILD: filters: include proxy.h in filters.c
    - BUILD: fcgi-app: include proxy.h in fcgi-app.c
    - BUILD: connection: move list_mux_proto() to connection.c
    - REORG: stick-table: uninline stktable_alloc_data_type()
    - REORG: stick-table: move composite address functions to stick_table.h
    - REORG: config: uninline warnifnotcap() and failifnotcap()
    - BUILD: task: remove unused includes from task.c
    - MINOR: task: stop including stream.h from task.c
    - BUILD: connection: stop including listener-t.h
    - BUILD: hlua: include proxy.h from hlua.c
    - BUILD: mux-h1: include proxy.h from mux-h1.c
    - BUILD: mux-fcgi: include proxy.h from mux-fcgi.c
    - BUILD: listener: include proxy.h from listener.c
    - BUILD: http-rules: include proxy.h from http_rules.c
    - BUILD: thread: include log.h from thread.c
    - BUILD: comp: include proxy.h from flt_http_comp.c
    - BUILD: fd: include log.h from fd.c
    - BUILD: config: do not include proxy.h nor errors.h anymore in cfgparse.h
    - BUILD: makefile: reorder object files by build time
    - DOC: Fix a few grammar/spelling issues and casing of HAProxy
    - REGTESTS: run-regtests: match both "HAProxy" and "HA-Proxy" in the version
    - MINOR: version: report "HAProxy" not "HA-Proxy" in the version output
    - DOC: remove last occurrences of "HA-Proxy" syntax
    - DOC: peers: fix the protocol tag name in the doc
    - ADMIN: netsnmp: report "HAProxy" and not "Haproxy" in output descriptions
    - MEDIUM: mailers: use "HAProxy" nor "HAproxy" in the subject of messages
    - DOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments
    - MINOR: tools/rnd: compute the result outside of the CAS loop
    - BUILD: http_fetch: address a few aliasing warnings with older compilers
    - BUILD: ssl: define HAVE_CRYPTO_memcmp() based on the library version
    - BUILD: errors: include stdarg in errors.h
    - REGTESTS: disable inter-thread idle connection sharing on sensitive tests
    - MINOR: cli: make "help" support a command in argument
    - MINOR: cli: sort the output of the "help" keywords
    - CLEANUP: cli/mworker: properly align the help messages
    - BUILD: memprof: make the old caller pointer a const in get_prof_bin()
    - BUILD: compat: include malloc_np.h for USE_MEMORY_PROFILING on FreeBSD
    - CI: Github Actions: enable USE_QUIC=1 for BoringSSL builds
    - BUG/MEDIUM: quic: fix null deref on error path in qc_conn_init()
    - BUILD: cli: appease a null-deref warning in cli_gen_usage_msg()

4 years agoBUILD: cli: appease a null-deref warning in cli_gen_usage_msg()
Willy Tarreau [Mon, 10 May 2021 05:47:05 +0000 (07:47 +0200)] 
BUILD: cli: appease a null-deref warning in cli_gen_usage_msg()

The compiler sees the possibility of null-deref for which a path is
possible but which doesn't exist as we didn't pass a null args outside
of the help request. The test was introduced by the simplified test on
ishelp variable, so let's add it to shut the warning.

4 years agoBUG/MEDIUM: quic: fix null deref on error path in qc_conn_init()
Willy Tarreau [Mon, 10 May 2021 05:40:27 +0000 (07:40 +0200)] 
BUG/MEDIUM: quic: fix null deref on error path in qc_conn_init()

When ctx is NULL, we go to the "err" label, which could dereference it.
No backport is needed.

4 years agoCI: Github Actions: enable USE_QUIC=1 for BoringSSL builds
Ilya Shipitsin [Sun, 9 May 2021 16:27:28 +0000 (21:27 +0500)] 
CI: Github Actions: enable USE_QUIC=1 for BoringSSL builds

if haproxy is built against BoringSSL, let us add USE_QUIC=1 dynamically

4 years agoBUILD: compat: include malloc_np.h for USE_MEMORY_PROFILING on FreeBSD
Willy Tarreau [Sun, 9 May 2021 21:46:45 +0000 (23:46 +0200)] 
BUILD: compat: include malloc_np.h for USE_MEMORY_PROFILING on FreeBSD

This include is needed for malloc_usable_size(). It's also important to
think about disabling global pools.

4 years agoBUILD: memprof: make the old caller pointer a const in get_prof_bin()
Willy Tarreau [Sun, 9 May 2021 21:18:50 +0000 (23:18 +0200)] 
BUILD: memprof: make the old caller pointer a const in get_prof_bin()

It's a const void* in the target, we can't use a void* in the caller,
this causes a build warning with clang.

4 years agoCLEANUP: cli/mworker: properly align the help messages
Willy Tarreau [Sun, 9 May 2021 20:49:44 +0000 (22:49 +0200)] 
CLEANUP: cli/mworker: properly align the help messages

CLI help commands were re-aligned by commit b205bfdab but the
master-worker ones were not done, let's do it now.

4 years agoMINOR: cli: sort the output of the "help" keywords
Willy Tarreau [Sun, 9 May 2021 19:45:29 +0000 (21:45 +0200)] 
MINOR: cli: sort the output of the "help" keywords

It's still very difficult to find all commands starting with a given
keyword like "set", "show" etc. Let's sort the lines by usage message,
this is much more convenient.

4 years agoMINOR: cli: make "help" support a command in argument
Willy Tarreau [Sun, 9 May 2021 18:59:23 +0000 (20:59 +0200)] 
MINOR: cli: make "help" support a command in argument

With ~100 commands on the CLI, it's particularly difficult to find a
specific one in the "help" output. The function used to display the
help already supports filtering on certain commands, so in the end it's
just needed to pass the argument of the help command to enable the
automatic filtering. That's what this patch does so that "help clear"
only lists commands starting with "clear" and that "help map" lists
commands containing "map" in them.

4 years agoREGTESTS: disable inter-thread idle connection sharing on sensitive tests
Willy Tarreau [Sun, 9 May 2021 12:41:41 +0000 (14:41 +0200)] 
REGTESTS: disable inter-thread idle connection sharing on sensitive tests

Some regtests involve multiple requests from multiple clients, which can
be dispatched as multiple requests to a server. It turns out that the
idle connection sharing works so well that very quickly few connections
are used, and regularly some of the remaining idle server connections
time out at the moment they were going to be reused, causing those random
"HTTP header incomplete" traces in the logs that make them fail often. In
the end this is only an artefact of the test environment.

And indeed, some tests like normalize-uri which perform a lot of reuse
fail very often, about 20-30% of the times in the CI, and 100% of the
time in local when running 1000 tests in a row. Others like ubase64,
sample_fetches or vary_* fail less often but still a lot in tests.

This patch addresses this by adding "tune.idle-pool.shared off" to all
tests which have at least twice as many requests as clients. It proves
very effective as no single error happens on normalize-uri anymore after
10000 tests. Also 100 full runs of all tests yield no error anymore.

One test is tricky, http_abortonclose, it used to fail ~10 times per
1000 runs and with this workaround still fails once every 1000 runs.
But the test is complex and there's a warning in it mentioning a
possible issue when run in parallel due to a port reuse.