]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
4 years agoMEDIUM: config: simplify cpu-map handling
Willy Tarreau [Tue, 15 Jun 2021 06:49:05 +0000 (08:49 +0200)] 
MEDIUM: config: simplify cpu-map handling

As there's no more nbproc>1, we can remove some loops and tests in cpu-map.
Both the lack of thread number and thread 1 can count as the whole process
now (which is still used for whole process binding when threads are disabled).

4 years agoMEDIUM: global: remove dead code from nbproc/bind_proc removal
Willy Tarreau [Tue, 15 Jun 2021 06:36:30 +0000 (08:36 +0200)] 
MEDIUM: global: remove dead code from nbproc/bind_proc removal

Lots of places iterating over nbproc or comparing with nbproc could be
simplified. Further, "bind-process" and "process" parsing that was
already limited to process 1 or "all" or "odd" resulted in a bind_proc
field that was either 0 or 1 during the init phase and later always 1.

All the checks for compatibilities were removed since it's not possible
anymore to run a frontend and a backend on different processes or to
have peers and stick-tables bound on different ones. This is the largest
part of this patch.

The bind_proc field was removed from both the proxy and the receiver
structs.

Since the "process" and "bind-process" directives are still parsed,
configs making use of correct values allowing process 1 will continue
to work.

4 years agoCLEANUP: global: remove pid_bit and all_proc_mask
Willy Tarreau [Tue, 15 Jun 2021 06:13:20 +0000 (08:13 +0200)] 
CLEANUP: global: remove pid_bit and all_proc_mask

They were already set to 1 and never changed. Let's remove them and
replace their references with 1.

4 years agoCLEANUP: global: remove the nbproc field from the global structure
Willy Tarreau [Tue, 15 Jun 2021 06:08:04 +0000 (08:08 +0200)] 
CLEANUP: global: remove the nbproc field from the global structure

Let's use 1 in the rare places where it was still referenced since it's
now its only possible value.

4 years agoMINOR: mworker: remove the initialization loop over processes
Willy Tarreau [Tue, 15 Jun 2021 06:02:06 +0000 (08:02 +0200)] 
MINOR: mworker: remove the initialization loop over processes

There was a loop used to prepare structures for all current processes.
Let's just assume there's a single iteration now.

4 years agoMEDIUM: init: remove the loop over processes during init
Willy Tarreau [Tue, 15 Jun 2021 05:58:09 +0000 (07:58 +0200)] 
MEDIUM: init: remove the loop over processes during init

There was a loop iterating over all nbproc values during init that
couldn't be immediately removed because the loop's index was used
to distinguish a child from a parent. That's now fixed by replacing
the iterator with an in_parent flag. All bindings that were checking
(1UL << proc) or cpu_map.proc[proc] were adjusted to always use zero
for proc.

4 years agoCLEANUP: global: remove unused definition of stopping_task[]
Willy Tarreau [Tue, 15 Jun 2021 09:39:57 +0000 (11:39 +0200)] 
CLEANUP: global: remove unused definition of stopping_task[]

