]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
4 years agoMINOR: http-ana: Use -1 status for client aborts during queuing and connect
Christopher Faulet [Wed, 2 Jun 2021 12:07:24 +0000 (14:07 +0200)] 
MINOR: http-ana: Use -1 status for client aborts during queuing and connect

When a client aborts while the session is in the queue or during the connect
stage, instead of reporting a 503-Service-Unavailable error in logs, -1
status is used. It means -1 status is now reported with 'CC' and 'CQ'
termination state.

Indeed, when a client aborts before the server connection is established,
there is no reason to report a 503 because nothing is sent to the
server. And in this case, because it is a client abort, it is useless to
send any response to the client. Thus -1 status is approriate. This status
is used in log messages when the connection is closed and no response is
sent.

This patch should fix the issue #1266.

4 years agoBUILD: fix compilation for OpenSSL-3.0.0-alpha17
William Lallemand [Wed, 2 Jun 2021 14:09:11 +0000 (16:09 +0200)] 
BUILD: fix compilation for OpenSSL-3.0.0-alpha17

Some changes in the OpenSSL syntax API broke this syntax:
  #if SSL_OP_NO_TLSv1_3

OpenSSL made this change which broke our usage in commit f04bb0bce490de847ed0482b8ec9eabedd173852:

-# define SSL_OP_NO_TLSv1_3                               (uint64_t)0x20000000
+#define SSL_OP_BIT(n)  ((uint64_t)1 << (uint64_t)n)
+# define SSL_OP_NO_TLSv1_3                               SSL_OP_BIT(29)

Which can't be evaluated by the preprocessor anymore.
This patch replace the test by an openssl version test.

This fix part of #1276 issue.

4 years agoCLEANUP: mux-fcgi: Don't needlessly store result of data/trailers parsing
Christopher Faulet [Wed, 2 Jun 2021 10:04:40 +0000 (12:04 +0200)] 
CLEANUP: mux-fcgi: Don't needlessly store result of data/trailers parsing

Return values of fcgi_strm_parse_data() and fcgi_strm_parse_trailers() are
no longer checked. Thus it is useless to store it.

This patch should fix the issues #1269 and #1268.

4 years agoDOC/MINOR: move uuid in the configuration to the right alphabetical order
Alexandar Lazic [Mon, 31 May 2021 22:27:01 +0000 (00:27 +0200)] 
DOC/MINOR: move uuid in the configuration to the right alphabetical order

This patch can be backported up to 2.1 where the uuid fetch was
introduced

4 years agoBUG/MINOR: vars: Be sure to have a session to get checks variables
Christopher Faulet [Wed, 2 Jun 2021 09:48:42 +0000 (11:48 +0200)] 
BUG/MINOR: vars: Be sure to have a session to get checks variables

It is now possible to get any variables from the cli. Concretely, only
variables in the PROC scope can be retrieved because there is neither stream
nor session defined. But, nothing forbids anyone to try to get a variable in
any scope. No value will be found, but it is allowed. Thus, we must be sure
to not rely on an undefined session or stream in that case. Especially, the
session must be tested before retrieving variables in CHECK scope.

This patch should fix the issue #1249. It must be backported to 2.4.

4 years agoMINOR: backend: Don't release SI endpoint anymore in connect_server()
Christopher Faulet [Tue, 1 Jun 2021 13:54:49 +0000 (15:54 +0200)] 
MINOR: backend: Don't release SI endpoint anymore in connect_server()

