]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
6 years agoBUILD: threads: Add __ha_cas_dw fallback for single threaded builds
Chris Packham [Thu, 9 May 2019 05:07:40 +0000 (17:07 +1200)] 
BUILD: threads: Add __ha_cas_dw fallback for single threaded builds

__ha_cas_dw() is used in fd_rm_from_fd_list() and when built without
USE_THREADS=1 the linker fails to find __ha_cas_dw(). Add a definition
of __ha_cas_dw() for the #ifndef USE_THREADS case.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
6 years agoBUILD: add BoringSSL to travis-ci build matrix
Ilya Shipitsin [Wed, 8 May 2019 20:15:59 +0000 (01:15 +0500)] 
BUILD: add BoringSSL to travis-ci build matrix

6 years agoCLEANUP: ssl: make inclusion of openssl headers safe
Willy Tarreau [Fri, 10 May 2019 07:58:43 +0000 (09:58 +0200)] 
CLEANUP: ssl: make inclusion of openssl headers safe

It's always a pain to have to stuff lots of #ifdef USE_OPENSSL around
ssl headers, it even results in some of them appearing in a random order
and multiple times just to benefit form an existing ifdef block. Let's
make these headers safe for inclusion when USE_OPENSSL is not defined,
they now perform the test themselves and do nothing if USE_OPENSSL is
not defined. This allows to remove no less than 8 such ifdef blocks
and make include blocks more readable.