This is a leftover of a previous attempt that was introduced in 2.4 by
commit d3a88c1c3 ("MEDIUM: connection: close front idling connection on
soft-stop"). It can be backported, as the variable doesn't exist.

4 years agoBUG/MINOR: mworker: fix typo in chroot error message
Willy Tarreau [Tue, 15 Jun 2021 06:59:19 +0000 (08:59 +0200)] 
BUG/MINOR: mworker: fix typo in chroot error message

Since its introduction in 1.8 with commit 095ba4c24 ("MEDIUM: mworker:
replace systemd mode by master worker mode"), it says "cannot chroot1(...)"
which seems to be a leftover of a debug message. It could be backported but
probably nobody will notice.

4 years agoBUG/MINOR: ssl: use atomic ops to update global shctx stats
Willy Tarreau [Tue, 15 Jun 2021 14:39:22 +0000 (16:39 +0200)] 
BUG/MINOR: ssl: use atomic ops to update global shctx stats

The global shctx lookups and misses was updated without using atomic
ops, so the stats available in "show info" are very likely off by a few
units over time. This should be backported as far as 1.8. Versions
without _HA_ATOMIC_INC() can use HA_ATOMIC_ADD(,1).

4 years agoBUG/MEDIUM: shctx: use at least thread-based locking on USE_PRIVATE_CACHE
Willy Tarreau [Tue, 15 Jun 2021 13:03:19 +0000 (15:03 +0200)] 
BUG/MEDIUM: shctx: use at least thread-based locking on USE_PRIVATE_CACHE

Since threads were introduced in 1.8, the USE_PRIVATE_CACHE mode of the
shctx was not updated to use locks. Originally it was meant to disable
sharing between processes, so it removes the lock/unlock instructions.
But with threads enabled, it's not possible to work like this anymore.

It's easy to see that once built with private cache and threads enabled,
sending violent SSL traffic to the the process instantly makes it die.
The HTTP cache is very likely affected as well.

This patch addresses this by falling back to our native spinlocks when
USE_PRIVATE_CACHE is used. In practice we could use them also for other
modes and remove all older implementations, but this patch aims at keeping
the changes very low and easy to backport. A new SHCTX_LOCK label was
added to help with debugging, but OTHER_LOCK might be usable as well
for backports.

An even lighter approach for backports may consist in always declaring
the lock (or reusing "waiters"), and calling pl_take_s() for the lock()
and pl_drop_s() for the unlock() operation. This could even be used in
all modes (process and threads), even when thread support is disabled.

Subsequent patches will further clean up this area.

This patch must be backported to all supported versions since 1.8.

4 years agoBUG/MEDIUM: server: do not auto insert a dynamic server in px addr_node
Amaury Denoyelle [Tue, 8 Jun 2021 13:19:51 +0000 (15:19 +0200)] 
BUG/MEDIUM: server: do not auto insert a dynamic server in px addr_node

Until then, the servers were automatically attached on their creation
into the proxy addr_node tree via _srv_parse_init. In case of an invalid
dynamic server which is instantly freed, no detach operation was made
leaving a NULL server in the tree.

Change this mode of operation by marking the attach operation as
optional in _srv_parse_init. This operation is not conduct for a dynamic
server. The server is attached only at the end of the CLI handler when
it is marked as valid.

This must be backported up to 2.4.

4 years agoBUG/MINOR: server: do not keep an invalid dynamic server in px ids tree
Amaury Denoyelle [Tue, 8 Jun 2021 15:00:20 +0000 (17:00 +0200)] 
BUG/MINOR: server: do not keep an invalid dynamic server in px ids tree

A bug is present when trying to create a dynamic server with a fixed id.
If the server is detected invalid due to a later parsing arguments
error, the server is not removed from the proxy used ids tree before
being freed.

Change the mode of operation of 'id' keyword parsing handler. The
insertion in the backend tree is removed from the handler and is not
taken in charge by parse_server for configuration parsing. For the
dynamic servers, the insertion is called at the end of the 'add server'
CLI handler when the server has been validated.

This must be backported up to 2.4.

4 years agoBUG/MEDIUM: server: do not forget to generate the dynamic servers ids
Amaury Denoyelle [Wed, 9 Jun 2021 07:58:47 +0000 (09:58 +0200)] 
BUG/MEDIUM: server: do not forget to generate the dynamic servers ids

If no id is specified by the user for a dynamic server, it is necessary
to generate a new one. This operation is now done at the end of 'add
server' CLI handler. The server is then inserted into the proxy ids
tree.

Without this, several features may be broken for dynamic servers. Among
them, there is the "first" lb algorithm, the persistence using
stick-tables or the uniqueness internal check of srv_parse_id.

This must be backported up to 2.4.

4 years agoBUG/MEDIUM: server: clear dynamic srv on delete from proxy id/name trees
Amaury Denoyelle [Wed, 9 Jun 2021 14:00:43 +0000 (16:00 +0200)] 
BUG/MEDIUM: server: clear dynamic srv on delete from proxy id/name trees

Do not leave deleted server in used_server_id/used_server_addr backend
trees. This might lead to crashes if a deleted server is used through
these trees.

At this moment, dynamic servers are only added in used_server_id if they
have a fixed id. They are never inserted in used_server_addr as this
code is missing. So these new delete instructions are noop. However, a
fix will be provided soon to insert properly all dynamic servers in both
used_server_id and used_server_addr trees so the deletion counterpart
will be mandatory in the CLI server delete handler.

This must be backported to 2.4.

4 years agoBUG/MEDIUM: server: extend thread-isolate over much of CLI 'add server'
Amaury Denoyelle [Thu, 10 Jun 2021 13:26:44 +0000 (15:26 +0200)] 
BUG/MEDIUM: server: extend thread-isolate over much of CLI 'add server'

Some config parsing handlers were designed to be run at startup on a
single-thread. When executing at runtime for dynamic servers,
thread-safety is not guaranteed. This is the case for example in
srv_parse_id which manipulates backend used_ids tree.

One solution could be to add locks but it might be tricky to found all
affected functions and it can be an easy source of deadlock. The other
solution which has been chosen is to use thread-isolation over almost
all of the cli_parse_add_server CLI handler.

For now this solution is sufficient. If some users make heavy use of the
'add server', hurting the overall performance, it will be necessary to
design a much thinner solution.

This must be backported up to 2.4.

4 years agoBUG/MINOR: stick-table: insert srv in used_name tree even with fixed id
Amaury Denoyelle [Mon, 14 Jun 2021 15:04:25 +0000 (17:04 +0200)] 
BUG/MINOR: stick-table: insert srv in used_name tree even with fixed id

If the server id is fixed in the configuration, it is immediately
inserted in the 'used_server_id' backend tree via srv_parse_id. On
check_config_validity, the dynamic id generation is thus skipped for
fixed-id servers. However, it must nevertheless be inserted in the
'used_server_name' backend tree.

This bug seems to be not noticeable for the user. Indeed, before the
fix, the search in sticking_rule_find_target always returned NULL for
the name, then the fallback search with server id succeeded, so the
persistence is properly applied. However with the fix the fallback
search is not executed anymore, which saves from the locking of
STK_SESS.

This should be backported up to 2.0.

4 years agoMINOR: ssl: Use OpenSSL's ASN1_TIME convertor when available
Remi Tricot-Le Breton [Fri, 11 Jun 2021 08:28:09 +0000 (10:28 +0200)] 
MINOR: ssl: Use OpenSSL's ASN1_TIME convertor when available

The ASN1_TIME_to_tm function was added in OpenSSL1.1.1 so with this
version of the library we do not need our homemade time convertor
anymore.

4 years agoDOC: lua: Add a warning about buffers modification in HTTP
Christopher Faulet [Mon, 14 Jun 2021 09:43:18 +0000 (11:43 +0200)] 
DOC: lua: Add a warning about buffers modification in HTTP

Since the 1.9, it is forbidden to alter the channel buffer from an HTTP
stream because there is no way to keep the HTTP parser synchronized if the
buffer content is altered. In addition, since the HTX is the only
reprensentation for HTTP messages, the data in HTTP buffers are structured
and cannot be read or updated in a raw fashion.

A warning is triggered when a user tries to alter an HTTP buffer. However,
it was not documented. This patch adds a warning in the lua documentation.

This patch is related to the issue #1287. It may be backported as far as
2.0.

4 years agoBUG/MAJOR: resolvers: segfault using server template without SRV RECORDs
Emeric Brun [Mon, 14 Jun 2021 08:02:18 +0000 (10:02 +0200)] 
BUG/MAJOR: resolvers: segfault using server template without SRV RECORDs

This patch fix the issue adding a test in srvrq before registering
the server on it during server template init.

This was a regression due to commit :
3406766d57fc11478d54a6fa2d048cbfe4524a4e

This should be backported with this previous commit (until 2.0)

4 years agoCI: github actions: enable alpine/musl builds
Ilya Shipitsin [Sat, 12 Jun 2021 10:46:29 +0000 (15:46 +0500)] 
CI: github actions: enable alpine/musl builds

on push builds are added. based on cirrus-ci patch sent by William Lallemand

4 years agoREGTESTS: Remove REQUIRE_VERSION=1.7 from all tests
Tim Duesterhus [Fri, 11 Jun 2021 16:16:25 +0000 (18:16 +0200)] 
REGTESTS: Remove REQUIRE_VERSION=1.7 from all tests

HAProxy 1.7 is the lowest supported version, thus this always matches.

4 years agoREGTESTS: Remove REQUIRE_VERSION=1.6 from all tests
Tim Duesterhus [Fri, 11 Jun 2021 16:16:24 +0000 (18:16 +0200)] 
REGTESTS: Remove REQUIRE_VERSION=1.6 from all tests

HAProxy 1.6 is EOL, thus this always matches.

4 years agoBUILD: log: remove unused fmt_directive()
Willy Tarreau [Fri, 11 Jun 2021 15:32:03 +0000 (17:32 +0200)] 
BUILD: log: remove unused fmt_directive()

fmt_directive() became unused after the removal of the deprecated
tags, and it emits a warning on some compilers. Let's drop it.

4 years agoBUILD: init: remove initialization of multi-process thread mappings
Willy Tarreau [Fri, 11 Jun 2021 15:28:19 +0000 (17:28 +0200)] 
BUILD: init: remove initialization of multi-process thread mappings

This broke the build with recent compilers and is not used anyway.

4 years agoMAJOR: config: remove parsing of the global "nbproc" directive
Willy Tarreau [Fri, 11 Jun 2021 14:50:29 +0000 (16:50 +0200)] 
MAJOR: config: remove parsing of the global "nbproc" directive

This one was deprecated in 2.3 and marked for removal in 2.5. It suffers
too many limitations compared to threads, and prevents some improvements
from being engaged. Instead of a bypassable startup error, there is now
a hard error.

The parsing code was removed, and very few obvious cases were as well.
The code is deeply rooted at certain places (e.g. "for" loops iterating
from 0 to nbproc) so it will not be that trivial to remove everywhere.
The "bind" and "bind-process" parsers will have to be adjusted, though
maybe not completely changed if we later want to support thread groups
for large NUMA machines. Some stats socket restrictions were removed,
and the doc was updated according to what was done. A few places in the
doc still refer to nbproc and will have to be revisited. The master-worker
code also refers to the process number to distinguish between master and
workers and will have to be carefully adjusted. The MAX_PROCS macro was
reset to 1, this will at least reduce the size of some remaining arrays.

Two regtests were dependieng on this directive, one with an explicit
"nbproc 1" and another one testing the master's CLI using nbproc 4.
Both were adapted.

4 years agoMEDIUM: proxy: remove the deprecated "grace" keyword
Willy Tarreau [Fri, 11 Jun 2021 14:27:10 +0000 (16:27 +0200)] 
MEDIUM: proxy: remove the deprecated "grace" keyword

Commit ab0a5192a ("MEDIUM: config: mark "grace" as deprecated") marked
the "grace" keyword as deprecated in 2.3, tentative removal for 2.4
with a hard deadline in 2.5, so let's remove it and return an error now.
This old and outdated feature was incompatible with soft-stop, reload
and socket transfers, and keeping it forced ugly hacks in the lower
layers of the protocol stack.

4 years agoMINOR: config: remove deprecated option "http-tunnel"
Willy Tarreau [Fri, 11 Jun 2021 14:06:29 +0000 (16:06 +0200)] 
MINOR: config: remove deprecated option "http-tunnel"

It was marked as deprecated in 2.1-dev2 and for removal in 2.2, but it
was missed. A warning was already emitted and the doc didn't refer to
it any more, let's now get rid of it.

4 years agoMINOR: config: reject long-deprecated "option forceclose"
Willy Tarreau [Fri, 11 Jun 2021 14:01:50 +0000 (16:01 +0200)] 
MINOR: config: reject long-deprecated "option forceclose"

It's been warning as being deprecated since 2.0-dev4, it's about time
to drop it now. The error message recommends to either remove it or
use "option httpclose" instead. It's still referred to in the old
internal doc about the connection header, which itself seems highly
inaccurate by now.

4 years agoMINOR: http: remove the long deprecated "set-cookie()" sample fetch function
Willy Tarreau [Fri, 11 Jun 2021 13:46:02 +0000 (15:46 +0200)] 
MINOR: http: remove the long deprecated "set-cookie()" sample fetch function

This one was marked as deprecated 9 years ago by commit 28376d62c
("MEDIUM: http: merge ACL and pattern cookie fetches into a single one")
and has disappeared from any documentation, so it never appeared in any
released version. Let's remove it now.

4 years agoMINOR: log: remove the long-deprecated early log-format tags
Willy Tarreau [Fri, 11 Jun 2021 13:37:45 +0000 (15:37 +0200)] 
MINOR: log: remove the long-deprecated early log-format tags

The following 10 log-format tags were implemented during log-format
development and changed before the release. They were marked as deprecated
in 2012 by commit 2beef5888 ("MEDIUM: log: change a few log tokens to make
them easier to remember") and were not documented. They've been emitting a
warning since then, with a suggestion of the one to use instead. Let's get
rid of them now.

      Bi => bi, Bp => bp, Ci => ci, Cp => cp, Fi => fi
      Fp => fp, Si => si, Sp => sp, cc => CC, cs => CS

4 years agoMINOR: config: completely remove support for "no option http-use-htx"
Willy Tarreau [Fri, 11 Jun 2021 13:34:34 +0000 (15:34 +0200)] 
MINOR: config: completely remove support for "no option http-use-htx"

This one used to still be supported, emitting a warning about it being
deprecated and the default since 2.1. Let's remove it now.

4 years agoMINOR: config: remove support for deprecated option "tune.chksize"
Willy Tarreau [Fri, 11 Jun 2021 13:29:31 +0000 (15:29 +0200)] 
MINOR: config: remove support for deprecated option "tune.chksize"

It was marked as deprecated for immediate removal as it was not used,
let's reject it and remove it from the doc. A specific error suggests
to check tune.bufsize instead.

4 years agoBUG/MINOR: server-state: load SRV resolution only if params match the config
Christopher Faulet [Thu, 10 Jun 2021 14:59:53 +0000 (16:59 +0200)] 
BUG/MINOR: server-state: load SRV resolution only if params match the config

When the state of a server is loaded, if there is no hostname defined for
this server and if a fqdn and a server record are retrieved from the state
file, it means the server should rely on a SRV resolution. But we must be
sure the server is configured this way. A SRV resolution must be configured
with the same SRV record. This part must be skipped if there is no SRV
resolution configured for this server or if the SRV record used is not the
same.

This patch should be backported as far as 1.8 after some observation period.

4 years agoMEDIUM: resolvers: add a ref between servers and srv request or used SRV record
Emeric Brun [Fri, 11 Jun 2021 08:48:45 +0000 (10:48 +0200)] 
MEDIUM: resolvers: add a ref between servers and srv request or used SRV record

This patch add a ref into servers to register them onto the
record answer item used to set their hostnames.

It also adds a head list into 'srvrq' to register servers free
to be affected to a SRV record.

A head of a tree is also added to srvrq to put servers which
present a hotname in server state file. To re-link them fastly
to the matching record as soon an item present the same name.

This results in better performances on SRV record response
parsing.

This is an optimization but it could avoid to trigger the haproxy's
internal wathdog in some circumstances. And for this reason
it should be backported as far we can (2.0 ?)

4 years agoMEDIUM: resolvers: add a ref on server to the used A/AAAA answer item
Emeric Brun [Fri, 11 Jun 2021 08:08:05 +0000 (10:08 +0200)] 
MEDIUM: resolvers: add a ref on server to the used A/AAAA answer item

This patch adds a head list into answer items on servers which use
this record to set their IPs. It makes lookup on duplicated ip faster and
allow to check immediatly if an item is still valid renewing the IP.

This results in better performances on A/AAAA resolutions.

This is an optimization but it could avoid to trigger the haproxy's
internal wathdog in some circumstances. And for this reason
it should be backported as far we can (2.0 ?)

4 years agoBUG/MINOR: resolvers: answser item list was randomly purged or errors
Emeric Brun [Thu, 10 Jun 2021 13:25:25 +0000 (15:25 +0200)] 
BUG/MINOR: resolvers: answser item list was randomly purged or errors

In case of SRV records, The answer item list was purged by the
error callback of the first requester which considers the error
could not be safely ignored. It makes this item list unavailable
for subsequent requesters even if they consider the error
could be ignored.

On A resolution or do_resolve action error, the answer items were
never trashed.

This patch re-work the error callbacks and the code to check the return code
If a callback return 1, we consider the error was ignored and
the answer item list must be kept. At the opposite, If all error callbacks
of all requesters of the same resolution returns 0 the list will be purged

This patch should be backported as far as 2.0.

4 years agoCLEANUP: l7-retries: do not test the buffer before calling b_alloc()
Christopher Faulet [Fri, 11 Jun 2021 13:55:56 +0000 (15:55 +0200)] 
CLEANUP: l7-retries: do not test the buffer before calling b_alloc()

The return value is enough now to know if the allocation succeeded or
failed.

This cleanup was already pushed by Willy (f499f50) but a revert crushed
it. It may be backported to the 2.4 because the original patch was done on
this version.

4 years agoBUG/MINOR: h1-htx: Fix a signess bug with char data type when parsing chunk size
Christopher Faulet [Fri, 11 Jun 2021 11:39:06 +0000 (13:39 +0200)] 
BUG/MINOR: h1-htx: Fix a signess bug with char data type when parsing chunk size

On some platform, a char may be unsigned. Of course, we should not rely on
the signess of a char to be portable. Unfortunatly, since the commit
a835f3cb ("MINOR: h1-htx: Use a correlation table to speed-up small chunks
parsing") we rely on it to test the value retrieved from the hexadecimal
correlation table when the size of a chunk is parsed.

To fix the bug, we now test the result is in the range [0,15] with a bitwise
AND.

This patch should fix the issue #1272. It is 2.5-specific, no backport is
needed except if the commit above is backported.

4 years agoBUG/MINOR: mux-fcgi: Expose SERVER_SOFTWARE parameter by default
Christopher Faulet [Fri, 11 Jun 2021 11:34:42 +0000 (13:34 +0200)] 
BUG/MINOR: mux-fcgi: Expose SERVER_SOFTWARE parameter by default

As specified in the RFC3875 (section 4.1.17), this parameter must be set to
the name and version of the information server software making the CGI
request. Thus, it is now added to the default parameters defined by
HAProxy. It is set to the string "HAProxy $version".

This patch should fix the issue #1285 and must be backported as far as 2.2.

4 years agoBUG/MAJOR: htx: Fix htx_defrag() when an HTX block is expanded
Christopher Faulet [Wed, 9 Jun 2021 15:30:40 +0000 (17:30 +0200)] 
BUG/MAJOR: htx: Fix htx_defrag() when an HTX block is expanded

When an HTX block is expanded, a defragmentation may be performed first to
have enough space to copy the new data. When it happens, the meta data of
the HTX message must take account of the new data length but copied data are
still unchanged at this stage (because we need more space to update the
message content). And here there is a bug because the meta data are updated
by the caller. It means that when the blocks content is copied, the new
length is already set. Thus a block larger than the reality is copied and
data outside the buffer may be accessed, leading to a crash.

To fix this bug, htx_defrag() is updated to use an extra argument with the
new meta data to use for the referenced block. Thus the caller does not need
to update the HTX message by itself. However, it still have to update the
data.

Most of time, the bug will be encountered in the HTTP compression
filter. But, even if it is highly unlikely, in theory it is also possible to
hit it when a HTTP header (or only its value) is replaced or when the
start-line is changed.

This patch must be backported as far as 2.0.

4 years agoREGTESTS: ssl: show_ssl_ocspresponce.vtc is broken with BoringSSL
William Lallemand [Fri, 11 Jun 2021 08:03:08 +0000 (10:03 +0200)] 
REGTESTS: ssl: show_ssl_ocspresponce.vtc is broken with BoringSSL

The `show ssl ocsp-response` feature is not available with BoringSSL,
but we don't have a way to disable this feature only with boringSSL on
the CI. Disable the reg-test until we do.

4 years agoBUG/MEDIUM: errors: include missing obj_type file
Willy Tarreau [Fri, 11 Jun 2021 05:31:57 +0000 (07:31 +0200)] 
BUG/MEDIUM: errors: include missing obj_type file

A tiny change in commit 6af81f80f ("MEDIUM: errors: implement parsing
context type") triggered an awful bug in gcc 5 and below (4.7.4 to 5.5
confirmed affected, at least on aarch64/mips/x86_64) causing the startup
to loop forever in acl_find_target().

This was tracked down to the acl.c file seeing a different definition
of the struct proxy than other files. The reason for this is that it
sees an unpacked "enum obj_type" (4 bytes) while others see it packed
(1 byte), thus all fields in the struct are having a different
alignment, and the "acl" list is shifted one pointer to the next struct
and seems to loop onto itself.

The commit above did nothing more than adding "enum obj_type *obj" in a
new struct without including obj_type.h, and that was apparently enough
for the compiler to internally declare obj_type as a regular enum and
silently ignore the packed attribute that it discovers later, so depending
on the order of includes, some files would see it as 1 byte and others as
4.

This patch simply adds the missing include but due to the nature of the
bug, probably that creating a special "packed_enum" definition to disable
the packed attribute on such compilers could be a safer option.

No backport is needed as this is only in -dev.

4 years agoBUILD: ssl: Fix compilation with BoringSSL
Remi Tricot-Le Breton [Thu, 10 Jun 2021 16:10:32 +0000 (18:10 +0200)] 
BUILD: ssl: Fix compilation with BoringSSL

The ifdefs surrounding the "show ssl ocsp-response" functionality that
were supposed to disable the code with BoringSSL were built the wrong
way.

It does not need to be backported.

4 years agoMEDIUM: pools: remove the locked pools implementation
Willy Tarreau [Thu, 10 Jun 2021 15:31:48 +0000 (17:31 +0200)] 
MEDIUM: pools: remove the locked pools implementation

Now that the modified lockless variant does not need a DWCAS anymore,
there's no reason to keep the much slower locked version, so let's
just get rid of it.

4 years agoCLEANUP: pools: remove now unused seq and pool_free_list
Willy Tarreau [Thu, 10 Jun 2021 06:46:28 +0000 (08:46 +0200)] 
CLEANUP: pools: remove now unused seq and pool_free_list

These ones were only used by the lockless implementation and are not
needed anymore.

4 years agoBUG/MAJOR: pools: fix possible race with free() in the lockless variant
Willy Tarreau [Wed, 9 Jun 2021 16:59:58 +0000 (18:59 +0200)] 
BUG/MAJOR: pools: fix possible race with free() in the lockless variant

In GH issue #1275, Fabiano Nunes Parente provided a nicely detailed
report showing reproducible crashes under musl. Musl is one of the libs
coming with a simple allocator for which we prefer to keep the shared
cache. On x86 we have a DWCAS so the lockless implementation is enabled
for such libraries.

And this implementation has had a small race since day one: the allocator
will need to read the first object's <next> pointer to place it into the
free list's head. If another thread picks the same element and immediately
releases it, while both the local and the shared pools are too crowded, it
will be freed to the OS. If the libc's allocator immediately releases it,
the memory area is unmapped and we can have a crash while trying to read
that pointer. However there is no problem as long as the item remains
mapped in memory because whatever value found there will not be placed
into the head since the counter will have changed.

The probability for this to happen is extremely low, but as analyzed by
Fabiano, it increases with the buffer size. On 16 threads it's relatively
easy to reproduce with 2MB buffers above 200k req/s, where it should
happen within the first 20 seconds of traffic usually.

This is a structural issue for which there are two non-trivial solutions:
  - place a read lock in the alloc call and a barrier made of lock/unlock
    in the free() call to force to serialize operations; this will have
    a big performance impact since free() is already one of the contention
    points;

  - change the allocator to use a self-locked head, similar to what is
    done in the MT_LISTS. This requires two memory writes to the head
    instead of a single one, thus the overhead is exactly one memory
    write during alloc and one during free;

This patch implements the second option. A new POOL_DUMMY pointer was
defined for the locked pointer value, allowing to both read and lock it
with a single xchg call. The code was carefully optimized so that the
locked period remains the shortest possible and that bus writes are
avoided as much as possible whenever the lock is held.

Tests show that while a bit slower than the original lockless
implementation on large buffers (2MB), it's 2.6 times faster than both
the no-cache and the locked implementation on such large buffers, and
remains as fast or faster than the all implementations when buffers are
48k or higher. Tests were also run on arm64 with similar results.

Note that this code is not used on modern libcs featuring a fast allocator.

A nice benefit of this change is that since it removes a dependency on
the DWCAS, it will be possible to remove the locked implementation and
replace it with this one, that is then usable on all systems, thus
significantly increasing their performance with large buffers.

Given that lockless pools were introduced in 1.9 (not supported anymore),
this patch will have to be backported as far as 2.0. The code changed
several times in this area and is subject to many ifdefs which will
complicate the backport. What is important is to remove all the DWCAS
code from the shared cache alloc/free lockless code and replace it with
this one. The pool_flush() code is basically the same code as the
allocator, retrieving the whole list at once. If in doubt regarding what
barriers to use in older versions, it's safe to use the generic ones.

This patch depends on the following previous commits:

 - MINOR: pools: do not maintain the lock during pool_flush()
 - MINOR: pools: call malloc_trim() under thread isolation
 - MEDIUM: pools: use a single pool_gc() function for locked and lockless

The last one also removes one occurrence of an unneeded DWCAS in the
code that was incompatible with this fix. The removal of the now unused
seq field will happen in a future patch.

Many thanks to Fabiano for his detailed report, and to Olivier for
his help on this issue.

4 years agoMEDIUM: pools: use a single pool_gc() function for locked and lockless
Willy Tarreau [Thu, 10 Jun 2021 08:21:35 +0000 (10:21 +0200)] 
MEDIUM: pools: use a single pool_gc() function for locked and lockless

Locked and lockless shared pools don't need to use a different pool_gc()
function because this function isolates itself during the operation, so
we do not need to rely on DWCAS nor any atomic operation in fact. Let's
just get rid of the lockless one in favor of the simple one. This should
even result in a faster execution.

The ifdefs were slightly moved so that we can have pool_gc() defined
as soon as there are global pools, this avoids duplicating the function.

4 years agoMINOR: pools: call malloc_trim() under thread isolation
Willy Tarreau [Thu, 10 Jun 2021 06:40:16 +0000 (08:40 +0200)] 
MINOR: pools: call malloc_trim() under thread isolation

pool_gc() was adjusted to run under thread isolation by commit c0e2ff202
("MEDIUM: memory: make pool_gc() run under thread isolation") so that the
underlying malloc() and free() don't compete between threads during these
potentially aggressive moments (especially when mmap/munmap are involved).

Commit 88366c292 ("MEDIUM: pools: call malloc_trim() from pool_gc()")
later added a call to malloc_trim() but made it outside of the thread
isolation, which is contrary to the principle explained above. Also it
missed it in the locked version, meaning that those without a lockless
implementation cannot benefit from trimming.

This patch fixes that by calling it before thread_release() in both
places.

4 years agoMINOR: pools: do not maintain the lock during pool_flush()
Willy Tarreau [Thu, 10 Jun 2021 05:13:04 +0000 (07:13 +0200)] 
MINOR: pools: do not maintain the lock during pool_flush()

The locked version of pool_flush() is absurd, it locks the pool for each
and every element to be released till the end. Not only this is extremely
inefficient, but it may even never finish if other threads spend their
time refilling the pool. The only case where this can happen is during
soft-stop so the risk remains limited, but it should be addressed.

4 years agoBUG/MINOR: pools: make DEBUG_UAF always write to the to-be-freed location
Willy Tarreau [Thu, 10 Jun 2021 15:20:19 +0000 (17:20 +0200)] 
BUG/MINOR: pools: make DEBUG_UAF always write to the to-be-freed location

Since the code was reorganized, DEBUG_UAF was still tested in the locked
pool code despite pools being disabled when DEBUG_UAF is used. Let's move
the test to pool_put_to_os() which is the one that is always called in
this condition.

The impact is only a possible misleading analysis during a troubleshooting
session due to a missing double-frees or free of const area test that is
normally already dealt with by the underlying code anyway. In practice it's
unlikely anyone will ever notice.

This should only be backported to 2.4.

4 years agoBUG/MINOR: pools: fix a possible memory leak in the lockless pool_flush()
Willy Tarreau [Thu, 10 Jun 2021 04:54:22 +0000 (06:54 +0200)] 
BUG/MINOR: pools: fix a possible memory leak in the lockless pool_flush()

The lockless version of pool_flush() had a leftover of the original
version causing the pool's first entry to be set to NULL at the end.
The problem is that it does this outside of any lock and in a non-
atomic way, so that any concurrent alloc+free would result in a lost
object.

The risk is low and the consequence even lower, given that pool_flush()
is only used in pool_destroy() (hence single-threaded) or by stream_free()
during a soft-stop (not the place where most allocations happen), so in
the worst case it could result in valgrind complaining on soft-stop.

The bug was introduced with the first version of the code, in 1.9, so
the fix can be backported to all stable versions.

4 years agoBUG/MINOR: server: explicitly set "none" init-addr for dynamic servers
Amaury Denoyelle [Thu, 10 Jun 2021 15:34:10 +0000 (17:34 +0200)] 
BUG/MINOR: server: explicitly set "none" init-addr for dynamic servers

Define srv.init_addr_methods to SRV_IADDR_NONE on 'add server' CLI
handler. This explicitly states that no resolution will be made on the
server creation.

This is not a real bug as the default value (SRV_IADDR_END) has the same
effect in practice. However the intent is clearer and prevent to use the
default "libc,last" by mistake which cannot execute on runtime (blocking
call + file access via gethostbyname/getaddrinfo).

The doc is also updated to reflect this limitation.

This should be backported up to 2.4.

4 years agoREGTESTS: ssl: Add "show ssl ocsp-response" test
Remi Tricot-Le Breton [Thu, 10 Jun 2021 11:51:16 +0000 (13:51 +0200)] 
REGTESTS: ssl: Add "show ssl ocsp-response" test

This file adds tests for the new "show ssl ocsp-response" command and
the new "show ssl cert foo.pem.ocsp" and "show ssl cert *foo.pem.ocsp"
special cases. They are all used to display information about an OCSP
response, committed or not.

4 years agoMINOR: ssl: Add the "show ssl cert foo.pem.ocsp" CLI command
Remi Tricot-Le Breton [Thu, 10 Jun 2021 11:51:15 +0000 (13:51 +0200)] 
MINOR: ssl: Add the "show ssl cert foo.pem.ocsp" CLI command

Add the ability to dump an OCSP response details through a call to "show
ssl cert cert.pem.ocsp". It can also be used on an ongoing transaction
by prefixing the certificate name with a '*'.
Even if the ckch structure holds an ocsp_response buffer, we still need
to look for the actual ocsp response entry in the ocsp response tree
rather than just dumping the ckch's buffer details because when updating
an ocsp response through a "set ssl ocsp-response" call, the
corresponding buffer in the ckch is not updated accordingly. So this
buffer, even if it is not empty, might hold an outdated ocsp response.

4 years agoMINOR: ssl: Add the OCSP entry key when displaying the details of a certificate
Remi Tricot-Le Breton [Thu, 10 Jun 2021 11:51:14 +0000 (13:51 +0200)] 
MINOR: ssl: Add the OCSP entry key when displaying the details of a certificate

This patch adds an "OCSP Response Key" information in the output of a
"show ssl cert <certfile>" call. The key can then be used in a "show ssl
ocsp-response <key>" CLI command.

4 years agoMINOR: ssl: Add new "show ssl ocsp-response" CLI command
Remi Tricot-Le Breton [Thu, 10 Jun 2021 11:51:13 +0000 (13:51 +0200)] 
MINOR: ssl: Add new "show ssl ocsp-response" CLI command

This patch adds the "show ssl ocsp-response [<id>]" CLI command. This
command can be used to display the IDs of the OCSP tree entries along
with details about the entries' certificate ID (issuer's name and key
hash + serial number), or to display the details of a single
ocsp-response if an ID is given. The details displayed in this latter
case are the ones shown by a "openssl ocsp -respin <ocsp-response>
-text" call.

4 years agoMINOR: ssl: Keep the actual key length in the certificate_ocsp structure
Remi Tricot-Le Breton [Thu, 10 Jun 2021 11:51:12 +0000 (13:51 +0200)] 
MINOR: ssl: Keep the actual key length in the certificate_ocsp structure

The OCSP tree entry key is a serialized version of the OCSP_CERTID of
the entry which is stored in a buffer that can be at most 128 bytes.
Depending on the length of the serial number, the actual non-zero part
of the key can be smaller than 128 bytes and this new structure member
allows to know how many of the bytes are filled. It will be useful when
dumping the key (in a "show ssl cert <cert>" output for instance).

4 years agoBUG/MEDIUM: compression: Add a flag to know the filter is still processing data
Christopher Faulet [Wed, 9 Jun 2021 15:12:44 +0000 (17:12 +0200)] 
BUG/MEDIUM: compression: Add a flag to know the filter is still processing data

Since the commit acfd71b97 ("BUG/MINOR: http-comp: Preserve
HTTP_MSGF_COMPRESSIONG flag on the response"), there is no more flag to know
when the compression ends. This means it is possible to finish the
compression several time if there are trailers.

So, we reintroduce almost the same mechanism but with a dedicated flag. So
now, there is a bits field in the compression filter context.

The commit above is marked to be backported as far as 2.0. Thus this patch
must also be backported as far as 2.0.

4 years agoBUG/MEDIUM: compression: Properly get the next block to iterate on payload
Christopher Faulet [Wed, 9 Jun 2021 15:04:37 +0000 (17:04 +0200)] 
BUG/MEDIUM: compression: Properly get the next block to iterate on payload

When a DATA block is compressed, or when the compression context is finished
on a TLR/EOT block, the next block used to loop on the HTX message must be
refreshed because a defragmentation may have occurred.

This bug was introduced when the EOM block was removed in 2.4. Thus, this
patch must be backported to 2.4.

4 years agoBUG/MEDIUM: compression: Fix loop skipping unused blocks to get the next block
Christopher Faulet [Wed, 9 Jun 2021 14:59:02 +0000 (16:59 +0200)] 
BUG/MEDIUM: compression: Fix loop skipping unused blocks to get the next block

In comp_http_payload(), the loop skipping unused blocks is buggy and may
lead to a infinite loop if the first next block is unused. Indeed instead of
iterating on blocks, we always retrieve the same one because <blk> is used
instead of <next> to get the next block.

This bug was introduced when the EOM block was removed in 2.4. Thus, this
patch must be backported to 2.4.

4 years agoSCRIPTS: opentracing: enable parallel builds in build-ot.sh
Willy Tarreau [Thu, 10 Jun 2021 05:35:15 +0000 (07:35 +0200)] 
SCRIPTS: opentracing: enable parallel builds in build-ot.sh

The script didn't make use of parallel builds, which roughly cut the
build time in half with 4 cores. This can help a bit with the CI.

4 years agoBUG/MEDIUM: opentracing: initialization before establishing daemon and/or chroot...
Miroslav Zagorac [Wed, 9 Jun 2021 23:23:15 +0000 (01:23 +0200)] 
BUG/MEDIUM: opentracing: initialization before establishing daemon and/or chroot mode

This patch solves the problem reported in github issue #1204, where the
OpenTracing filter cannot communicate with the selected tracer if HAProxy
is run in daemon mode.

This commit also solves github issue #1274, where the problem manifests
itself when using the 'chroot' keyword in the HAProxy configuration.

This is solved so that the initialization of the OpenTracing plugin is
split into two operations, first the plugin (dynamic library) is loaded
before switching the HAProxy to daemon mode (or chroot) and then the
tracer thread is started.

This means that nothing is retrieved from the file system in runtime.

After applying this commit, opentracing C wrapper version 1.1.0 should be
used because the earlier version does not have separated initialization
functions.

This resolves GitHub issues #1204 and #1274.

4 years agoRevert "BUG/MINOR: opentracing: initialization after establishing daemon mode"
Miroslav Zagorac [Wed, 9 Jun 2021 23:19:13 +0000 (01:19 +0200)] 
Revert "BUG/MINOR: opentracing: initialization after establishing daemon mode"

This reverts commit f2263435d71964d1aa3eb80df6464500696c0515.

This commit is unnecessary because although it solves the problem of using
the OpenTracing filter in daemon mode, it does not solve the same problem
if chroot is used.

The following commit related to the OpenTracing filter solves both problems
efficiently.

4 years agoBUG/MINOR: ssl: OCSP stapling does not work if expire too far in the future
Remi Tricot-Le Breton [Wed, 9 Jun 2021 15:16:18 +0000 (17:16 +0200)] 
BUG/MINOR: ssl: OCSP stapling does not work if expire too far in the future

The wey the "Next Update" field of the OCSP response is converted into a
timestamp relies on the use of signed integers for the year and month so
if the calculated timestamp happens to overflow INT_MAX, it ends up
being seen as negative and the OCSP response being dwignored in
ssl_sock_ocsp_stapling_cbk (because of the "ocsp->expire < now.tv_sec"
test).

It could be backported to all stable branches.

4 years agoBUILD: make tune.ssl.keylog available again
William Lallemand [Wed, 9 Jun 2021 14:46:12 +0000 (16:46 +0200)] 
BUILD: make tune.ssl.keylog available again

Since commit 04a5a44 ("BUILD: ssl: use HAVE_OPENSSL_KEYLOG instead of
OpenSSL versions") the "tune.ssl.keylog" feature is broken because
HAVE_OPENSSL_KEYLOG does not exist.

Replace this by a HAVE_SSL_KEYLOG which is defined in openssl-compat.h.
Also add an error when not built with the right openssl version.

Must be backported as far as 2.3.

4 years agoCI: Make matrix.py executable and add shebang
Tim Duesterhus [Tue, 8 Jun 2021 13:14:35 +0000 (15:14 +0200)] 
CI: Make matrix.py executable and add shebang

It's a script, allow executing this as a script without needing to invoke
`python3` manually.

4 years agoBUG: errors: remove printf positional args for user messages context
Amaury Denoyelle [Mon, 7 Jun 2021 17:24:10 +0000 (19:24 +0200)] 
BUG: errors: remove printf positional args for user messages context

Change the algorithm for the generation of the user messages context
prefix. Remove the dubious API relying on optional printf positional
arguments. This may be non portable, and in fact the CI glibc crashes
with the following error when some arguments are not present in the
format string :

"invalid %N$ use detected".

Now, a fixed buffer attached to the context instance is allocated once
for the program lifetime. Then call repeatedly snprintf with the
optional arguments of context if present to build the context string.
The buffer is deallocated via a per-thread free handler.

This does not need to be backported.

4 years agoMINOR: haproxy: Add `-cc` argument
Maximilian Mader [Sat, 5 Jun 2021 22:50:22 +0000 (00:50 +0200)] 
MINOR: haproxy: Add `-cc` argument

This patch adds the `-cc` (check condition) argument to evaluate conditions on
startup and return the result as the exit code.

As an example this can be used to easily check HAProxy's version in scripts:

    haproxy -cc 'version_atleast(2.4)'

This resolves GitHub issue #1246.

Co-authored-by: Tim Duesterhus <tim@bastelstu.be>
4 years agoCLEANUP: tools: Make errptr const in `parse_line()`
Maximilian Mader [Sat, 5 Jun 2021 22:50:21 +0000 (00:50 +0200)] 
CLEANUP: tools: Make errptr const in `parse_line()`

This change is for consistency with `cfg_eval_condition()`.

4 years agoCLEANUP: cfgparse: Remove duplication of `MAX_LINE_ARGS + 1`
Tim Duesterhus [Sat, 5 Jun 2021 22:50:20 +0000 (00:50 +0200)] 
CLEANUP: cfgparse: Remove duplication of `MAX_LINE_ARGS + 1`

We can calculate the number of possible arguments based off the size of the
`args` array. We should do so to prevent the two values from getting out of
sync.

4 years agoDOC: use the req.ssl_sni in examples
Alex [Sat, 5 Jun 2021 11:23:08 +0000 (13:23 +0200)] 
DOC: use the req.ssl_sni in examples

This patch should be backported to at least 2.0

4 years agoMINOR: server: use ha_alert in server parsing functions
Amaury Denoyelle [Fri, 28 May 2021 14:35:05 +0000 (16:35 +0200)] 
MINOR: server: use ha_alert in server parsing functions

Replace memprintf usage in _srv_parse* functions by ha_alert calls. This
has the advantage to simplify the function prototype by removing an
extra char** argument.

As a consequence, the CLI handler of 'add server' is updated to output
the user messages buffers if not empty.

4 years agoMINOR: server: use parsing ctx for server init addr
Amaury Denoyelle [Fri, 28 May 2021 09:01:52 +0000 (11:01 +0200)] 
MINOR: server: use parsing ctx for server init addr

Initialize the parsing context in srv_init_addr. This function is called
after configuration check.

This will standardize the stderr output on startup with the parse_server
function.

4 years agoREORG: config: use parsing ctx for server config check
Amaury Denoyelle [Fri, 28 May 2021 08:34:01 +0000 (10:34 +0200)] 
REORG: config: use parsing ctx for server config check

Initialize the parsing context when checking server config validity.
Adjust the log messages to remove redundant config file/line and server
name. Do a similar cleaning in prepare_srv from ssl_sock as this
function is called at the same stage.

This will standardize the stderr output on startup with the parse_server
function.

4 years agoREORG: server: use parsing ctx for server parsing
Amaury Denoyelle [Fri, 28 May 2021 09:00:18 +0000 (11:00 +0200)] 
REORG: server: use parsing ctx for server parsing

Use the parsing context in parse_server. Remove redundant manual
format-string specifying the current file/line/server parsed.

4 years agoMINOR: log: define server user message format
Amaury Denoyelle [Fri, 28 May 2021 08:36:56 +0000 (10:36 +0200)] 
MINOR: log: define server user message format

Define the format for user messages related to a server instance. It
contains the names of the backend and the server itself.

4 years agoMINOR: errors: specify prefix "config" for parsing output
Amaury Denoyelle [Fri, 4 Jun 2021 16:22:08 +0000 (18:22 +0200)] 
MINOR: errors: specify prefix "config" for parsing output

Set "config :" as a prefix for the user messages context before starting
the configuration parsing. All following stderr output will be prefixed
by it.

As a consequence, remove extraneous prefix "config" already specified in
various ha_alert/warning/notice calls.

4 years agoMINOR: log: display exec path on first warning
Amaury Denoyelle [Fri, 28 May 2021 07:57:10 +0000 (09:57 +0200)] 
MINOR: log: display exec path on first warning

Display process executable path on first warning if not already done in
ha_warning, as in ha_alert. The output is thus cleaner when ALERT and
WARN messages are mixed, with the executable path always on first
position.

4 years agoMINOR: errors: use user messages context in print_message
Amaury Denoyelle [Thu, 27 May 2021 13:46:19 +0000 (15:46 +0200)] 
MINOR: errors: use user messages context in print_message

Prepend the user messages context to stderr output in print_message. It
is inserted between the output prefix (log level / pid) and the message
itself. Its content depends on the loaded context infos.

4 years agoMEDIUM: errors: implement parsing context type
Amaury Denoyelle [Thu, 27 May 2021 13:45:28 +0000 (15:45 +0200)] 
MEDIUM: errors: implement parsing context type

Create a parsing_ctx structure. This type is used to store information
about the current file/line parsed. A global context is created and
can be manipulated when haproxy is in STARTING mode. When starting is
over, the context is resetted and should not be accessed anymore.

4 years agoMINOR: log: do not discard stderr when starting is over
Amaury Denoyelle [Wed, 26 May 2021 09:05:45 +0000 (11:05 +0200)] 
MINOR: log: do not discard stderr when starting is over

Always print message in ha_alert/warning/notice when starting is over,
regardless of quiet/verbose options.

This change is useful to retrieve the output via the newly implemented
user messages buffer at runtime, for the CLI handlers.

4 years agoMEDIUM: errors: implement user messages buffer
Amaury Denoyelle [Wed, 26 May 2021 09:05:22 +0000 (11:05 +0200)] 
MEDIUM: errors: implement user messages buffer

The user messages buffer is used to store the stderr output after the
starting is over. Each thread has it own user messages buffer. Add some
functions to add a new message, retrieve and clear the content.

The user messages buffer primary goal is to be consulted by CLI
handlers. Each handlers using it must clear the buffer before starting
its operation.

4 years agoCLEANUP: server: fix cosmetic of error message on sni parsing
Amaury Denoyelle [Fri, 28 May 2021 09:01:22 +0000 (11:01 +0200)] 
CLEANUP: server: fix cosmetic of error message on sni parsing

Fix memprintf used in server_parse_sni_expr. Error messages should not
be ending with a newline as it will be inserted in the parent function
on the ha_alert invocation.

4 years agoREORG: errors: split errors reporting function from log.c
Amaury Denoyelle [Fri, 4 Jun 2021 09:20:32 +0000 (11:20 +0200)] 
REORG: errors: split errors reporting function from log.c

Move functions related to errors output on stderr from log.c to a newly
created errors.c file. It targets print_message and
ha_alert/warning/notice/diag functions and related startup_logs feature.

4 years agoMINOR: errors: allow empty va_args for diag variadic macro
Amaury Denoyelle [Mon, 31 May 2021 12:26:20 +0000 (14:26 +0200)] 
MINOR: errors: allow empty va_args for diag variadic macro

Use the '##' operator to allow the usage of HA_DIAG_WARNING_COND macro
without extra arguments.

This must be backported up to 2.4.

4 years agoCI: github actions: -Wno-deprecated-declarations with OpenSSL 3.0.0
William Lallemand [Mon, 7 Jun 2021 13:27:57 +0000 (15:27 +0200)] 
CI: github actions: -Wno-deprecated-declarations with OpenSSL 3.0.0

Disable the deprecated functions warning when building with openssl
3.0.0 alpha. This will need to be reverted once haproxy is ported to the
new API.

4 years agoCI: github actions: add OpenSSL-3.0.0 builds
Ilya Shipitsin [Sat, 5 Jun 2021 03:06:59 +0000 (03:06 +0000)] 
CI: github actions: add OpenSSL-3.0.0 builds

OpenSSL-3.0.0 is getting close to its release, let us add it to build matrix

4 years agoCLEANUP: reg-tests: Remove obsolete no-htx parameter for reg-tests
Tim Duesterhus [Mon, 31 May 2021 21:07:29 +0000 (23:07 +0200)] 
CLEANUP: reg-tests: Remove obsolete no-htx parameter for reg-tests

The legacy HTTP subsystem has been removed. HTX is always enabled.

4 years agoCLEANUP: backend: fix incorrect comments on locking conditions for lb functions
Willy Tarreau [Tue, 1 Jun 2021 14:58:31 +0000 (16:58 +0200)] 
CLEANUP: backend: fix incorrect comments on locking conditions for lb functions

The leastconn and roundrobin functions mention that the server's lock
must be held while this is not true at all and it is not used either.
The "first" algo doesn't mention anything about the need for locking,
so let's mention that it uses the lbprm lock.

4 years agoREGTESTS: Fix http_abortonclose.vtc to support -1 status for some client aborts
Christopher Faulet [Wed, 2 Jun 2021 15:23:47 +0000 (17:23 +0200)] 
REGTESTS: Fix http_abortonclose.vtc to support -1 status for some client aborts

Since the commit 5e702fcad ("MINOR: http-ana: Use -1 status for client
aborts during queuing and connect"), -1 status is reported in the log
message when the client aborts during queuing and
connect. http_abortonclose.vtc script must be update accordingly.

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.