Thanks to the previous patch (822decfd "BUG/MAJOR: stream-int: Release SI
endpoint on server side ASAP on retry"), it is now useless to release any
existing connection in connect_server() because it was already done in
back_handle_st_cer() if necessary.

This patch is not a CLEANUP because it may introduce some bugs in edge
cases. There is no reason to backport it for now except if it is required to
fix a bug.

4 years agoBUG/MAJOR: stream-int: Release SI endpoint on server side ASAP on retry
Christopher Faulet [Tue, 1 Jun 2021 12:06:05 +0000 (14:06 +0200)] 
BUG/MAJOR: stream-int: Release SI endpoint on server side ASAP on retry

When a connection attempt failed, if a retry is possible, the SI endpoint on
the server side is immediately released, instead of waiting to establish a
new connection to a server. Thus, when the backend SI is switched from
SI_ST_CER state to SI_ST_REQ, SI_ST_ASS or SI_ST_TAR, its endpoint is
released. It is expected because the SI is moved to a state prior to the
connection stage ( < SI_ST_CONN). So it seems logical to not have any server
connection.

It is especially important if the retry is delayed (SI_ST_TAR or
SI_ST_QUE). Because, if the server connection is preserved, any error at the
connection level is unexpectedly relayed to the stream, via the
stream-interface, leading to an infinite loop in process_stream(). if
SI_FL_ERR flag is set on the backend SI in another state than SI_ST_CLO, an
internal goto is performed to resync the stream-interfaces. In addtition,
some ressources are not released ASAP.

This bug is quite old and was reported 1 or 2 times per years since the 2.2
(at least) with not enough information to catch it. It must be backported as
far as 2.2 with a special care because this part has moved several times and
after some observation period and feedback from users to be sure. For info,
in 2.0 and prior, the connection is released when an error is encountered in
SI_ST_CON or SI_ST_RDY states.

4 years agoCLEANUP: http-ana: Remove useless if statement about L7 retries
Christopher Faulet [Mon, 31 May 2021 09:45:24 +0000 (11:45 +0200)] 
CLEANUP: http-ana: Remove useless if statement about L7 retries

Thanks to the commit 1f08bffe0 ("MINOR: http-ana: Perform L7 retries because
of status codes in response analyser"), the L7 retries about the response
status code is now fully handled in the HTTP response analyser.
CF_READ_ERROR flag is no longer set on the response channel in this
case. Thus it is useless to try to catch L7 retries when CF_READ_ERROR is
set because it cannot happen.

The above commit was backported to 2.4, thus this one should also be
backported.

4 years agoBUG/MINOR: proxy: Missing calloc return value check in chash_init_server_tree
Remi Tricot-Le Breton [Wed, 19 May 2021 14:40:28 +0000 (16:40 +0200)] 
BUG/MINOR: proxy: Missing calloc return value check in chash_init_server_tree

A memory allocation failure happening in chash_init_server_tree while
trying to allocate a server's lb_nodes item used in consistent hashing
would have resulted in a crash. This function is only called during
configuration parsing.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: http: Missing calloc return value check in make_arg_list
Remi Tricot-Le Breton [Wed, 19 May 2021 10:00:54 +0000 (12:00 +0200)] 
BUG/MINOR: http: Missing calloc return value check in make_arg_list

A memory allocation failure happening in make_arg_list when trying to
allocate the argument list would have resulted in a crash. This function
is only called during configuration parsing.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: http: Missing calloc return value check while parsing redirect rule
Remi Tricot-Le Breton [Wed, 19 May 2021 09:32:04 +0000 (11:32 +0200)] 
BUG/MINOR: http: Missing calloc return value check while parsing redirect rule

A memory allocation failure happening in http_parse_redirect_rule when
trying to allocate a redirect_rule structure would have resulted in a
crash. This function is only called during configuration parsing.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: worker: Missing calloc return value check in mworker_env_to_proc_list
Remi Tricot-Le Breton [Wed, 19 May 2021 08:45:12 +0000 (10:45 +0200)] 
BUG/MINOR: worker: Missing calloc return value check in mworker_env_to_proc_list

A memory allocation failure happening in mworker_env_to_proc_list when
trying to allocate a mworker_proc would have resulted in a crash. This
function is only called during init.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: compression: Missing calloc return value check in comp_append_type/algo
Remi Tricot-Le Breton [Mon, 17 May 2021 08:35:08 +0000 (10:35 +0200)] 
BUG/MINOR: compression: Missing calloc return value check in comp_append_type/algo

A memory allocation failure happening in comp_append_type or
comp_append_algo called while parsing compression options would have
resulted in a crash. These functions are only called during
configuration parsing.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: http: Missing calloc return value check while parsing tcp-request rule
Remi Tricot-Le Breton [Mon, 17 May 2021 08:08:16 +0000 (10:08 +0200)] 
BUG/MINOR: http: Missing calloc return value check while parsing tcp-request rule

A memory allocation failure happening in tcp_parse_request_rule while
processing the "capture" keyword and trying to allocate a cap_hdr
structure would have resulted in a crash. This function is only called
during configuration parsing.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: http: Missing calloc return value check while parsing tcp-request/tcp...
Remi Tricot-Le Breton [Wed, 12 May 2021 16:24:18 +0000 (18:24 +0200)] 
BUG/MINOR: http: Missing calloc return value check while parsing tcp-request/tcp-response

A memory allocation failure happening in tcp_parse_tcp_req or
tcp_parse_tcp_rep when trying to allocate an act_rule structure would
have resulted in a crash. These functions are only called during
configuration parsing.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: proxy: Missing calloc return value check in proxy_defproxy_cpy
Remi Tricot-Le Breton [Wed, 12 May 2021 16:07:27 +0000 (18:07 +0200)] 
BUG/MINOR: proxy: Missing calloc return value check in proxy_defproxy_cpy

A memory allocation failure happening in proxy_defproxy_cpy while
copying the default compression options would have resulted in a crash.
This function is called for every new proxy found while parsing the
configuration.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: proxy: Missing calloc return value check in proxy_parse_declare
Remi Tricot-Le Breton [Wed, 12 May 2021 16:04:46 +0000 (18:04 +0200)] 
BUG/MINOR: proxy: Missing calloc return value check in proxy_parse_declare

A memory allocation failure happening during proxy_parse_declare while
processing the "capture" keyword and allocating a cap_hdr structure
would have resulted in a crash. This function is only called during
configuration parsing.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: http: Missing calloc return value check in parse_http_req_capture
Remi Tricot-Le Breton [Wed, 12 May 2021 15:54:17 +0000 (17:54 +0200)] 
BUG/MINOR: http: Missing calloc return value check in parse_http_req_capture

A memory allocation failure happening in parse_http_req_capture while
processing a "len" keyword and allocating a cap_hdr structure would
have resulted in a crash. This function is only called during
configuration parsing.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: ssl: Missing calloc return value check in ssl_init_single_engine
Remi Tricot-Le Breton [Wed, 12 May 2021 15:45:21 +0000 (17:45 +0200)] 
BUG/MINOR: ssl: Missing calloc return value check in ssl_init_single_engine

A memory allocation failure happening during ssl_init_single_engine
would have resulted in a crash. This function is only called during
init.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: peers: Missing calloc return value check in peers_register_table
Remi Tricot-Le Breton [Wed, 12 May 2021 15:39:04 +0000 (17:39 +0200)] 
BUG/MINOR: peers: Missing calloc return value check in peers_register_table

A memory allocation failure happening during peers_register_table would
have resulted in a crash. This function is only called during init.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.

4 years agoBUG/MINOR: server: Missing calloc return value check in srv_parse_source
Remi Tricot-Le Breton [Wed, 12 May 2021 07:44:06 +0000 (09:44 +0200)] 
BUG/MINOR: server: Missing calloc return value check in srv_parse_source

Two calloc calls were not checked in the srv_parse_source function.
Considering that this function could be called at runtime through a
dynamic server creation via the CLI, this could lead to an unfortunate
crash.

It was raised in GitHub issue #1233.
It could be backported to all stable branches even though the runtime
crash could only happen on branches where dynamic server creation is
possible.

4 years agoDOC: intro: Fix typo in starter guide
Mark Mullan [Sat, 22 May 2021 18:15:02 +0000 (11:15 -0700)] 
DOC: intro: Fix typo in starter guide

s/sned/send.

4 years agoMINOR: cfgparse: Fail when encountering extra arguments in macro
Tim Duesterhus [Wed, 26 May 2021 15:45:33 +0000 (17:45 +0200)] 
MINOR: cfgparse: Fail when encountering extra arguments in macro

This resolves GitHub issue #1124.

This change should be backported as a *warning* to 2.4.

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.