6 years agoCLEANUP: ssl: never include openssl/*.h outside of openssl-compat.h anymore
Willy Tarreau [Fri, 10 May 2019 07:35:00 +0000 (09:35 +0200)] 
CLEANUP: ssl: never include openssl/*.h outside of openssl-compat.h anymore

Since we're providing a compatibility layer for multiple OpenSSL
implementations and their derivatives, it is important that no C file
directly includes openssl headers but only passes via openssl-compat
instead. As a bonus this also gets rid of redundant complex rules for
inclusion of certain files (engines etc).

6 years agoREORG: ssl: move some OpenSSL defines from ssl_sock to openssl-compat
Willy Tarreau [Fri, 10 May 2019 07:22:53 +0000 (09:22 +0200)] 
REORG: ssl: move some OpenSSL defines from ssl_sock to openssl-compat

Some defines like OPENSSL_VERSION or X509_getm_notBefore() have nothing
to do in ssl_sock and must move to openssl-compat.h so that they are
consistently shared by the whole code. A warning in the code was added
against wild additions of macros there.

6 years agoREORG: ssl: move openssl-compat from proto to common
Willy Tarreau [Thu, 9 May 2019 12:52:44 +0000 (14:52 +0200)] 
REORG: ssl: move openssl-compat from proto to common

This way we can include it much earlier to cover types/ as well.

6 years agoBUILD: ssl: fix libressl build again after aes-gcm-enc
Willy Tarreau [Fri, 10 May 2019 07:16:53 +0000 (09:16 +0200)] 
BUILD: ssl: fix libressl build again after aes-gcm-enc

Enabling aes-gcm-enc in last commit (MINOR: ssl: enable aes_gcm_dec
on LibreSSL) uncovered a wrong condition on the define of the
EVP_CTRL_AEAD_SET_IVLEN macro which I forgot to add when making the
commit, resulting in breaking libressl build again. In case libressl
later defines this macro, the test will have to change for a version
range instead.

6 years agoMINOR: ssl: enable aes_gcm_dec on LibreSSL
Willy Tarreau [Thu, 9 May 2019 12:15:32 +0000 (14:15 +0200)] 
MINOR: ssl: enable aes_gcm_dec on LibreSSL

This one requires OpenSSL 1.0.1 and above, and libressl was forked from
1.0.1g and is compatible (build-tested). No need to exclude it anymore
from using this converter.

6 years agoCLEANUP: ssl: remove 57 occurrences of useless tests on LIBRESSL_VERSION_NUMBER
Willy Tarreau [Thu, 9 May 2019 12:13:35 +0000 (14:13 +0200)] 
CLEANUP: ssl: remove 57 occurrences of useless tests on LIBRESSL_VERSION_NUMBER

They were all check to comply with the advertised openssl version. Now
that libressl doesn't pretend to be a more recent openssl anymore, we
can simply rely on the regular openssl version tests without having to
deal with exceptions for libressl.

6 years agoBUILD: ssl: make libressl use its own version numbers
Willy Tarreau [Thu, 9 May 2019 11:41:45 +0000 (13:41 +0200)] 
BUILD: ssl: make libressl use its own version numbers

LibreSSL causes lots of build issues by pretending to be OpenSSL 2.0.0,
and it requires lots of care for each #if added to cover any specific
OpenSSL features.

This commit addresses the problem by making LibreSSL only advertise the
version it forked from (1.0.1g) and by starting to use tests based on
its real version to enable features instead of working by exclusion.

6 years agoCLEANUP: ssl-sock: use HA_OPENSSL_VERSION_NUMBER instead of OPENSSL_VERSION_NUMBER
Willy Tarreau [Thu, 9 May 2019 11:26:41 +0000 (13:26 +0200)] 
CLEANUP: ssl-sock: use HA_OPENSSL_VERSION_NUMBER instead of OPENSSL_VERSION_NUMBER

Most tests on OPENSSL_VERSION_NUMBER have become complex and break all
the time because this number is fake for some derivatives like LibreSSL.
This patch creates a new macro, HA_OPENSSL_VERSION_NUMBER, which will
carry the real openssl version defining the compatibility level, and
this version will be adjusted depending on the variants.

6 years agoBUILD: ssl: fix again a libressl build failure after the openssl FD leak fix
Willy Tarreau [Thu, 9 May 2019 11:53:28 +0000 (13:53 +0200)] 
BUILD: ssl: fix again a libressl build failure after the openssl FD leak fix

As with every single OpenSSL fix, LibreSSL build broke again, this time
after commit 56996dabe ("BUG/MINOR: mworker/ssl: close OpenSSL FDs on
reload"). A definitive solution will have to be found quickly. For now,
let's exclude libressl from the version test.

This patch must be backported to 1.9 since the fix above was already
backported there.

6 years agoBUG/MEDIUM: h2: Make sure we set send_list to NULL in h2_detach().
Olivier Houchard [Thu, 9 May 2019 11:24:08 +0000 (13:24 +0200)] 
BUG/MEDIUM: h2: Make sure we set send_list to NULL in h2_detach().

In h2_detach(), if we still have a send_wait pointer, because we woke the
tasklet up, but it hasn't ran yet, explicitely set send_wait to NULL after
we removed the tasklet from the task list.
Failure to do so may lead to crashes if the h2s isn't immediately destroyed,
because we considered there were still something to send.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: servers: Don't use the same srv flag for cookie-set and TFO.
Olivier Houchard [Wed, 8 May 2019 17:48:32 +0000 (19:48 +0200)] 
BUG/MEDIUM: servers: Don't use the same srv flag for cookie-set and TFO.

The tfo code was based on an old patch, and the value of the SRV_F_FASTOPEN
flag it used was since reused for SRV_F_COOKIESET. So give SRV_F_FASTOPEN
its own value.

6 years agoBUILD: travis-ci bugfixes and improvements
Ilya Shipitsin [Mon, 6 May 2019 20:42:43 +0000 (01:42 +0500)] 
BUILD: travis-ci bugfixes and improvements

Call missing scripts/build-ssl.sh (which actually builds SSL variants)
Enable OpenSSL, LibreSSL builds caching, it saves a bunch of time
LibreSSL builds are not allowed to fail anymore
Add openssl to osx builds

6 years agoMINOR: htx: Remove support for unused OOB HTX blocks
Christopher Faulet [Tue, 7 May 2019 19:48:12 +0000 (21:48 +0200)] 
MINOR: htx: Remove support for unused OOB HTX blocks

This type of block was introduced in the early design of the HTX and it is not
used anymore. So, just remove it.

This patch may be backported to 1.9.

6 years agoMINOR: htx: Don't try to append a trailer block with the previous one
Christopher Faulet [Tue, 7 May 2019 19:42:27 +0000 (21:42 +0200)] 
MINOR: htx: Don't try to append a trailer block with the previous one

In H1 and H2, one and only one trailer block is emitted during the HTTP
parsing. So it is useless to try to append this block with the previous one,
like for data block.

This patch may be backported to 1.9.

6 years agoMINOR: htx: Split on DATA blocks only when blocks are moved to an HTX message
Christopher Faulet [Tue, 7 May 2019 08:52:54 +0000 (10:52 +0200)] 
MINOR: htx: Split on DATA blocks only when blocks are moved to an HTX message

When htx_xfer_blks() is called to move blocks from an HTX message to another
one, most of blocks must be transferred atomically. But some may be splitted if
there is not enough space to move all the block. This was true for DATA and TLR
blocks. But it is a bad idea to split trailers. During HTTP parsing, only one
TLR block is emitted. It simplifies the processing of trailers to keep the block
untouched.

This patch must be backported to 1.9 because some fixes may depend on it.

6 years agoBUG/MINOR: htx: Never transfer more than expected in htx_xfer_blks()
Christopher Faulet [Tue, 7 May 2019 08:52:25 +0000 (10:52 +0200)] 
BUG/MINOR: htx: Never transfer more than expected in htx_xfer_blks()

When the maximum free space available for data in the HTX message is compared to
the number of bytes to transfer, we must take into account the amount of data
already transferred. Otherwise we may move more data than expected.

This patch must be backported to 1.9.

6 years agoBUG/MINOR: mux-h1: Fix the parsing of trailers
Christopher Faulet [Tue, 7 May 2019 08:53:32 +0000 (10:53 +0200)] 
BUG/MINOR: mux-h1: Fix the parsing of trailers

Unlike other H1 parsing functions, the 3rd parameter of the function
h1_measure_trailers() is the maximum number of bytes to read. For others
functions, it is the relative offset where to stop the parsing.

This patch must be backported to 1.9.

6 years agoBUG/MEDIUM: spoe: Be sure the sample is found before setting its context
Christopher Faulet [Mon, 6 May 2019 07:53:10 +0000 (09:53 +0200)] 
BUG/MEDIUM: spoe: Be sure the sample is found before setting its context

When a sample fetch is encoded, we use its context to set info about the
fragmentation. But if the sample is not found, the function sample_process()
returns NULL. So we me be sure the sample exists before setting its context.

This patch must be backported to 1.9 and 1.8.

6 years agoBUG/MINOR: mux-h2: fix the condition to close a cs-less h2s on the backend
Willy Tarreau [Tue, 7 May 2019 16:10:10 +0000 (18:10 +0200)] 
BUG/MINOR: mux-h2: fix the condition to close a cs-less h2s on the backend

A typo was introduced in the following commit : 927b88ba0 ("BUG/MAJOR:
mux-h2: fix race condition between close on both ends") making the test
on h2s->cs never being done and h2c->cs being dereferenced without being
tested. This also confirms that this condition does not happen on this
side but better fix it right now to be safe.

This must be backported to 1.9.

6 years agoMINOR: mworker: support a configurable maximum number of reloads
William Lallemand [Tue, 7 May 2019 15:49:33 +0000 (17:49 +0200)] 
MINOR: mworker: support a configurable maximum number of reloads

This patch implements a new global parameter for the master-worker mode.
When setting the mworker-max-reloads value, a worker receive a SIGTERM
if its number of reloads is greater than this value.

6 years agoCLEANUP: task: remove unneeded tests before task_destroy()
Willy Tarreau [Tue, 7 May 2019 17:05:35 +0000 (19:05 +0200)] 
CLEANUP: task: remove unneeded tests before task_destroy()

Since previous commit it's not needed anymore to test a task pointer
before calling task_destory() so let's just remove these tests from
the various callers before they become confusing. The function's
arguments were also documented. The same should probably be done
with tasklet_free() which involves a test in roughly half of the
call places.

6 years agoBUG/MEDIUM: tasks: fix possible segfault on task_destroy()
Dragan Dosen [Tue, 7 May 2019 13:25:25 +0000 (15:25 +0200)] 
BUG/MEDIUM: tasks: fix possible segfault on task_destroy()

Commit 3f795f7 ("MEDIUM: tasks: Merge task_delete() and task_free() into
task_destroy().") replaced task_delete() and task_free() with a single
function named task_destroy().

This patch adds a check for struct task* argument in function
task_destroy() to prevent a possible segfault on NULL and also to make
the function safer for use in other cases.

6 years agoBUG/MEDIUM: stick-table: fix regression caused by a change in proxy struct
Dragan Dosen [Tue, 7 May 2019 12:16:18 +0000 (14:16 +0200)] 
BUG/MEDIUM: stick-table: fix regression caused by a change in proxy struct

In commit 1b8e68e ("MEDIUM: stick-table: Stop handling stick-tables as
proxies."), the ->table member of proxy struct was replaced by a pointer
that is not always checked and in some situations can cause a segfault,
eg. during reload or while using "show table" on CLI socket.

No backport is needed.

6 years agoMINOR: systemd: support /etc/sysconfig/ for redhat based distrib
William Lallemand [Tue, 7 May 2019 12:00:33 +0000 (14:00 +0200)] 
MINOR: systemd: support /etc/sysconfig/ for redhat based distrib

The patch "MINOR: systemd: Make use of master socket in systemd unit"
introduces an environment file in /etc/default.

Unfortunatly this is not supported on redhat-based system, so we add
/etc/sysconfig/haproxy for that.

6 years agoMINOR: systemd: Make use of master socket in systemd unit
Tim Duesterhus [Mon, 6 May 2019 11:00:53 +0000 (13:00 +0200)] 
MINOR: systemd: Make use of master socket in systemd unit

Unless the EXTRAOPTS variable is overriden in /etc/default/haproxy
the unit file will use the master socket by default.

This patch may be backported to 1.9 and depends on
MINOR: systemd: Use the variables from /etc/default/haproxy.

6 years agoMINOR: systemd: Use the variables from /etc/default/haproxy
Apollon Oikonomopoulos [Mon, 6 May 2019 11:00:52 +0000 (13:00 +0200)] 
MINOR: systemd: Use the variables from /etc/default/haproxy

This will allow seamless upgrades from the sysvinit system while respecting
any changes the users may have made. It will also make local configuration
easier than overriding the systemd unit file.

Note by Tim:

This GPL-2 licensed patch was taken from the Debian project at [1].

It was slightly modified to cleanly apply, because HAProxy's default unit
file does not include rsyslog.service as an 'After' dependency. Also the
subject line was modified to include the proper subsystem and severity.

This patch may be backported to 1.9.

[1] https://salsa.debian.org/haproxy-team/haproxy/blob/master/debian/patches/haproxy.service-use-environment-variables.patch

Co-authored-by: Tim Duesterhus <tim@bastelstu.be>
6 years agoBUG/MINOR: mworker/ssl: close OpenSSL FDs on reload
Rob Allen [Fri, 3 May 2019 08:11:32 +0000 (09:11 +0100)] 
BUG/MINOR: mworker/ssl: close OpenSSL FDs on reload

From OpenSSL 1.1.1, the default behaviour is to maintain open FDs to any
random devices that get used by the random number library. As a result,
those FDs leak when the master re-execs on reload; since those FDs are
not marked FD_CLOEXEC or O_CLOEXEC, they also get inherited by children.
Eventually both master and children run out of FDs.

OpenSSL 1.1.1 introduces a new function to control whether the random
devices are kept open. When clearing the keep-open flag, it also closes
any currently open FDs, so it can be used to clean-up open FDs too.
Therefore, a call to this function is made in mworker_reload prior to
re-exec.

The call is guarded by whether SSL is in use, because it will cause
initialisation of the OpenSSL random number library if that has not
already been done.

This should be backported to 1.9 and 1.8.

6 years agoREGTEST: Wrong assumption in IP:port logging test.
Frédéric Lécaille [Tue, 7 May 2019 10:00:36 +0000 (12:00 +0200)] 
REGTEST: Wrong assumption in IP:port logging test.

In this reg test, as the client connection is not supposed to receive any
server response, we should try to "rxresp" but we should expect the client
connection to be closed by haproxy. This is done replacing "rxresp" by
"expect_close". Furthermore since dbb75ee3 vtest commit, calling "rxresp"
expects at least to receive a HTTP header as shown by Travis build
here: https://travis-ci.com/haproxy/haproxy/jobs/198126488.

6 years agoREGTEST: Wrong renaming for one reg test.
Frédéric Lécaille [Tue, 7 May 2019 09:18:56 +0000 (11:18 +0200)] 
REGTEST: Wrong renaming for one reg test.

Fix a wrong reg test file renaming which came with d7a8f14 commit
(REGTEST: rename the reg test files). This prevented
reg-tests/log/wrong_ip_port_logging.vtc with "bug" as reg test type
from being run.

6 years agoREGTEST: Reg tests file renaming.
Frédéric Lécaille [Tue, 7 May 2019 09:14:29 +0000 (11:14 +0200)] 
REGTEST: Reg tests file renaming.

Remove old s_ prefixes for some reg tests after they have been flagged
as slow by 91704bfa commit (REGTEST: Flag some slow reg tests).

6 years agoREGTEST: Flag some slow reg tests.
Frédéric Lécaille [Tue, 7 May 2019 09:11:00 +0000 (11:11 +0200)] 
REGTEST: Flag some slow reg tests.

All reg-tests/peers/*basic_sync*.vtc tests are slow reg reg tests.

6 years agoBUG/MEDIUM: h2/htx: never leave a trailers block alone with no EOM block
Willy Tarreau [Tue, 7 May 2019 09:17:32 +0000 (11:17 +0200)] 
BUG/MEDIUM: h2/htx: never leave a trailers block alone with no EOM block

If when receiving an H2 response we fail to add an EOM block after too
large a trailers block, we must not leave the trailers block alone as it
violates the internal assumptions by not being followed by an EOM, even
when an error is reported. We must then make sure the error will safely
be reported to upper layers and that no attempt will be made to forward
partial blocks.

This must be backported to 1.9.

6 years agoBUG/MEDIUM: mux-h2/htx: never wait for EOM when processing trailers
Willy Tarreau [Mon, 6 May 2019 09:23:29 +0000 (11:23 +0200)] 
BUG/MEDIUM: mux-h2/htx: never wait for EOM when processing trailers

In message https://www.mail-archive.com/haproxy@formilux.org/msg33541.html
Patrick Hemmer reported an interesting bug affecting H2 and trailers.

The problem is that in order to close the stream we have to see the EOM
block, but nothing guarantees it will atomically be delivered with the
trailers block(s). So the code currently waits for it by returning zero
when it was not found, resulting in the caller (h2_snd_buf()) to loop
forever calling it again.

The current internal connection/connstream API doesn't allow a send
actor to notify its caller that it cannot process the data until it
gets more, so even returning zero will only lead to calls in loops
without any guarantee that any progress will be made.

Some late amendments to HTX already guaranteed the atomicity of the
trailers block during snd_buf(), which is currently ensured by the
fact that producers create exactly one such trailers block for all
trailers. So in practice we can only loop between trailers and EOM.

This patch changes the behaviour by making h2s_htx_make_trailers()
become atomic by not consuming the EOM block. This way either it finds
the end of trailers marker (empty line) or it fails. Once it sends the
trailers block, ES is set so the stream turns HLOC or CLOSED. Thanks
to previous patch "MEDIUM: mux-h2: discard contents that are to be sent
after a shutdown" is is now safe to interrupt outgoing data processing,
and the late EOM block will silently be discarded when the caller
finally sends it.

This is a bit tricky but should remain solid by design, and seems like
the only option we have that is compatible with 1.9, where it must be
backported along with the aforementioned patch.

6 years agoMEDIUM: mux-h2: discard contents that are to be sent after a shutdown
Willy Tarreau [Mon, 6 May 2019 13:00:22 +0000 (15:00 +0200)] 
MEDIUM: mux-h2: discard contents that are to be sent after a shutdown

In h2_snd_buf() we discard any possible buffer contents requested to be
sent after a close or an error. But in practice we can extend this to
any case where the stream is locally half-closed since it means we will
never be able to send these data anymore.

For now it must not change anything, but it will be used by subsequent
patches to discard lone a HTX EOM block arriving after the trailers
block.

6 years agoBUG/MEDIUM: h2/htx: always fail on too large trailers
Willy Tarreau [Mon, 6 May 2019 09:12:18 +0000 (11:12 +0200)] 
BUG/MEDIUM: h2/htx: always fail on too large trailers

In case a header frame carrying trailers just fits into the HTX buffer
but leaves no room for the EOM block, we used to return the same code
as the one indicating we're missing data. This could would result in
such frames causing timeouts instead of immediate clean aborts. Now
they are properly reported as stream errors (since the frame was
decoded and the compression context is still synchronized).

This must be backported to 1.9.

6 years agoBUG/MINOR: mux-h2: rely on trailers output not input to turn them to empty data
Willy Tarreau [Mon, 6 May 2019 13:13:41 +0000 (15:13 +0200)] 
BUG/MINOR: mux-h2: rely on trailers output not input to turn them to empty data

When sending trailers, we may face an empty HTX trailers block or even
have to discard some of the headers there and be left with nothing to
send. RFC7540 forbids sending of empty HEADERS frames, so in this case
we turn to DATA frames (which is possible since after other DATA).

The code used to only check the input frame's contents to decide whether
or not to switch to a DATA frame, it didn't consider the possibility that
the frame only used to contain headers discarded later, thus it could still
emit an empty HEADERS frame in such a case. This patch makes sure that the
output frame size is checked instead to take the decision.

This patch must be backported to 1.9. In practice this situation is never
encountered since the discarded headers have really nothing to do in a
trailers block.

6 years agoREGTEST: make the "table in peers" test require v2.0
Willy Tarreau [Tue, 7 May 2019 05:53:54 +0000 (07:53 +0200)] 
REGTEST: make the "table in peers" test require v2.0

And the second test also requires openssl otherwise it fails as seen
here : https://travis-ci.com/haproxy/haproxy/jobs/198126488

6 years agoREGTEST: make the tls_health_checks test much faster
Willy Tarreau [Tue, 7 May 2019 05:26:08 +0000 (07:26 +0200)] 
REGTEST: make the tls_health_checks test much faster

This test relies on a server timeout and was using the default 2s check
interval with a full 1s server timeout, thus adding a whole second to the
test series by itself. Let's shrink the server timeout to 20ms which is
way enough to properly trigger a timeout, and set the check interval to
the double of this, or 40ms.

6 years agoMEDIUM: regex: modify regex_comp() to atomically allocate/free the my_regex struct
Dragan Dosen [Tue, 30 Apr 2019 13:54:36 +0000 (15:54 +0200)] 
MEDIUM: regex: modify regex_comp() to atomically allocate/free the my_regex struct

Now we atomically allocate the my_regex struct within function
regex_comp() and compile the regex or free both in case of failure. The
pointer to the allocated my_regex struct is returned directly. The
my_regex* argument to regex_comp() is removed.

Function regex_free() was modified so that it systematically frees the
my_regex entry. The function does nothing when called with a NULL as
argument (like free()). It will avoid existing risk of not properly
freeing the initialized area.

Other structures are also updated in order to be compatible (the ones
related to Lua and action rules).

6 years agoREGTEST: Add reg tests for "table" lines in "peers" sections.
Frédéric Lécaille [Mon, 18 Mar 2019 13:08:46 +0000 (14:08 +0100)] 
REGTEST: Add reg tests for "table" lines in "peers" sections.

These reg tests are there to test the support for stick-table declarations
in "peers" sections ("table" keyword).

6 years agoDOC: Update for "table" lines in "peers" section.
Frédéric Lécaille [Mon, 18 Mar 2019 13:05:58 +0000 (14:05 +0100)] 
DOC: Update for "table" lines in "peers" section.

6 years agoMINOR: peers: Do not emit global stick-table names.
Frédéric Lécaille [Wed, 20 Mar 2019 14:09:45 +0000 (15:09 +0100)] 
MINOR: peers: Do not emit global stick-table names.

This commit "MINOR: stick-table: Add prefixes to stick-table names"
prepended the "peers" section name to stick-table names declared in such "peers"
sections followed by a '/' character.  This is not this name which must be sent
over the network to avoid collisions with stick-table name declared as backends.
As the '/' character is forbidden as first character of a backend name, we prefix
the stick-table names declared in peers sections only with a '/' character.
With such declarations:

    peers mypeers
       table t1

backend t1
   stick-table ... peers mypeers

at peer protocol level, "t1" declared as stick-table in "mypeers" section is different
of "t1" stick-table declared as backend.

In src/peers.c, only two modifications were required: use ->nid stktable struct
member in place of ->id in peer_prepare_switchmsg() to prepare the stick-table
definition messages. Same thing in peer_treat_definemsg() to treat a stick-table
definition messages.

6 years agoMINOR: stick-table: Add prefixes to stick-table names.
Frédéric Lécaille [Wed, 20 Mar 2019 14:06:55 +0000 (15:06 +0100)] 
MINOR: stick-table: Add prefixes to stick-table names.

With this patch we add a prefix to stick-table names declared in "peers" sections
concatenating the "peers" section name followed by a '/' character with
the stick-table name. Consequently, "peers" sections have their own
namespace for their stick-tables. Obviously, these stick-table names are not the
ones which should be sent over the network. So these configurations must be
compatible and should make A and B peers communicate with peers protocol:

    # haproxy A config, old way stick-table declerations
    peers mypeers
        peer A ...
        peer B ...

    backend t1
        stick-table type string size 10m store gpc0 peers mypeers

    # haproxy B config, new way stick-table declerations
    peers mypeers
        peer A ...
        peer B ...
        table t1 type string size store gpc0 10m

This "network" name is stored in ->nid new field of stktable struct. The "local"
stktable-name is still stored in ->id.

6 years agoMINOR: stick-tables: Add peers process binding computing.
Frédéric Lécaille [Tue, 19 Mar 2019 13:55:01 +0000 (14:55 +0100)] 
MINOR: stick-tables: Add peers process binding computing.

Add a list of proxies for all the stick-tables (->proxies_list struct stktable
member) so that to be able to compute the process bindings of the peers after having
parsed the configuration file.
The proxies are added to the stick-tables they reference when parsing
stick-tables lines in proxy sections, when checking the actions in
check_trk_action() and when resolving samples args for stick-tables
without checking is they are duplicates. We check only there is no loop.
Then, after having parsed everything, we add the proxy bindings to the
peers frontend bindings with stick-tables they reference.

6 years agoMEDIUM: stick-table: Stop handling stick-tables as proxies.
Frédéric Lécaille [Thu, 14 Mar 2019 06:07:41 +0000 (07:07 +0100)] 
MEDIUM: stick-table: Stop handling stick-tables as proxies.

This patch adds the support for the "table" line parsing in "peers" sections
to declare stick-table in such sections. This also prevents the user from having
to declare dummy backends sections with a unique stick-table inside.
Even if still supported, this usage will become deprecated.

To do so, the ->table member of proxy struct which is a stktable struct is replaced
by a pointer to a stktable struct allocated at parsing time in src/cfgparse-listen.c
for the dummy stick-table backends and in src/cfgparse.c for "peers" sections.
This has an impact on the code for stick-table sample converters and on the stickiness
rules parsers which first store the name of the dummy before resolving the rules.
This patch replaces proxy_tbl_by_name() calls by stktable_find_by_name() calls
to lookup for stick-tables stored in "stktable_by_name" ebtree at parsing time.
There is only one remaining place where proxy_tbl_by_name() is used: src/hlua.c.

At several places in the code we relied on the fact that ->size member of stick-table
was equal to zero to consider the stick-table was present by not configured,
this do not make sense anymore as ->table member of struct proxyis fow now on a pointer.
These tests are replaced by a test on ->table value itself.

In "peers" section we do not have to temporary store the name of the section the
stick-table are attached to because this name is obviously already known just after
having entered this "peers" section.

About the CLI stick-table I/O handler, the pointer to proxy struct is replaced by
a pointer to a stktable struct.

6 years agoBUILD/MINOR: stick-table: Compilation fix.
Frédéric Lécaille [Fri, 15 Mar 2019 10:24:53 +0000 (11:24 +0100)] 
BUILD/MINOR: stick-table: Compilation fix.

Missing header to dereference struct peers pointer from struct table.

6 years agoMINOR: config: Extract the code of "stick-table" line parsing.
Frédéric Lécaille [Fri, 8 Mar 2019 13:47:00 +0000 (14:47 +0100)] 
MINOR: config: Extract the code of "stick-table" line parsing.

With this patch we move the code responsible of parsing "stick-table"
lines to implement parse_stick_table() function in src/stick-tabble.c
so that to be able to parse "stick-table" elsewhere than in proxy sections.
We have have also added a conf struct to stktable struct to store the filename
and the line in the file the stick-table has been parsed to help in
diagnosing and displaying any configuration issue.

6 years agoMEDIUM: tcp: add the "tfo" option to support TCP fastopen on the server
Willy Tarreau [Mon, 23 Jan 2017 22:36:45 +0000 (23:36 +0100)] 
MEDIUM: tcp: add the "tfo" option to support TCP fastopen on the server

This implements support for the new API which relies on a call to
setsockopt().
On systems that support it (currently, only Linux >= 4.11), this enables
using TCP fast open when connecting to server.
Please note that you should use the retry-on "conn-failure", "empty-response"
and "response-timeout" keywords, or the request won't be able to be retried
on failure.

Co-authored-by: Olivier Houchard <ohouchard@haproxy.com>
6 years agoMEDIUM: proto: Change the prototype of the connect() method.
Olivier Houchard [Mon, 6 May 2019 16:32:29 +0000 (18:32 +0200)] 
MEDIUM: proto: Change the prototype of the connect() method.

The connect() method had 2 arguments, "data", that tells if there's pending
data to be sent, and "delack" that tells if we have to use a delayed ack
inconditionally, or if the backend is configured with tcp-smart-connect.
Turn that into one argument, "flags".
That way it'll be easier to provide more informations to connect() without
adding extra arguments.

6 years agoMINOR: doc: Document the interaction of allow-0rtt and retry-on 0rtt-rejected.
Olivier Houchard [Mon, 6 May 2019 17:01:04 +0000 (19:01 +0200)] 
MINOR: doc: Document the interaction of allow-0rtt and retry-on 0rtt-rejected.

Document that haproxy will try to use early data when connecting to the
server if we have retry-on 0rtt-rejected, as well.

6 years agoMINOR: doc: Document allow-0rtt on the server line.
Olivier Houchard [Mon, 6 May 2019 16:58:48 +0000 (18:58 +0200)] 
MINOR: doc: Document allow-0rtt on the server line.

Briefly document allow-0rtt on the server line, and only the part that apply
to 1.8 and 1.9.

This should be backported to 1.8 and 1.9.

6 years agoBUG/MEDIUM: ssl: Don't attempt to use early data with libressl.
Olivier Houchard [Mon, 6 May 2019 13:18:27 +0000 (15:18 +0200)] 
BUG/MEDIUM: ssl: Don't attempt to use early data with libressl.

Libressl doesn't yet provide early data, so don't put the CO_FL_EARLY_SSL_HS
on the connection if we're building with libressl, or the handshake will
never be done.

6 years agoBUILD: travis: TMPDIR replacement.
Frédéric Lécaille [Fri, 3 May 2019 17:16:02 +0000 (19:16 +0200)] 
BUILD: travis: TMPDIR replacement.

TMPDIR default value may be too long to create UNIX sockets for the stats
used during the reg tests. Indeed vtest builds its temporary working directory
${tmpdir} variable from TMPDIR variable, with /tmp as value if not already set.
This is the case on Linux contrary to OS X which sets TMPDIR with a too much long
value.

With this path we revert the part of 88c63a6 commit which tried to shorten this
TMPDIR value modifying script/run-regtests.sh. Unfortunately this was not
sufficient. Furthermore this patch force TMPDIR to /tmp value for all the OS'es.

Thank you to Tim Düsterhus and Ilya for having helped on this issue.

6 years agoBUILD: temporarily mark LibreSSL builds as allowed to fail
Ilya Shipitsin [Sun, 5 May 2019 19:36:21 +0000 (00:36 +0500)] 
BUILD: temporarily mark LibreSSL builds as allowed to fail

6 years agoBUILD: enable several LibreSSL hacks, including
Ilya Shipitsin [Sun, 5 May 2019 18:27:54 +0000 (23:27 +0500)] 
BUILD: enable several LibreSSL hacks, including

SSL_SESSION_get0_id_context is introduced in LibreSSL-2.7.0
async operations are not supported by LibreSSL
early data is not supported by LibreSSL
packet_length is removed from SSL struct in LibreSSL

6 years agoBUILD: travis-ci: get back to osx without openssl support
Ilya Shipitsin [Sun, 5 May 2019 12:43:37 +0000 (17:43 +0500)] 
BUILD: travis-ci: get back to osx without openssl support

there's some issue with socket path, after it is resolved,
we will enable openssl for osx

6 years agoBUILD: remove "build_libressl" duplicate declaration
Ilya Shipitsin [Sun, 5 May 2019 12:41:12 +0000 (17:41 +0500)] 
BUILD: remove "build_libressl" duplicate declaration

6 years agoDOC: Fix typo in keyword matrix
Tim Duesterhus [Sun, 5 May 2019 23:19:53 +0000 (01:19 +0200)] 
DOC: Fix typo in keyword matrix

It should read 'deprecated' instead of 'deprectated'.

6 years agoCLEANUP: Remove appsession documentation
Tim Duesterhus [Sun, 5 May 2019 23:19:52 +0000 (01:19 +0200)] 
CLEANUP: Remove appsession documentation

I was about to partly revert 294d0f08b3d100fcae0e71c26d4f9f93d26e3569,
because there were no 'X' for 'appsession' in the keyword matrix until
I checked the blame, realizing that the feature does not exist any more.

Clearly the documentation is confusing here, the removal note is only
listed *below* the old documentation and the supported sections still
show 'backend' and 'listen'.

It's been 3.5 years and 4 releases (1.6, 1.7, 1.8 and 1.9), I guess
this can be removed from the documentation of future versions.

6 years agoBUILD: extend travis-ci matrix
Ilya Shipitsin [Fri, 3 May 2019 09:31:20 +0000 (14:31 +0500)] 
BUILD: extend travis-ci matrix

added openssl-1.0.2, 1.1.0, 1.1.1, libressl-2.7.5, 2.8.3, 2.9.1
added linux-ppc64le image

6 years agoBUG/MINOR: logs/threads: properly split the log area upon startup
Willy Tarreau [Sun, 5 May 2019 08:11:39 +0000 (10:11 +0200)] 
BUG/MINOR: logs/threads: properly split the log area upon startup

If logs were emitted before creating the threads, then the dataptr pointer
keeps a copy of the end of the log header. Then after the threads are
created, the headers are reallocated for each thread. However the end
pointer was not reset until the end of the first second, which may result
in logs emitted by multiple threads during the first second to be mangled,
or possibly in some cases to use a memory area that was reused for something
else. The fix simply consists in reinitializing the end pointers immediately
when the threads are created.

This fix must be backported to 1.9 and 1.8.

6 years agoBUG/MEDIUM: checks: make sure the warmup task takes the server lock
Willy Tarreau [Sun, 5 May 2019 04:54:22 +0000 (06:54 +0200)] 
BUG/MEDIUM: checks: make sure the warmup task takes the server lock

The server warmup task is used when a server uses the "slowstart"
parameter. This task affects the server's weight and maxconn, and may
dequeue pending connections from the queue. This must be done under
the server's lock, which was not the case.

This must be backported to 1.9 and 1.8.

6 years agoBUG/MINOR: stream: also increment the retry stats counter on L7 retries
Willy Tarreau [Sat, 4 May 2019 08:38:31 +0000 (10:38 +0200)] 
BUG/MINOR: stream: also increment the retry stats counter on L7 retries

It happens that the retries stats use their own counter and are not
derived from the stream interface, so we need to update it as well
when performing an L7 retry.

No backport is needed.

6 years agoMEDIUM: streams: Add a new keyword for retry-on, "junk-response"
Olivier Houchard [Fri, 3 May 2019 21:01:47 +0000 (23:01 +0200)] 
MEDIUM: streams: Add a new keyword for retry-on, "junk-response"

Add a way to retry requests if we got a junk response from the server, ie
an incomplete response, or something that is not valid HTTP.
To do so, one can use the new "junk-response" keyword for retry-on.

6 years agoMEDIUM: streams: Add a way to replay failed 0rtt requests.
Olivier Houchard [Fri, 3 May 2019 20:46:27 +0000 (22:46 +0200)] 
MEDIUM: streams: Add a way to replay failed 0rtt requests.

Add a new keyword for retry-on, 0rtt-rejected. If set, we will try to
replay requests for which we sent early data that got rejected by the
server.
If that option is set, we will attempt to use 0rtt if "allow-0rtt" is set
on the server line even if the client didn't send early data.

6 years agoMEDIUM: streams: Add the ability to retry a request on L7 failure.
Olivier Houchard [Fri, 5 Apr 2019 13:30:12 +0000 (15:30 +0200)] 
MEDIUM: streams: Add the ability to retry a request on L7 failure.

When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.

To do so, add a new backend keyword, "retry-on".

It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".

The default is "conn-failure".

6 years agoBUG/MEDIUM: streams: Don't add CF_WRITE_ERROR if early data were rejected.
Olivier Houchard [Fri, 3 May 2019 20:21:24 +0000 (22:21 +0200)] 
BUG/MEDIUM: streams: Don't add CF_WRITE_ERROR if early data were rejected.

In sess_update_st_con_tcp(), if we have an error on the stream_interface
because we tried to send early_data but failed, don't flag the request
channel as CF_WRITE_ERROR, or we will never reach the analyser that sends
back the 425 response.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: ssl: Use the early_data API the right way.
Olivier Houchard [Fri, 3 May 2019 18:56:19 +0000 (20:56 +0200)] 
BUG/MEDIUM: ssl: Use the early_data API the right way.

We can only read early data if we're a server, and write if we're a client,
so don't attempt to mix both.

This should be backported to 1.8 and 1.9.

6 years agoMINOR: init/threads: make the threads array global
Willy Tarreau [Fri, 3 May 2019 07:22:44 +0000 (09:22 +0200)] 
MINOR: init/threads: make the threads array global

Currently the thread array is a local variable inside a function block
and there is no access to it from outside, which often complicates
debugging. Let's make it global and export it. Also the allocation
return is now checked.

6 years agoMINOR: init/threads: remove the useless tids[] array
Willy Tarreau [Fri, 3 May 2019 07:27:30 +0000 (09:27 +0200)] 
MINOR: init/threads: remove the useless tids[] array

It's still obscure how we managed to initialize an array of integers
with values always equal to the index, just to retrieve the value
from an opaque pointer to the index instead of directly using it! I
suspect it's a leftover from the very early threading experiments.

This commit gets rid of this and simply passes the thread ID as the
argument to run_thread_poll_loop(), thus significantly simplifying the
few call places and removing the need to allocate then free an array
of identity.

6 years agoMINOR: threads: flatten the per-thread cpu-map
Willy Tarreau [Fri, 3 May 2019 07:41:23 +0000 (09:41 +0200)] 
MINOR: threads: flatten the per-thread cpu-map

When we initially experimented with threads and processes support, we
needed to implement arrays of threads per process for cpu-map, but this
is not needed anymore since we support either threads or processes.
Let's simply make the thread-based cpu-map per thread and not per
thread and per process since that's not used anymore. Doing so reduces
the global struct from 33kB to 1.5kB.

6 years agoBUG/MEDIUM: connections: Make sure we remove CO_FL_SESS_IDLE on disown.
Olivier Houchard [Thu, 2 May 2019 10:04:15 +0000 (12:04 +0200)] 
BUG/MEDIUM: connections: Make sure we remove CO_FL_SESS_IDLE on disown.

When for some reason the session is not the owner of the connection anymore,
make sure we remove CO_FL_SESS_IDLE, even if we're about to call
conn->mux->destroy(), as the destroy may not destroy the connection
immediately if it's still in use.
This should be backported to 1.9.
u

6 years agoBUG/MEDIUM: channels: Don't forget to reset output in channel_erase().
Olivier Houchard [Wed, 1 May 2019 22:58:53 +0000 (00:58 +0200)] 
BUG/MEDIUM: channels: Don't forget to reset output in channel_erase().

In channel_erase(), don't forget to set output to 0, otherwise the
channel won't seem empty, when it really is, and that could lead to
stream never closing properly.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: pattern: fix memory leak in regex pattern functions
Dragan Dosen [Mon, 29 Apr 2019 23:03:26 +0000 (01:03 +0200)] 
BUG/MEDIUM: pattern: fix memory leak in regex pattern functions

The allocated regex is not freed properly and can cause a memory leak,
eg. when patterns are updated via CLI socket.

This patch should be backported to all supported versions.

6 years agoBUG/MINOR: checks: free memory allocated for tasklets
Dragan Dosen [Mon, 29 Apr 2019 22:56:20 +0000 (00:56 +0200)] 
BUG/MINOR: checks: free memory allocated for tasklets

The check->wait_list.task and agent->wait_list.task were not
freed properly on deinit().

This patch should be backported to 1.9.

6 years agoBUG/MINOR: log: properly free memory on logformat parse error and deinit()
Dragan Dosen [Mon, 29 Apr 2019 22:40:02 +0000 (00:40 +0200)] 
BUG/MINOR: log: properly free memory on logformat parse error and deinit()

This patch may be backported to all supported versions.

6 years agoBUG/MINOR: haproxy: fix rule->file memory leak
Dragan Dosen [Mon, 29 Apr 2019 22:38:36 +0000 (00:38 +0200)] 
BUG/MINOR: haproxy: fix rule->file memory leak

When using the "use_backend" configuration directive, the configuration
file name stored as rule->file was not freed in some situations. This
was introduced in commit 4ed1c95 ("MINOR: http/conf: store the
use_backend configuration file and line for logs").

This patch should be backported to 1.9, 1.8 and 1.7.

6 years agoBUG/MEDIUM: ssl: Don't pretend we can retry a recv/send if we got a shutr/w.
Olivier Houchard [Wed, 1 May 2019 15:24:36 +0000 (17:24 +0200)] 
BUG/MEDIUM: ssl: Don't pretend we can retry a recv/send if we got a shutr/w.

In ha_ssl_write() and ha_ssl_read(), don't pretend we can retry a read/write
if we got a shutr/shutw, or we will never properly shutdown the connection.

6 years agoBUG/MEDIUM: servers: fix typo "src" instead of "srv"
Ilya Shipitsin [Tue, 30 Apr 2019 16:21:28 +0000 (21:21 +0500)] 
BUG/MEDIUM: servers: fix typo "src" instead of "srv"

When copying the settings for all servers when using server templates,
fix a typo, or we would never copy the length of the ALPN to be used for
checks.

This should be backported to 1.9.

6 years agoCLEANUP: config: Don't alter listener->maxaccept when nbproc is set to 1
Christopher Faulet [Tue, 30 Apr 2019 12:08:41 +0000 (14:08 +0200)] 
CLEANUP: config: Don't alter listener->maxaccept when nbproc is set to 1

This patch only removes a useless calculation on listener->maxaccept when nbproc
is set to 1. Indeed, the following formula has no effet in such case:

  listener->maxaccept = (listener->maxaccept + nbproc - 1) / nbproc;

This patch may be backported as far as 1.5.

6 years agoMINOR: config: Test validity of tune.maxaccept during the config parsing
Christopher Faulet [Tue, 30 Apr 2019 12:03:56 +0000 (14:03 +0200)] 
MINOR: config: Test validity of tune.maxaccept during the config parsing

Only -1 and positive integers from 0 to INT_MAX are accepted. An error is
triggered during the config parsing for any other values.

This patch may be backported to all supported versions.

6 years agoBUG/MEDIUM: listener: Fix how unlimited number of consecutive accepts is handled
Christopher Faulet [Tue, 30 Apr 2019 10:17:13 +0000 (12:17 +0200)] 
BUG/MEDIUM: listener: Fix how unlimited number of consecutive accepts is handled

There is a bug when global.tune.maxaccept is set to -1 (no limit). It is pretty
visible with one process (nbproc sets to 1). The functions listener_accept() and
accept_queue_process() don't expect to handle negative maxaccept values. So
instead of accepting incoming connections without any limit, none are never
accepted and HAProxy loop infinitly in the scheduler.

When there are 2 or more processes, the bug is a bit more subtile. The limit for
a listener is set to 1. So only one connection is accepted at a time by a given
listener. This happens because the listener's maxaccept value is an unsigned
integer. In check_config_validity(), it is first set to UINT_MAX (-1 casted in
an unsigned integer), and then some calculations on it leads to an integer
overflow.

To fix the bug, the listener's maxaccept value is now a signed integer. So, if a
negative value is set for global.tune.maxaccept, we keep it untouched for the
listener and no calculation is made on it. Then, in the listener code, this
signed value is casted to a unsigned one. It simplifies all tests instead of
dealing with negative values. So, it limits the number of connections accepted
at a time to UINT_MAX at most. But, honestly, it not an issue.

This patch must be backported to 1.9 and 1.8.

6 years agoBUG/MEDIUM: port_range: Make the ring buffer lock-free.
Olivier Houchard [Mon, 29 Apr 2019 16:52:06 +0000 (18:52 +0200)] 
BUG/MEDIUM: port_range: Make the ring buffer lock-free.

Port range uses a ring buffer, and unfortunately, when making haproxy
multithreaded, it's been overlooked, and the ring buffer is not thread-safe.
When specifying a source range, 2 or more threads could pick the same
port, and of course only one of them could use the port, the others would
always fail the connection.
To fix this, make it a lock-free ring buffer. This is easier than usual
because we know the ring buffer can never be full.

This should be backported to 1.8 and 1.9.

6 years agoMINOR: threads: Implement HA_ATOMIC_LOAD().
Olivier Houchard [Tue, 30 Apr 2019 11:38:02 +0000 (13:38 +0200)] 
MINOR: threads: Implement HA_ATOMIC_LOAD().

The same way we have HA_ATOMIC_STORE(), implement HA_ATOMIC_LOAD().

This should be backported to 1.8 and 1.9, as we need it for a bug fix
in port ranges.

6 years agoMINOR: activity: report context switch counts instead of rates
Willy Tarreau [Tue, 30 Apr 2019 12:55:18 +0000 (14:55 +0200)] 
MINOR: activity: report context switch counts instead of rates

It's not logical to report context switch rates per thread in show activity
because everything else is a counter and it's not even possible to compare
values. Let's only report counts. Further, this simplifies the scheduler's
code.

6 years agoCLEANUP: task: move the task_per_thread definition to task.h
Willy Tarreau [Tue, 30 Apr 2019 12:36:47 +0000 (14:36 +0200)] 
CLEANUP: task: move the task_per_thread definition to task.h

It's the second time I look for it and can't find it because it's not
in the right file.

6 years agoREGTEST: Make this reg test be Linux specific.
Frédéric Lécaille [Mon, 29 Apr 2019 14:10:12 +0000 (16:10 +0200)] 
REGTEST: Make this reg test be Linux specific.

This patch reverts 9ffb88 commit (REGTEST: Be less Linux specific with a syslog
regex.) and makes this script be Linux specific.

6 years agoBUG/MAJOR: map/acl: real fix segfault during show map/acl on CLI
Willy Tarreau [Tue, 30 Apr 2019 09:43:43 +0000 (11:43 +0200)] 
BUG/MAJOR: map/acl: real fix segfault during show map/acl on CLI

A previous commit 8d85aa44d ("BUG/MAJOR: map: fix segfault during
'show map/acl' on cli.") was provided to address a concurrency issue
between "show acl" and "clear acl" on the CLI. Sadly the code placed
there was copy-pasted without changing the element type (which was
struct stream in the original code) and not tested since the crash
is still present.

The reproducer is simple : load a large ACL file (e.g. geolocation
addresses), issue "show acl #0" in loops in one window and issue a
"clear acl #0" in the other one, haproxy crashes.

This fix was also tested with threads enabled and looks good since
the locking seems to work correctly in these areas though. It will
have to be backported as far as 1.6 since the commit above went
that far as well...

6 years agoREGTEST: Add a new reg test for log load-balancing feature.
Frédéric Lécaille [Thu, 25 Apr 2019 18:14:43 +0000 (20:14 +0200)] 
REGTEST: Add a new reg test for log load-balancing feature.

This is a reg test for the log load-balancing feature implemented by
these commits:
  MINOR: log: Add "sample" new keyword to "log" lines
  MINOR: log: Enable the log sampling and load-balancing feature

The size of the logging buffer for vtest has been doubled to support this script.

6 years agoDOC: log: Document the sampling and load-balancing logging feature.
Frédéric Lécaille [Thu, 25 Apr 2019 08:52:17 +0000 (10:52 +0200)] 
DOC: log: Document the sampling and load-balancing logging feature.

This document should come with these commits:
  'MINOR: log: Enable the log sampling and load-balancing feature'
  'MINOR: log: Add "sample" new keyword to "log" lines.'

6 years agoMINOR: log: Enable the log sampling and load-balancing feature.
Frédéric Lécaille [Thu, 25 Apr 2019 05:42:09 +0000 (07:42 +0200)] 
MINOR: log: Enable the log sampling and load-balancing feature.

This patch implements the sampling and load-balancing of log servers configured
with "sample" new keyword implemented by this commit:
    'MINOR: log: Add "sample" new keyword to "log" lines'.
As the list of ranges used to sample the log to balance is ordered, we only
have to maintain ->curr_idx member of smp_info struct which is the index of
the sample and check if it belongs or not to the current range to decide if we
must send it to the log server or not.

6 years agoMINOR: log: Add "sample" new keyword to "log" lines.
Frédéric Lécaille [Wed, 24 Apr 2019 14:14:33 +0000 (16:14 +0200)] 
MINOR: log: Add "sample" new keyword to "log" lines.

This patch implements the parsing of "sample" new optional keyword for "log" lines
to be able to sample and balance the load of log messages between serveral log
destinations declared by "log" lines. This keyword must be followed by a list of
comma seperated ranges of indexes numbered from 1 to define the samples to be used
to balance the load of logs to send. This "sample" keyword must be used on "log" lines
obviously before the remaining optional ones without keyword. The list of ranges
must be followed by a colon character to separate it from the log sampling size.

With such following configuration declarations:

   log stderr local0
   log 127.0.0.1:10001 sample 2-3,8-11:11 local0
   log 127.0.0.2:10002 sample 5:5 local0

in addition to being sent to stderr, about the second "log" line, every 11 logs
the logs #2 up to #3 would be sent to 127.0.0.1:10001, then #8 up tp #11 four
logs would be sent to the same log server and so on periodically. Logs would be
sent to 127.0.0.2:100002 every 5 logs.

It is also possible to define the size of the sample with a value different of
the maximum of the high limits of the ranges, for instance as follows:

   log 127.0.0.1:10001 sample 2-3,8-11:15 local0

as before the two logs #2 and #3 would be sent to 127.0.0.1:10001, then #8
up tp #11 logs, but in this case here, this would be done periodically every 15
messages.

Also note that the ranges must not overlap each others. This is to ease the
way the logs are periodically sent.

6 years agoBUG/MEDIUM: contrib/modsecurity: If host header is NULL, don't try to strdup it
Yann Cézard [Thu, 25 Apr 2019 12:30:23 +0000 (14:30 +0200)] 
BUG/MEDIUM: contrib/modsecurity: If host header is NULL, don't try to strdup it

I discovered this bug when running OWASP regression tests against HAProxy +
modsecurity-spoa (it's a POC to evaluate how it is working).  I found out that
modsecurity spoa will crash when the request doesn't have any Host header.

See the pull request #86 on github for details.

This patch must be backported to 1.9 and 1.8.

6 years agoDOC: contrib/modsecurity: Typos and fix the reject example
Yann Cézard [Thu, 25 Apr 2019 12:48:38 +0000 (14:48 +0200)] 
DOC: contrib/modsecurity: Typos and fix the reject example

Thanks to https://www.mail-archive.com/haproxy@formilux.org/msg30056.html

This patch may be backported to 1.9 and 1.8.

6 years agoMINOR: spoe: Use the sample context to pass frag_ctx info during encoding
Christopher Faulet [Fri, 26 Apr 2019 12:30:15 +0000 (14:30 +0200)] 
MINOR: spoe: Use the sample context to pass frag_ctx info during encoding

This simplifies the API and hide the details in the sample. This way, only
string and binary are aware of these info, because other types cannot be
partially encoded.

This patch may be backported to 1.9 and 1.8.

6 years agoBUG/MEDIUM: spoe: arg len encoded in previous frag frame but len changed
Kevin Zhu [Fri, 26 Apr 2019 06:00:01 +0000 (14:00 +0800)] 
BUG/MEDIUM: spoe: arg len encoded in previous frag frame but len changed

Fragmented arg will do fetch at every encode time, each fetch may get
different result if SMP_F_MAY_CHANGE, for example res.payload, but
the length already encoded in first fragment of the frame, that will
cause SPOA decode failed and waste resources.

This patch must be backported to 1.9 and 1.8.

6 years agoBUG/MINOR: http: Call stream_inc_be_http_req_ctr() only one time per request
Christopher Faulet [Mon, 29 Apr 2019 11:12:02 +0000 (13:12 +0200)] 
BUG/MINOR: http: Call stream_inc_be_http_req_ctr() only one time per request

The function stream_inc_be_http_req_ctr() is called at the beginning of the
analysers AN_REQ_HTTP_PROCESS_FE/BE. It as an effect only on the backend. But we
must be careful to call it only once. If the processing of HTTP rules is
interrupted in the middle, when the analyser is resumed, we must not call it
again. Otherwise, the tracked counters of the backend are incremented several
times.

This bug was reported in github. See issue #74.

This fix should be backported as far as 1.6.