]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
6 years agoBUG/MEDIUM: h2: Don't attempt to recv from h2_process_demux if we subscribed.
Olivier Houchard [Fri, 5 Apr 2019 13:34:34 +0000 (15:34 +0200)] 
BUG/MEDIUM: h2: Don't attempt to recv from h2_process_demux if we subscribed.

Modify h2c_restart_reading() to add a new parameter, to let it know if it
should consider if the buffer isn't empty when retrying to read or not, and
call h2c_restart_reading() using 0 as a parameter from h2_process_demux().
If we're leaving h2_process_demux() with a non-empty buffer, it means the
frame is incomplete, and we're waiting for more data, and if we already
subscribed, we'll be waken when more data are available.
Failing to do so means we'll be waken up in a loop until more data are
available.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: peers: fix a case where peer session is not cleanly reset on release.
Emeric Brun [Tue, 2 Apr 2019 15:22:01 +0000 (17:22 +0200)] 
BUG/MEDIUM: peers: fix a case where peer session is not cleanly reset on release.

The deinit took place in only peer_session_release, but in the a case of a
previous call to peer_session_forceshutdown, the session cursors
won't be reset, resulting in a bad state for new session of the same
peer. For instance, a table definition message could be dropped and
so all update messages will be dropped by the remote peer.

This patch move the deinit processing directly in the force shutdown
funtion. Killed session remains in "ST_END" state but ref on peer was
reset to NULL and deinit will be skipped on session release function.

The session release continue to assure the deinit for "active" sessions.

This patch should be backported on all stable version since proto
peers v2.

6 years agoREGTEST: lua/b00003: Specify the HAProxy pid when the command ss is executed
Christopher Faulet [Mon, 1 Apr 2019 13:39:50 +0000 (15:39 +0200)] 
REGTEST: lua/b00003: Specify the HAProxy pid when the command ss is executed

This avoids confusions with any other haproxy process.

6 years agoREGTEST: lua/b00003: Relax the regex matching the log message
Christopher Faulet [Mon, 1 Apr 2019 09:17:40 +0000 (11:17 +0200)] 
REGTEST: lua/b00003: Relax the regex matching the log message

The timeer TR may be greater than 10ms, making the test fails.

6 years agoREGTEST: log/b00000: Be sure the client always hits its timeout
Christopher Faulet [Mon, 1 Apr 2019 13:33:19 +0000 (15:33 +0200)] 
REGTEST: log/b00000: Be sure the client always hits its timeout

To do so, the server does not send anything. Instead it waits 2ms before
closing. The client, on its side, will wait for a response. So it will be
blocked. Becauase the client timeout is set to 1ms, HAProxy should always close
the client connection because it times out.

6 years agoREGTEST: http-rules/h00003: Use a different client for requests expecting a 301
Christopher Faulet [Mon, 1 Apr 2019 09:21:57 +0000 (11:21 +0200)] 
REGTEST: http-rules/h00003: Use a different client for requests expecting a 301

Because HAProxy may decide to close 301 responses, as others internal responses,
it is safer to use a different client for these requests. This is not the
purpose of this test to verify the keep-alive in such cases.

6 years agoREGTEST: http-messaging/h00000: Fix the test when the HTX is enabled
Christopher Faulet [Mon, 1 Apr 2019 09:26:25 +0000 (11:26 +0200)] 
REGTEST: http-messaging/h00000: Fix the test when the HTX is enabled

The way unexpected bodies are handled for responses to HEAD requests differs from
the legacy HTTP to the HTX. While it is dropped wih the legacy HTTP, in HTX, it
is parsed as the response to the next request. So, in HTX, a 502 error is
returned to the client and the connexion is closed.

This test has been modified to pass in both mode.

6 years agoREGTEST: http-capture/h00000: Relax a regex matching the log message
Christopher Faulet [Thu, 28 Mar 2019 17:30:42 +0000 (18:30 +0100)] 
REGTEST: http-capture/h00000: Relax a regex matching the log message

Size reported in logs may differ between legacy HTTP and HTX, at least for
now. So in the regtest http-capture/h00000.vtc, we need to relax the regex
matching the log message.

6 years agoBUG/MINOR: proto_htx: Reset to_forward value when a message is set to DONE
Christopher Faulet [Thu, 28 Mar 2019 17:12:46 +0000 (18:12 +0100)] 
BUG/MINOR: proto_htx: Reset to_forward value when a message is set to DONE

Because we try to forward infinitly message body, when its state is set to DONE,
we must be sure to reset to_foward value of the corresponding
channel. Otherwise, some errors can be errornously triggered.

No need to backport this patch.

6 years agoBUG/MINOR: htx: Preserve empty HTX messages with an unprocessed parsing error
Christopher Faulet [Mon, 1 Apr 2019 09:33:17 +0000 (11:33 +0200)] 
BUG/MINOR: htx: Preserve empty HTX messages with an unprocessed parsing error

This let a chance to HTX analyzers to handle the error and send the appropriate
response to the client.

This patch must be backported to 1.9.

6 years agoMINOR: cli: export HAPROXY_CLI environment variable
William Lallemand [Mon, 1 Apr 2019 09:30:06 +0000 (11:30 +0200)] 
MINOR: cli: export HAPROXY_CLI environment variable

Export the HAPROXY_CLI environment variable which contains the list of
all stats sockets (including the sockpair@) separated by semicolons.

6 years agoMINOR: cli: start addresses by a prefix in 'show cli sockets'
William Lallemand [Mon, 1 Apr 2019 09:30:05 +0000 (11:30 +0200)] 
MINOR: cli: start addresses by a prefix in 'show cli sockets'

Displays a prefix for every addresses in 'show cli sockets'.
It could be 'unix@', 'ipv4@', 'ipv6@', 'abns@' or 'sockpair@'.

Could be backported in 1.9 and 1.8.

6 years agoBUG/MINOR: cli: correctly handle abns in 'show cli sockets'
William Lallemand [Mon, 1 Apr 2019 09:30:04 +0000 (11:30 +0200)] 
BUG/MINOR: cli: correctly handle abns in 'show cli sockets'

The 'show cli sockets' was not handling the abns sockets. This is a
problem since it uses the AF_UNIX family, it displays nothing
in the path column because the path starts by \0.

Should be backported to 1.9 and 1.8.

6 years agoMINOR: mworker/cli: show programs in 'show proc'
William Lallemand [Mon, 1 Apr 2019 09:30:03 +0000 (11:30 +0200)] 
MINOR: mworker/cli: show programs in 'show proc'

Show the programs in 'show proc'

Example:

# programs
2285            dataplane-api   -               0               0d 00h00m12s
# old programs
2261            dataplane-api   -               1               0d 00h00m53s

6 years agoMEDIUM: mworker-prog: implement program for master-worker
William Lallemand [Mon, 1 Apr 2019 09:30:02 +0000 (11:30 +0200)] 
MEDIUM: mworker-prog: implement program for master-worker

This patch implements the external binary support in the master worker.

To configure an external process, you need to use the program section,
for example:

program dataplane-api
command ./dataplane_api

Those processes are launched at the same time as the workers.

During a reload of HAProxy, those processes are dealing with the same
sequence as a worker:

  - the master is re-executed
  - the master sends a USR1 signal to the program
  - the master launches a new instance of the program

During a stop, or restart, a SIGTERM is sent to the program.

6 years agoREORG: mworker/cli: move CLI functions to mworker.c
William Lallemand [Mon, 1 Apr 2019 09:30:01 +0000 (11:30 +0200)] 
REORG: mworker/cli: move CLI functions to mworker.c

Move the CLI functions of the master worker to mworker.c

6 years agoMINOR: cli: export cli_parse_default() definition in cli.h
William Lallemand [Mon, 1 Apr 2019 09:30:00 +0000 (11:30 +0200)] 
MINOR: cli: export cli_parse_default() definition in cli.h

Export the cli_parse_default() function in cli.h so it could be used in
other files.

6 years agoMINOR: mworker: don't use children variable anymore
William Lallemand [Mon, 1 Apr 2019 09:29:59 +0000 (11:29 +0200)] 
MINOR: mworker: don't use children variable anymore

The children variable is still used in haproxy, it is not required
anymore since we have the information about the current workers in the
mworker_proc linked list.

The oldpids array is also replaced by this linked list when we
generated the arguments for the master reexec.

6 years agoMINOR: mworker: calloc mworker_proc structures
William Lallemand [Mon, 1 Apr 2019 09:29:58 +0000 (11:29 +0200)] 
MINOR: mworker: calloc mworker_proc structures

Initialize mworker_proc structures to 0 with calloc instead of just
doing a malloc.

6 years agoREORG: mworker: move mworker_cleanlisteners to mworker.c
William Lallemand [Mon, 1 Apr 2019 09:29:57 +0000 (11:29 +0200)] 
REORG: mworker: move mworker_cleanlisteners to mworker.c

6 years agoREORG: mworker: move signal handlers and related functions
William Lallemand [Mon, 1 Apr 2019 09:29:56 +0000 (11:29 +0200)] 
REORG: mworker: move signal handlers and related functions

Move the following functions to mworker.c:

void mworker_catch_sighup(struct sig_handler *sh);
void mworker_catch_sigterm(struct sig_handler *sh);
void mworker_catch_sigchld(struct sig_handler *sh);

static void mworker_kill(int sig);
int current_child(int pid);

6 years agoREORG: mworker: move IPC functions to mworker.c
William Lallemand [Mon, 1 Apr 2019 09:29:55 +0000 (11:29 +0200)] 
REORG: mworker: move IPC functions to mworker.c

Move the following functions to mworker.c:

void mworker_accept_wrapper(int fd);
void mworker_pipe_register();

6 years agoREORG: mworker: move signals functions to mworker.c
William Lallemand [Mon, 1 Apr 2019 09:29:54 +0000 (11:29 +0200)] 
REORG: mworker: move signals functions to mworker.c

Move the following functions to mworker.c:

void mworker_block_signals();
void mworker_unblock_signals();

6 years agoREORG: mworker: move serializing functions to mworker.c
William Lallemand [Mon, 1 Apr 2019 09:29:53 +0000 (11:29 +0200)] 
REORG: mworker: move serializing functions to mworker.c

Move the 2 following functions to mworker.c:

void mworker_proc_list_to_env()
void mworker_env_to_proc_list()

6 years agoMINOR: ssl: Add aes_gcm_dec converter
Nenad Merdanovic [Sat, 23 Mar 2019 10:00:32 +0000 (11:00 +0100)] 
MINOR: ssl: Add aes_gcm_dec converter

The converter can be used to decrypt the raw byte input using the
AES-GCM algorithm, using provided nonce, key and AEAD tag. This can
be useful to decrypt encrypted cookies for example and make decisions
based on the content.

6 years agoBUILD: Makefile: disable shared cache on AIX 5.1
Willy Tarreau [Fri, 29 Mar 2019 17:56:54 +0000 (18:56 +0100)] 
BUILD: Makefile: disable shared cache on AIX 5.1

AIX 5.1 is missing the following builtins used for atomic locking of the
shared inter-process cache :

   .__sync_val_compare_and_swap_4
   .__sync_lock_test_and_set_4
   .__sync_sub_and_fetch_4

Let's simply use the private cache by default since nobody cares on
such old systems. No test was made on a more recent version.

6 years agoBUILD: define unsetenv on AIX 5.1
Willy Tarreau [Fri, 29 Mar 2019 17:56:00 +0000 (18:56 +0100)] 
BUILD: define unsetenv on AIX 5.1

This version doesn't have unsetenv(), so let's map it to my_unsetenv() instead.
This wasn't tested on more recent versions.

6 years agoBUILD: makefile: add _LINUX_SOURCE_COMPAT to build on AIX-51
Willy Tarreau [Fri, 29 Mar 2019 16:56:13 +0000 (17:56 +0100)] 
BUILD: makefile: add _LINUX_SOURCE_COMPAT to build on AIX-51

Not tested on later versions, but at least there _LINUX_SOURCE_COMPAT
must be defined to access the CMSG_SPACE() and CMSG_LEN() macros.

6 years agoBUILD: makefile: fix build of IPv6 header on aix51
Willy Tarreau [Fri, 29 Mar 2019 16:40:23 +0000 (17:40 +0100)] 
BUILD: makefile: fix build of IPv6 header on aix51

ip6_hdr is called ip6hdr there and is only defined when STEVENS_API is
defined.

6 years agoBUILD: connection: fix naming of ip_v field
Willy Tarreau [Fri, 29 Mar 2019 16:35:32 +0000 (17:35 +0100)] 
BUILD: connection: fix naming of ip_v field

AIX defines ip_v as ip_ff.ip_fv in netinet/ip.h using a macro, and
unfortunately we do have a local variable with such a name and which
uses the same header file. Let's rename the variable to ip_ver to fix
this.

6 years agoBUILD: use inttypes.h instead of stdint.h
Willy Tarreau [Fri, 29 Mar 2019 16:26:33 +0000 (17:26 +0100)] 
BUILD: use inttypes.h instead of stdint.h

I found on an (old) AIX 5.1 machine that stdint.h didn't exist while
inttypes.h which is expected to include it does exist and provides the
desired functionalities.

As explained here, stdint being just a subset of inttypes for use in
freestanding environments, it's probably always OK to switch to inttypes
instead:

  https://pubs.opengroup.org/onlinepubs/009696799/basedefs/stdint.h.html

Also it's even clearer here in the autoconf doc :

  https://www.gnu.org/software/autoconf/manual/autoconf-2.61/html_node/Header-Portability.html

  "The C99 standard says that inttypes.h includes stdint.h, so there's
   no need to include stdint.h separately in a standard environment.
   Some implementations have inttypes.h but not stdint.h (e.g., Solaris
   7), but we don't know of any implementation that has stdint.h but not
   inttypes.h"

6 years agoBUILD: re-implement an initcall variant without using executable sections
Willy Tarreau [Fri, 29 Mar 2019 20:30:17 +0000 (21:30 +0100)] 
BUILD: re-implement an initcall variant without using executable sections

The current initcall implementation relies on dedicated sections (one
section per init stage) to store the initcall descriptors. Then upon
startup, these sections are scanned from beginning to end and all items
found there are called in sequence.

On platforms like AIX or Cygwin it seems difficult to figure the
beginning and end of sections as the linker doesn't seem to provide
the corresponding symbols. In order to replace this, this patch
simply implements an array of single linked (one per init stage)
which are fed using constructors for each register call. These
constructors are declared static, with a name depending on their
line number in the file, in order to avoid name clashes. The final
effect is the same, except that the method is slightly more expensive
in that it explicitly produces code to register these initcalls :

$ size  haproxy.sections haproxy.constructor
   text    data     bss     dec     hex filename
4060312  249176 1457652 5767140  57ffe4 haproxy.sections
4062862  260408 1457652 5780922  5835ba haproxy.constructor

This mechanism is enabled as an alternative to the default one when
build option USE_OBSOLETE_LINKER is set. This option is currently
enabled by default only on AIX and Cygwin, and may be attempted for
any target which fails to build complaining about missing symbols
__start_init_* and/or __stop_init_*.

Once confirmed as a reliable fix, this will likely have to be backported
to 1.9 where AIX and Cygwin do not build anymore.

6 years agoMINOR: tools: add an unsetenv() implementation
Willy Tarreau [Fri, 29 Mar 2019 17:49:09 +0000 (18:49 +0100)] 
MINOR: tools: add an unsetenv() implementation

Older Solaris and AIX versions do not have unsetenv(). This adds a
fairly simple implementation which scans the environment, for use
with those systems. It will simply require to pass the define in
the "DEFINE" macro at build time like this :

      DEFINE="-Dunsetenv=my_unsetenv"

6 years agoMINOR: tools: make memvprintf() never pass a NULL target to vsnprintf()
Willy Tarreau [Fri, 29 Mar 2019 18:13:23 +0000 (19:13 +0100)] 
MINOR: tools: make memvprintf() never pass a NULL target to vsnprintf()

Most modern platforms don't touch the output buffer when the size
argument is null, but there exist a few old ones (like AIX 5 and
possibly Tru64) where the output will be dereferenced anyway, probably
to write the trailing null, crashing the process. memprintf() uses this
to measure the desired length.

There is a very simple workaround to this consisting in passing a pointer
to a character instead of a NULL pointer. It was confirmed to fix the issue
on AIX 5.1.

6 years agoBUILD: cache: avoid a build warning with some compilers/linkers
Willy Tarreau [Fri, 29 Mar 2019 17:26:52 +0000 (18:26 +0100)] 
BUILD: cache: avoid a build warning with some compilers/linkers

The struct http_cache_applet was fully declared at the beginning
instead of just doing a forward declaration using an extern modifier.
Some linkers report warnings about a redefined symbol since these
really are two complete declarations.

The proper way to do this is to use extern on the first one and to
have a full declaration later. However it's not permitted to have
both static and extern so the change done in commit 0f2229943
("CLEANUP: cache: don't export http_cache_applet anymore") has to
be partially undone.

This should be backported to 1.9 for sanity but has no effet on
most platforms. However on 1.9 the extern keyword must also be
added to include/types/cache.h.

6 years agoBUILD: chunk: properly declare pool_head_trash as extern
Willy Tarreau [Fri, 29 Mar 2019 17:13:36 +0000 (18:13 +0100)] 
BUILD: chunk: properly declare pool_head_trash as extern

This one was also declared without the extern modifier in an include
file.

This needs to be backported to 1.9.

6 years agoBUILD: http: properly mark some struct as extern
Willy Tarreau [Fri, 29 Mar 2019 16:52:50 +0000 (17:52 +0100)] 
BUILD: http: properly mark some struct as extern

http_known_methods, HTTP_100 and HTTP_103 were not declared extern and
as such were multiply defined since they were in http.h. There was
apparently no more side effect but it may depend on the platform and
the linker.

This needs to be backported to 1.9.

6 years agoBUILD: makefile: work around another bug in make 3.80
Willy Tarreau [Fri, 29 Mar 2019 19:55:54 +0000 (20:55 +0100)] 
BUILD: makefile: work around another bug in make 3.80

GNU make 3.80 has an issue with calls to functions inside an if block,
which is just what we recently introduced to simplify the targets
declaration. The fix is easy, it simply consists in assigning the
command to a variable inside the if block and evaluating this command
after the block. This also makes the code slightly more readable so we
can keep compatibility with 3.80 for now.

No backport is needed.

6 years agoBUILD: makefile: work around an old bug in GNU make-3.80
Willy Tarreau [Fri, 29 Mar 2019 16:17:52 +0000 (17:17 +0100)] 
BUILD: makefile: work around an old bug in GNU make-3.80

GNU make-3.80 fails on the .build_opts target, expecting the closing
brace before the first semi-colon in the shell command, it probably
uses a more limited parser for dependencies. Actually it appears it's
enough to place this command in a variable and reference the variable
there. Since it doesn't affect later versions (and the resulting string
is always empty anyway), let's apply the minor change to continue to
comply with the announced dependencies.

This could be backported as far as 1.6.

6 years agoBUG/MAJOR: checks: segfault during tcpcheck_main
Ricardo Nabinger Sanchez [Fri, 29 Mar 2019 00:42:23 +0000 (21:42 -0300)] 
BUG/MAJOR: checks: segfault during tcpcheck_main

When using TCP health checks (tcp-check connect), it is possible to
crash with a segfault when, for reasons yet to be understood, the
protocol family is unknown.

In the function tcpcheck_main(), proto is dereferenced without a prior
test in case it is NULL, leading to the segfault during proto->connect
dereference.

The line has been unmodified since it was introduced, in commit
69e273f3fcfbfb9cc0fb5a09668faad66cfbd36b.  This was the only use of
proto (or more specifically, the return of  protocol_by_family()) that
was unprotected; all other callsites perform the test for a NULL
pointer.

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

6 years agoBUG/MEDIUM: checks: Don't bother subscribing if we have a connection error.
Olivier Houchard [Thu, 28 Mar 2019 16:32:42 +0000 (17:32 +0100)] 
BUG/MEDIUM: checks: Don't bother subscribing if we have a connection error.

In __event_srv_chk_r() and __event_srv_chk_w(), don't bother subscribing
if we're waiting for a handshake, but we had a connection error. We will
never be able to send/receive anything on that connection anyway, and
the conn_stream is probably about to be destroyed, and we will crash if
the tasklet is waken up.
I'm not convinced we need to subscribe here at all anyway, but I'd rather
modify the check code as little as possible.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: mworker: don't free the wrong child when not found
William Lallemand [Wed, 27 Mar 2019 13:19:10 +0000 (14:19 +0100)] 
BUG/MEDIUM: mworker: don't free the wrong child when not found

A bug occurs when the sigchld handler is called and a child which is
not in the process list just left, or with an empty process list.

The child variable won't be set and left as an uninitialized variable or
set to the wrong child entry, which can lead to a free of this
uninitialized variable or of the wrong child.

This can lead to a crash of the master during a stop or a reload.

It is not supposed to happen with a worker which was created by the
master. A cause could be a fork made by a dependency. (openssl, lua ?)

This patch strengthens the case of the missing child by doing the free
only if the child was found.

This patch must be backported to 1.9.

6 years agoBUG/MINOR: mux-h1: Only skip invalid C-L headers on output
Christopher Faulet [Wed, 27 Mar 2019 14:44:56 +0000 (15:44 +0100)] 
BUG/MINOR: mux-h1: Only skip invalid C-L headers on output

When an HTTP request with an empty body is received, the flag HTX_SL_F_BODYLESS
is set on the HTX start-line block. It is true if the header content-length is
explicitly set to 0 or if it is omitted for a non chunked request.

On the server side, when the request is reformatted, because HTX_SL_F_BODYLESS
is set, the flag H1_MF_CLEN is added on the request parser. It is done to not
add an header transfer-encoding on bodyless requests. But if an header
content-length is explicitly set to 0, when it is parsed, because H1_MF_CLEN is
set, the function h1_parse_cont_len_header() returns 0, meaning the header can
be dropped. So in such case, a request without any header content-length is sent
to the server.

Some servers seems to reject empty POST requests with an error 411 when there is
no header content-length. So to fix this issue, on the output side, only headers
with an invalid content length are skipped, ie only when the function
h1_parse_cont_len_header() returns a negative value.

This patch must be backported to 1.9.

6 years agoBUILD/MINOR: listener: Silent a few signedness warnings.
David Carlier [Wed, 27 Mar 2019 16:08:42 +0000 (16:08 +0000)] 
BUILD/MINOR: listener: Silent a few signedness warnings.

Silenting couple of warnings related to signedness, due to a mismatch of
signed and unsigned ints with l->nbconn, actconn and p->feconn.

6 years agoBUG/MINOR: contrib/prometheus-exporter: Fix applet accordingly to recent changes
Christopher Faulet [Wed, 27 Mar 2019 14:48:53 +0000 (15:48 +0100)] 
BUG/MINOR: contrib/prometheus-exporter: Fix applet accordingly to recent changes

Since the flag EOI was added on channels, some hidden bugs in the prometheus
exporter now leads to error. the visible effect is that responses are
truncated.

So first of all, channel_add_input() must be called when the response headers
and the EOM block are added. To be sure to correctly update the response channel
(especially to_forward value). Then the request must really be fully
consumed. And finally, the return clause in the switch has been replaced by a
break. It was totally wrong to skip the end of the function in the states
PROMEX_DONE and PROMEX_ERROR. (Note that PROMEX_ERROR was never used, so it was
replaced by PROMEX_END just to ease reading the code).

No need to backport this patch, the Prometheus exporter does not exist in early
versions.

6 years agoBUG/MINOR: peers: Missing initializations after peer session shutdown.
Frédéric Lécaille [Wed, 27 Mar 2019 13:32:39 +0000 (14:32 +0100)] 
BUG/MINOR: peers: Missing initializations after peer session shutdown.

This patch fixes a bug introduced by 045e0d4 commit where it was really a bad
idea to reset the peer applet context before shutting down the underlying
session. This had as side effect to cancel the re-initializations done by
peer_session_release(), especially prevented this function from re-initializing
the current table pointer which is there to force annoucement of stick-table
definitions on when reconnecting. Consequently the peers could send stick-table
update messages without a first stick-table definition message. As this is
forbidden, this leaded the remote peers to close the sessions.

6 years agoREGTEST: script: remove platform-specific assigments of OPTIONS
Willy Tarreau [Wed, 27 Mar 2019 13:00:10 +0000 (14:00 +0100)] 
REGTEST: script: remove platform-specific assigments of OPTIONS

We don't use OPTIONS anymore, let's simply remove all the code that sets
this variable. It was not viable anyway to keep this one in sync with
the makefile.

6 years agoREGTEST: script: make the script use the new features list
Willy Tarreau [Wed, 27 Mar 2019 12:52:39 +0000 (13:52 +0100)] 
REGTEST: script: make the script use the new features list

Currently the script only sees options that differ from the default,
which makes it fail on default options that are disabled (such as
threads on the relevant platforms). Let's make it instead extract
the newly introduced feature list and search for an explicit "+" in
front of the desiered feature. This one is known for always being
valid.

6 years agoBUILD: pass all "USE_*" variables as -DUSE_* to the compiler
Willy Tarreau [Wed, 27 Mar 2019 13:44:14 +0000 (14:44 +0100)] 
BUILD: pass all "USE_*" variables as -DUSE_* to the compiler

Many of these variables are already passed verbatim. Let's now pass
all of them, this will require less changes in the future. A number
of older variables have different names for the makefile and the code
and should be adjusted to further simplify this. A few remain though,
mainly the ones which imply another one (e.g. USE_STATIC_PCRE implies
USE_PCRE).

6 years agoBUILD: report the whole feature set with their status in haproxy -vv
Willy Tarreau [Wed, 27 Mar 2019 12:20:08 +0000 (13:20 +0100)] 
BUILD: report the whole feature set with their status in haproxy -vv

It's not convenient not to know the status of default options, and
requires the user to know what option is enabled by default in each
target. With this patch, a new "Features list" line is added to the
output of "haproxy -vv" to report the whole list of known features
with their respective status. They're prefixed with a "+" when enabled
or a "-" when disabled. The "USE_" prefix is removed for clarity.

6 years agoBUILD: Makefile: clean up the target declarations
Willy Tarreau [Wed, 27 Mar 2019 10:44:19 +0000 (11:44 +0100)] 
BUILD: Makefile: clean up the target declarations

The target declarations were historically made of a series of if/else but
this is pointless and only makes the list unreadable given the number of
entries, especially the long tail of "endif". Just use a series of
"if/endif" for each target instead, and take this opportuity to clean up
the comments.

6 years agoBUILD: Makefile: shorten default settings declaration
Willy Tarreau [Wed, 27 Mar 2019 10:30:47 +0000 (11:30 +0100)] 
BUILD: Makefile: shorten default settings declaration

By using a "default_opts" function we can enumerate at once all the
settings we want to enable by default for each platform instead of
individually assigning each variable. Doing this removed 46 lines
in the makefile.

6 years agoBUILD: Makefile: also report disabled options in the BUILD_OPTIONS variable
Willy Tarreau [Wed, 27 Mar 2019 09:57:49 +0000 (10:57 +0100)] 
BUILD: Makefile: also report disabled options in the BUILD_OPTIONS variable

Now we iterate over all known variables and report in the BUILD_OPTIONS
string all those which differ from the target's defaults. This means that
if a target sets a variable by default (e.g. USE_THREAD in linux2628) and
the user disables it on the command line, the BUILD_OPTIONS string will
now properly report "USE_THREAD=".

6 years agoBUILD: Makefile: consider a variable's origin and not its value for the options list
Willy Tarreau [Wed, 27 Mar 2019 09:36:35 +0000 (10:36 +0100)] 
BUILD: Makefile: consider a variable's origin and not its value for the options list

Right now it's annoying not to be able to enumerate disabled options that
are set by default for a given target. The reason is that we rely on the
fact that the variable is neither cleared nor set to "implicit" in order
to list it.

Here we modify the ignore_implicit function to check the variable's origin
instead of its value. We consider as modified any variable whose origin is
"environment" or "command". Other ones are "undefined" (variable not set)
and "file" (variable set in the Makefile). For now this doesn't change
anything since variables are only dumped when not empty. However if a
variable was forced to "implicit" on the command line, it would now appear.

6 years agoBUILD: Makefile: remove outdated support for dlmalloc
Willy Tarreau [Wed, 27 Mar 2019 13:20:43 +0000 (14:20 +0100)] 
BUILD: Makefile: remove outdated support for dlmalloc

dlmalloc has remained unused for quite a while now, in part because it
is not thread-safe and in part because it has been superseded by the
much better and faster jemalloc. So let's simplify the makefile and
remove entries related to this library.

6 years agoBUILD: remove 10-years old error message for obsolete option USE_TCPSPLICE
Willy Tarreau [Wed, 27 Mar 2019 13:26:34 +0000 (14:26 +0100)] 
BUILD: remove 10-years old error message for obsolete option USE_TCPSPLICE

The USE_TCPSPLICE option was removed in 1.4-dev3 10 years ago, and the
error message remained to warn the user. Let's get rid of it now.

6 years agoBUILD: Makefile: remove 11-years old workarounds for deprecated options
Willy Tarreau [Wed, 27 Mar 2019 10:51:44 +0000 (11:51 +0100)] 
BUILD: Makefile: remove 11-years old workarounds for deprecated options

Build options "REGEX=" and "DEFINE=-DTPROXY" have been deprecated by
commit 9f2b730 in 1.3.15 and have been emitting warnings for over 11
years. It's about time to get rid of them.

6 years agoREGTEST: remove unexpected "nbthread" statement from Lua test cases
Willy Tarreau [Wed, 27 Mar 2019 12:50:33 +0000 (13:50 +0100)] 
REGTEST: remove unexpected "nbthread" statement from Lua test cases

Lua test files 2 and 3 fail when threads are disabled because of a
"nbthread" statement that seems to be a leftover from an ancient
configuration. One of them even mentions a commit message showing
a reproducer not involving threads. Let's clean this up so that
running the tests without threads also works.

This should be backported to 1.9 as the problem also exists there.

6 years agoDOC: peers: Peers protocol documentation update.
Frédéric Lécaille [Tue, 26 Mar 2019 15:17:33 +0000 (16:17 +0100)] 
DOC: peers: Peers protocol documentation update.

Add information about new peers protocol heartbeat feature.

6 years agoDOC: The option httplog is no longer valid in a backend.
Freddy Spierenburg [Mon, 25 Mar 2019 13:35:17 +0000 (14:35 +0100)] 
DOC: The option httplog is no longer valid in a backend.

This can be backported to 1.9 and 1.8.

6 years agoREGTEST: Enable again reg tests with HEAD HTTP method usage.
Frédéric Lécaille [Tue, 26 Mar 2019 10:06:29 +0000 (11:06 +0100)] 
REGTEST: Enable again reg tests with HEAD HTTP method usage.

These reg tests have been disabled because they required a version of vtest
including a bug fix supposed to make these ones work without breaking others.
But reg-tests for compression were broken.

This issue has been fixed by 525ef0f vtest commit. So, to make all the
reg tests work you must update your vtest program to include 525ef0f commit.
(see https://github.com/vtest/VTest/commit/525ef0f for more information.

6 years agoCLEANUP: peers: replace timeout constants by macros.
Frédéric Lécaille [Tue, 26 Mar 2019 09:25:20 +0000 (10:25 +0100)] 
CLEANUP: peers: replace timeout constants by macros.

This adds two macros PEER_RESYNC_TIMEOUT and PEER_RECONNECT_TIMEOUT
both set to 5 seconds in order to remove magic timeouts which appear
in the code.

6 years agoCLEANUP: peers: remove useless annoying tabulations.
Frédéric Lécaille [Tue, 26 Mar 2019 09:18:07 +0000 (10:18 +0100)] 
CLEANUP: peers: remove useless annoying tabulations.

There were tabs in between macro names and their values in their
definition, forcing everyone to do the same, and causing some
mangling in patches. Let's fix all this.

6 years agoBUG/MINOR: peers: Really close the sessions with no heartbeat.
Frédéric Lécaille [Thu, 21 Mar 2019 10:12:32 +0000 (11:12 +0100)] 
BUG/MINOR: peers: Really close the sessions with no heartbeat.

645635d commit was not sufficient to implement the heartbeat feature.
When no heartbeat was received before its timeout has expired the session was not
closed due to the fact that process_peer_sync() which is the task responsible of
handling the heartbeat and session expirations only checked the heartbeat timeout,
and sent a heartbeat message if it has expired. This has as side
effect to leave the session opened. On the remote side, a peer which receives a
heartbeat message, even if not supported, does not close the session.
Furthermore it not sufficient to update ->reconnect peer member field to schedule
a peer session release.

With this patch, a peer is flagged as alive as soon as it received peer protocol
messages (and not only heartbeat messages). When no updates must be sent,
we first check the reconnection timeout (->reconnect peer member field). If expired,
we really shutdown the session if the peer is not alive, but if the peer seen as alive,
we reset this flag and update the ->reconnect for the next period.
If the reconnection timeout has not expired, then we check the heartbeat timeout
which is there only to emit heartbeat messages upon expirations. If expired, as before this
patch we increment the heartbeat timeout by 3s to schedule the next heartbeat message
then we emit a heartbeat message waking up the peer I/O handler.
In every cases we update the task expiration to the earlier time between the
reconnection time and the heartbeat timeout time so that to be sure to check
again these two ->reconnect and ->heartbeat timers.

6 years ago[RELEASE] Released version 2.0-dev2 v2.0-dev2
Willy Tarreau [Tue, 26 Mar 2019 04:40:51 +0000 (05:40 +0100)] 
[RELEASE] Released version 2.0-dev2

Released version 2.0-dev2 with the following main changes :
    - CLEANUP: http: Remove unreachable code in parse_http_req_capture
    - CLEANUP: stream: Remove bogus loop in conn_si_send_proxy
    - MINOR: lists: Implement locked variations.
    - MEDIUM: servers: Used a locked list for idle_orphan_conns.
    - MEDIUM: servers: Reorganize the way idle connections are cleaned.
    - BUG/MEDIUM: lists: Properly handle the case we're removing the first elt.
    - MINOR: cfgparse: Add a cast to make gcc happier.
    - BUG/MEDIUM: standard: Wrong reallocation size.
    - BUG/MINOR: listener: keep accept rate counters accurate under saturation
    - DOC: fix alphabetic ordering for "tune.fail-alloc" setting
    - MAJOR: config: disable support for nbproc and nbthread in parallel
    - MEDIUM: listener: keep a single thread-mask and warn on "process" misuse
    - MAJOR: listener: do not hold the listener lock in listener_accept()
    - MINOR: listener: maintain a per-thread count of the number of connections on a listener
    - MINOR: tools: implement functions to look up the nth bit set in a mask
    - MINOR: listener: pre-compute some thread counts per bind_conf
    - MINOR: listener: implement multi-queue accept for threads
    - MAJOR: listener: use the multi-queue for multi-thread listeners
    - MINOR: activity: add accept queue counters for pushed and overflows
    - MINOR: config: add global tune.listener.multi-queue setting
    - MAJOR: threads: enable one thread per CPU by default
    - DOC: update management.txt to reflect that threads are used by default
    - BUG/MINOR: config: don't over-count the global maxsock value
    - BUG/MEDIUM: list: fix the rollback on addq in the locked liss
    - BUG/MEDIUM: list: fix LIST_POP_LOCKED's removal of the last pointer
    - BUG/MEDIUM: list: add missing store barriers when updating elements and head
    - MINOR: list: make the delete and pop operations idempotent
    - MINOR: server: remove a few unneeded LIST_INIT calls after LIST_DEL_LOCKED
    - BUG/MEDIUM: listener: use a self-locked list for the dequeue lists
    - BUG/MEDIUM: listener: make sure the listener never accepts too many conns
    - BUG/MEDIUM: list: correct fix for LIST_POP_LOCKED's removal of last element
    - MINOR: listener: introduce listener_backlog() to report the backlog value
    - MINOR: listener: do not needlessly set l->maxconn
    - MINOR: proxy: do not change the listeners' maxconn when updating the frontend's
    - MEDIUM: config: don't enforce a low frontend maxconn value anymore
    - MINOR: peers: Add a message for heartbeat.
    - MINOR: global: keep a copy of the initial rlim_fd_cur and rlim_fd_max values
    - BUG/MINOR: init: never lower rlim_fd_max
    - BUG/MINOR: checks: make external-checks restore the original rlim_fd_cur/max
    - BUG/MINOR: mworker: be careful to restore the original rlim_fd_cur/max on reload
    - MINOR: init: make the maxpipe computation more accurate
    - MINOR: init: move some maxsock updates earlier
    - MEDIUM: init: make the global maxconn default to what rlim_fd_cur permits
    - REGTEST: fix a spurious "nbthread 4" in the connection test
    - DOC: update the text related to the global maxconn value
    - BUG/MAJOR: mux-h2: fix race condition between close on both ends
    - MINOR: sample: Replace "req.ungrpc" smp fetch by a "ungrpc" converter.
    - BUG/MEDIUM: list: fix again LIST_ADDQ_LOCKED
    - MINOR: htx: unconditionally handle parsing errors in requests or responses
    - MINOR: mux-h2: always pass HTX_FL_PARSING_ERROR between h2s and buf on RX
    - BUG/MEDIUM: h2/htx: verify that :path doesn't contain invalid chars
    - MINOR: sample: Code factorization "ungrpc" converter.
    - MINOR: sample: Rework gRPC converter code.
    - CLEANUP: wurfl: remove dead, broken and unmaintained code
    - MINOR: config: relax the range checks on cpu-map
    - BUG/MINOR: ssl: fix warning about ssl-min/max-ver support
    - MINOR: sample: Extract some protocol buffers specific code.
    - DOC: Remove tabs and fixed punctuation.
    - MINOR: sample: Add a protocol buffers specific converter.
    - REGTEST: Peers reg tests.
    - REGTEST: Enable reg tests with HEAD HTTP method usage.
    - MINOR: lists: add a LIST_DEL_INIT() macro
    - MINOR: task: use LIST_DEL_INIT() to remove a task from the queue
    - MINOR: listener: improve incoming traffic distribution
    - MINOR: tools: implement my_flsl()
    - MEDIUM: listener: change the LB algorithm again to use two round robins instead
    - CLEANUP: listener: remove old thread bit mapping
    - MINOR: listener: move thr_idx from the bind_conf to the listener
    - BUG/MEDIUM: logs: Only attempt to free startup_logs once.
    - BUG/MAJOR: config: Wrong maxconn adjustment.
    - BUG/MEDIUM: 51d: fix possible segfault on deinit_51degrees()
    - OPTIM: task: limit the impact of memory barriers in taks_remove_from_task_list()
    - MINOR: fd: Remove debugging code.
    - BUG/MEDIUM: listeners: Don't call fd_stop_recv() if fd_updt is NULL.
    - MINOR: threads: Implement __ha_barrier_atomic*.
    - MEDIUM: threads: Use __ATOMIC_SEQ_CST when using the newer atomic API.
    - MINOR: threads: Add macros to do atomic operation with no memory barrier.
    - MEDIUM: various: Use __ha_barrier_atomic* when relevant.
    - MEDIUM: applets: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: xref: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: fd: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: freq_ctr: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: proxy: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: server: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: task: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: activity: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: backend: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: cache: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: checks: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: pollers: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: compression: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: spoe: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: threads: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: http: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: lb/threads: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: listeners: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: logs: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: memory: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: peers: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: proto_tcp: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: queues: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: sessions: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: ssl: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: stream: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: tcp_rules: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: time: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: vars: Use the new _HA_ATOMIC_* macros.
    - MINOR: config: remove obsolete use of DEFAULT_MAXCONN at various places
    - MINOR: config: continue to rely on DEFAULT_MAXCONN to set the minimum maxconn
    - BUG/MEDIUM: list: fix incorrect pointer unlocking in LIST_DEL_LOCKED()
    - BUG/MEDIUM: listener: make sure we don't pick stopped threads
    - MEDIUM: list: Remove useless barriers.
    - MEDIUM: list: Use _HA_ATOMIC_*
    - MEDIUM: connections: Use _HA_ATOMIC_*
    - BUG/MAJOR: tasks: Use the TASK_GLOBAL flag to know if we're in the global rq.
    - BUG/MEDIUM: threads/fd: do not forget to take into account epoll_fd/pipes
    - BUG/MEDIUM: init/threads: consider epoll_fd/pipes for automatic maxconn calculation
    - BUG/MEDIUM: tasks: Make sure we wake sleeping threads if needed.
    - BUG/MINOR: mux-h1: Don't report an error on EOS if no message was received
    - BUG/MINOR: stats/htx: Call channel_add_input() when response headers are sent
    - BUG/MINOR: lua/htx: Use channel_add_input() when response data are added
    - BUG/MINOR: lua/htx: Don't forget to call htx_to_buf() when appropriate
    - MINOR: stats: Add the status code STAT_STATUS_IVAL to handle invalid requests
    - MINOR: stats: Move stuff about the stats status codes in stats files
    - BUG/MINOR: stats: Be more strict on what is a valid request to the stats applet
    - Revert "REGTEST: Enable reg tests with HEAD HTTP method usage."
    - BUILD: listener: shut up a build warning when threads are disabled
    - BUILD: Makefile: allow the reg-tests target to be verbose
    - BUILD: Makefile: resolve LEVEL before calling run-regtests
    - BUG/MAJOR: spoe: Fix initialization of thread-dependent fields
    - BUG/MAJOR: stats: Fix how huge POST data are read from the channel
    - BUG/MINOR: http/counters: fix missing increment of fe->srv_aborts
    - BUG/MEDIUM: mux-h2: Always wakeup streams with no id to avoid frozen streams
    - MINOR: mux-h2: Set REFUSED_STREAM error to reset a stream if no data was never sent
    - MINOR: muxes: Report the Last read with a dedicated flag
    - MINOR: proto-http/proto-htx: Make error handling clearer during data forwarding
    - BUILD: tools: fix a build warning on some 32-bit archs
    - MINOR: init: report the list of optionally available services
    - MEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter
    - BUG/MINOR: cache: Fully consume large requests in the cache applet
    - BUG/MINOR: stats: Fully consume large requests in the stats applet
    - BUG/MEDIUM: lua: Fully consume large requests when an HTTP applet ends
    - MINOR: proto_http: Add function to handle the header "Expect: 100-continue"
    - MINOR: proto_htx: Add function to handle the header "Expect: 100-continue"
    - MINOR: stats/cache: Handle the header Expect when applets are registered
    - MINOR: http/applets: Handle all applets intercepting HTTP requests the same way
    - CLEANUP: cache: don't export http_cache_applet anymore
    - MINOR: lua: Don't handle the header Expect in lua HTTP applets anymore
    - BUG/MINOR: doc: Be accurate on the behavior on pool-purge-delay.
    - Revert "MEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter"
    - BUG/MEDIUM: mux-h2: Make sure we destroyed the h2s once shutr/shutw is done.
    - BUG/MEDIUM: mux-h2: Don't bother keeping the h2s if detaching and nothing to send.
    - BUG/MEDIUM: mux-h2: Use the right list in h2_stop_senders().
    - MINOR: mux-h2: copy small data blocks more often and reduce the number of pauses
    - CLEANUP: mux-h2: add some comments to help understand the code
    - BUG/MEDIUM: ssl: ability to set TLS 1.3 ciphers using ssl-default-server-ciphersuites
    - BUG/MINOR: log: properly format IPv6 address when LOG_OPT_HEXA modifier is used.
    - BUG/MEDIUM: h2: Try to be fair when sending data.
    - BUG/MINOR: proto-http: Don't forward request body anymore on error
    - MINOR: mux-h2: Remove useless test on ES flag in h2_frt_transfer_data()
    - MINOR: connection: and new flag to mark end of input (EOI)
    - MINOR: channel: Report EOI on the input channel if it was reached in the mux
    - MEDIUM: mux-h2: Don't mix the end of the message with the end of stream
    - MINOR: mux-h1: Set CS_FL_EOI the end of the message is reached
    - BUG/MEDIUM: http/htx: Fix handling of the option abortonclose
    - CLEANUP: muxes/stream-int: Remove flags CS_FL_READ_NULL and SI_FL_READ_NULL
    - MEDIUM: proto_htx: Reintroduce the infinite forwarding on data
    - BUG/MEDIUM: h2: only destroy the h2s if h2s->cs is NULL.
    - BUG/MEDIUM: h2: Use the new sending_list in h2s_notify_send().
    - BUG/MEDIUM: h2: Follow the same logic in h2_deferred_shut than in h2_snd_buf.
    - BUG/MEDIUM: h2: Remove the tasklet from the task list if unsubscribing.
    - BUG/MEDIUM: task/h2: add an idempotent task removal fucntion
    - CLEANUP: task: only perform a LIST_DEL() when the list is not empty
    - BUG/MEDIUM: mux-h2: make sure to always notify streams of EOS condition
    - CONTRIB: debug: report the CS and CF's EOI flags
    - MINOR: channel: don't unset CF_SHUTR_NOW after shutting down.

6 years agoMINOR: channel: don't unset CF_SHUTR_NOW after shutting down.
Willy Tarreau [Mon, 25 Mar 2019 17:35:05 +0000 (18:35 +0100)] 
MINOR: channel: don't unset CF_SHUTR_NOW after shutting down.

This flag is set by the stream layer to request an abort, and results in
CF_SHUTR being set once the abort is performed. However by analogy with
the send side, the flag was removed once the CF_SHUTR flag was set, thus
we lose the information about the cause of the shutr. This is what creates
the confusion that sometimes arises between client and server aborts.

This patch makes sure we don't remove this flag anymore in this case.
All call places only use it to perform the shutr and already check it
against CF_SHUTR. So no condition needs to be updated to take this into
account.

Some later, more careful changes may consist in refining the conditions
where we report a client reset or a server reset to ignore SHUTR when
SHUTR_NOW is set so that we don't report such misleading information
anymore.

6 years agoCONTRIB: debug: report the CS and CF's EOI flags
Willy Tarreau [Mon, 25 Mar 2019 17:34:28 +0000 (18:34 +0100)] 
CONTRIB: debug: report the CS and CF's EOI flags

These ones indicate an end of input.

6 years agoBUG/MEDIUM: mux-h2: make sure to always notify streams of EOS condition
Willy Tarreau [Mon, 25 Mar 2019 17:13:16 +0000 (18:13 +0100)] 
BUG/MEDIUM: mux-h2: make sure to always notify streams of EOS condition

Recent commit 63768a63d ("MEDIUM: mux-h2: Don't mix the end of the message
with the end of stream") introduced a race which may manifest itself with
small connection counts on large objects and large server timeouts in
legacy mode. Sometimes h2s_close() is called while the data layer is
subscribed to read events but nothing in the chain can cause this wake-up
to happen and some streams stall for a while at the end of a transfer
until the server timeout strikes and ends the stream completes.

We need to wake the stream up if it's subscribed to rx events there,
which is what this patch does. When the patch above is backported to
1.9, this patch will also have to be backported.

6 years agoCLEANUP: task: only perform a LIST_DEL() when the list is not empty
Willy Tarreau [Mon, 25 Mar 2019 17:10:53 +0000 (18:10 +0100)] 
CLEANUP: task: only perform a LIST_DEL() when the list is not empty

In tasklet_free() we unconditionally perform a LIST_DEL() even when
the list is empty, let's move the LIST_DEL() inside the matching block.

6 years agoBUG/MEDIUM: task/h2: add an idempotent task removal fucntion
Willy Tarreau [Mon, 25 Mar 2019 17:02:54 +0000 (18:02 +0100)] 
BUG/MEDIUM: task/h2: add an idempotent task removal fucntion

Previous commit 3ea351368 ("BUG/MEDIUM: h2: Remove the tasklet from the
task list if unsubscribing.") uncovered an issue which needs to be
addressed in the scheduler's API. The function task_remove_from_task_list()
was initially designed to remove a task from the running tasklet list from
within the scheduler, and had to be used in h2 to abort pending I/O events.
However this function was not designed to be idempotent, occasionally
causing a double removal from the tasklet list, with the second doing
nothing but affecting the apparent tasks count and making haproxy use
100% CPU on some tests consisting in stopping the client during some
transfers. The h2_unsubscribe() function can sometimes be called upon
stream exit after an error where the tasklet was possibly already
removed, so it.

This patch does 2 things :
  - it renames task_remove_from_task_list() to
    __task_remove_from_tasklet_list() to discourage users from calling
    it. Also note the fix in the naming since it's a tasklet list and
    not a task list. This function is still uesd from the scheduler.
  - it adds a new, idempotent, task_remove_from_tasklet_list() function
    which does nothing if the task is already not in the tasklet list.

This patch will need to be backported where the commit above is backported.

6 years agoBUG/MEDIUM: h2: Remove the tasklet from the task list if unsubscribing.
Olivier Houchard [Mon, 25 Mar 2019 13:10:42 +0000 (14:10 +0100)] 
BUG/MEDIUM: h2: Remove the tasklet from the task list if unsubscribing.

In h2_unsubscribe(), if we unsubscribe on SUB_CALL_UNSUBSCRIBE, then remove
ourself from the sending_list, and remove the tasklet from the task list.
We're probably about to destroy the stream anyway, so we don't want the
tasklet to run, or to stay in the sending_list, or it could lead to a crash.

This should be backpored to 1.9.

6 years agoBUG/MEDIUM: h2: Follow the same logic in h2_deferred_shut than in h2_snd_buf.
Olivier Houchard [Mon, 25 Mar 2019 13:08:01 +0000 (14:08 +0100)] 
BUG/MEDIUM: h2: Follow the same logic in h2_deferred_shut than in h2_snd_buf.

In h2_deferred_shut(), don't just set h2s->send_wait to NULL, instead, use
the same logic as in h2_snd_buf() and only do so if we successfully sent data
(or if we don't want to send them anymore). Setting it to NULL can lead to
crashes.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: h2: Use the new sending_list in h2s_notify_send().
Olivier Houchard [Mon, 25 Mar 2019 13:04:25 +0000 (14:04 +0100)] 
BUG/MEDIUM: h2: Use the new sending_list in h2s_notify_send().

In h2s_notify_send(), use the new sending_list instead of using the old
way of setting hs->send_wait to NULL, failing to do so may lead to crashes.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: h2: only destroy the h2s if h2s->cs is NULL.
Olivier Houchard [Mon, 25 Mar 2019 12:25:02 +0000 (13:25 +0100)] 
BUG/MEDIUM: h2: only destroy the h2s if h2s->cs is NULL.

In h2_deferred_shut(), only attempt to destroy the h2s if h2s->cs is NULL.
h2s->cs being non-NULL means it's still referenced by the stream interface,
so it may try to use it later, and that could lead to a crash.

This should be backported to 1.9.

6 years agoMEDIUM: proto_htx: Reintroduce the infinite forwarding on data
Christopher Faulet [Fri, 22 Mar 2019 13:54:52 +0000 (14:54 +0100)] 
MEDIUM: proto_htx: Reintroduce the infinite forwarding on data

This commit was reverted because of bugs. Now it should be ok. Difference with
the commit f52170d2f ("MEDIUM: proto_htx: Switch to infinite forwarding if there
is no data filte") is that when the infinite forwarding is enabled, the message
is switched to the state HTTP_MSG_DONE if the flag CF_EOI is set.

6 years agoCLEANUP: muxes/stream-int: Remove flags CS_FL_READ_NULL and SI_FL_READ_NULL
Christopher Faulet [Fri, 22 Mar 2019 13:51:36 +0000 (14:51 +0100)] 
CLEANUP: muxes/stream-int: Remove flags CS_FL_READ_NULL and SI_FL_READ_NULL

Since the flag CF_SHUTR is no more set to mark the end of the message, these
flags become useless.

This patch should be backported to 1.9.

6 years agoBUG/MEDIUM: http/htx: Fix handling of the option abortonclose
Christopher Faulet [Fri, 22 Mar 2019 13:23:18 +0000 (14:23 +0100)] 
BUG/MEDIUM: http/htx: Fix handling of the option abortonclose

Because the flag CF_SHUTR is no more set to mark the end of the message by the
H2 multiplexer, we can rely on it again to detect aborts. there is no more need
to make a check on the flag SI_FL_CLEAN_ABRT when the option abortonclose is
enabled. So, this option should work as before for h2 clients.

This patch must be backported to 1.9 with the previous EOI patches.

6 years agoMINOR: mux-h1: Set CS_FL_EOI the end of the message is reached
Christopher Faulet [Fri, 22 Mar 2019 13:09:41 +0000 (14:09 +0100)] 
MINOR: mux-h1: Set CS_FL_EOI the end of the message is reached

As for the H2 multiplexer, When the end of a message is detected, the flag
CS_FL_EOI is set on the conn_stream.

This patch should be backported to 1.9.

6 years agoMEDIUM: mux-h2: Don't mix the end of the message with the end of stream
Christopher Faulet [Fri, 22 Mar 2019 13:05:52 +0000 (14:05 +0100)] 
MEDIUM: mux-h2: Don't mix the end of the message with the end of stream

The H2 multiplexer now sets CS_FL_EOI when it receives a frame with the ES
flag. And when the H2 streams is closed, it set the flag CS_FL_REOS.

This patch should be backported to 1.9.

6 years agoMINOR: channel: Report EOI on the input channel if it was reached in the mux
Christopher Faulet [Fri, 22 Mar 2019 13:16:14 +0000 (14:16 +0100)] 
MINOR: channel: Report EOI on the input channel if it was reached in the mux

The flag CF_EOI is now set on the input channel when the flag CS_FL_EOI is set
on the corresponding conn_stream. In addition, if a read activity is reported
when this flag is set, the stream is woken up.

This patch should be backported to 1.9.

6 years agoMINOR: connection: and new flag to mark end of input (EOI)
Christopher Faulet [Fri, 22 Mar 2019 13:05:52 +0000 (14:05 +0100)] 
MINOR: connection: and new flag to mark end of input (EOI)

Since the begining, in the H2 multiplexer, when the end of a message is reached,
the flag CS_FL_(R)EOS is set on the conn_stream to notify the upper layer that
all data were received and consumed and there is no longer any expected. The
stream-interface converts it into a shutdown read. But it leads to some
ambiguities with the real shutr. Once it was reported at the end of the message,
there is no way to report it when the read0 is received. For this reason, aborts
after the message was fully received cannot be reported. And on the channel
side, it is hard to make the difference between a shutr because the end of the
message was reached and a shutr because of an abort.

For these reasons, there is now a flag to mark the end of the message. It is
called CS_FL_EOI (end-of-input) because it is only used on the receipt path.
This flag is only declared and not used yet.

This patch will be used by future bug fixes and will have to be backported
to 1.9.

6 years agoMINOR: mux-h2: Remove useless test on ES flag in h2_frt_transfer_data()
Christopher Faulet [Fri, 22 Mar 2019 13:12:11 +0000 (14:12 +0100)] 
MINOR: mux-h2: Remove useless test on ES flag in h2_frt_transfer_data()

Same test is already performed in the caller function, h2c_frt_handle_data().

This patch should be backported to 1.9.

6 years agoBUG/MINOR: proto-http: Don't forward request body anymore on error
Christopher Faulet [Tue, 19 Mar 2019 13:55:11 +0000 (14:55 +0100)] 
BUG/MINOR: proto-http: Don't forward request body anymore on error

In the commit 93e02d8b7 ("MINOR: proto-http/proto-htx: Make error handling
clearer during data forwarding"), a return clause was removed by error in the
function http_request_forward_body(). This bug seems not having any visible
impact.

This patch must be backported to 1.9.

6 years agoBUG/MEDIUM: h2: Try to be fair when sending data.
Olivier Houchard [Fri, 22 Mar 2019 16:37:16 +0000 (17:37 +0100)] 
BUG/MEDIUM: h2: Try to be fair when sending data.

On the send path, try to be fair, and make sure the first to attempt to
send data will actually be the first to send data when it's possible (ie
when the mux' buffer is not full anymore).
To do so, use a separate list element for the sending_list, and only remove
the h2s from the send_list/fctl_list if we successfully sent data. If we did
not, we'll keep our place in the list, and will be able to try again next time.

This should be backported to 1.9.

6 years agoBUG/MINOR: log: properly format IPv6 address when LOG_OPT_HEXA modifier is used.
Radek Zajic [Fri, 22 Mar 2019 10:21:54 +0000 (10:21 +0000)] 
BUG/MINOR: log: properly format IPv6 address when LOG_OPT_HEXA modifier is used.

In lf_ip(), when LOG_OPT_HEXA modifier is used, there is a code to format the
IP address as a hexadecimal string. This code does not properly handle cases
when the IP address is IPv6. In such case, the code only prints `00000000`.

This patch adds support for IPv6. For legacy IPv4, the format remains
unchanged. If IPv6 socket is used to accept IPv6 connection, the full IPv6
address is returned. For example, IPv6 localhost, ::1, is printed as
00000000000000000000000000000001.

If IPv6 socket accepts IPv4 connection, the IPv4 address is mapped by the
kernel into the IPv4-mapped-IPv6 address space (RFC4291, section 2.5.5.2)
and is formatted as such. For example, 127.0.0.1 becomes ::ffff:127.0.0.1,
which is printed as 00000000000000000000FFFF7F000001.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: ssl: ability to set TLS 1.3 ciphers using ssl-default-server-ciphersuites
Pierre Cheynier [Thu, 21 Mar 2019 16:15:47 +0000 (16:15 +0000)] 
BUG/MEDIUM: ssl: ability to set TLS 1.3 ciphers using ssl-default-server-ciphersuites

Any attempt to put TLS 1.3 ciphers on servers failed with output 'unable
to set TLS 1.3 cipher suites'.

This was due to usage of SSL_CTX_set_cipher_list instead of
SSL_CTX_set_ciphersuites in the TLS 1.3 block (protected by
OPENSSL_VERSION_NUMBER >= 0x10101000L & so).

This should be backported to 1.9 and 1.8.

Signed-off-by: Pierre Cheynier <p.cheynier@criteo.com>
Reported-by: Damien Claisse <d.claisse@criteo.com>
Cc: Emeric Brun <ebrun@haproxy.com>
6 years agoCLEANUP: mux-h2: add some comments to help understand the code
Willy Tarreau [Thu, 21 Mar 2019 18:19:36 +0000 (19:19 +0100)] 
CLEANUP: mux-h2: add some comments to help understand the code

Some functions' roles and usage are far from being obvious, and diving
into this part each time requires deep concentration before starting to
understand who does what. Let's add a few comments which help figure
some of the useful pieces.

6 years agoMINOR: mux-h2: copy small data blocks more often and reduce the number of pauses
Willy Tarreau [Thu, 21 Mar 2019 16:47:28 +0000 (17:47 +0100)] 
MINOR: mux-h2: copy small data blocks more often and reduce the number of pauses

We tend to refrain from sending data a bit too much in the H2 mux :
whenever there are pending data in the buffer and we try to copy
something larger than 1/4 of the buffer we prefer to pause. This
is suboptimal for medium-sized objects which have to send their
headers and later their data.

This patch slightly changes this by allowing a copy of a large block
if it fits at once and if the realign cost is small, i.e. the pending
data are small or the block fits in the contiguous area. Depending on
the object size this measurably improves the download performance by
between 1 and 10%, and possibly lowers the transfer latency for medium
objects.

6 years agoBUG/MEDIUM: mux-h2: Use the right list in h2_stop_senders().
Olivier Houchard [Thu, 21 Mar 2019 14:50:58 +0000 (15:50 +0100)] 
BUG/MEDIUM: mux-h2: Use the right list in h2_stop_senders().

In h2_stop_senders(), when we're about to move the h2s about to send back
to the send_list, because we know the mux is full, instead of putting them
all in the send_list, put them back either in the fctl_list or the send_list
depending on if they are waiting for the flow control or not. This also makes
sure they're inserted in their arrival order and not reversed.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: mux-h2: Don't bother keeping the h2s if detaching and nothing to send.
Olivier Houchard [Thu, 21 Mar 2019 14:48:46 +0000 (15:48 +0100)] 
BUG/MEDIUM: mux-h2: Don't bother keeping the h2s if detaching and nothing to send.

In h2_detach(), don't bother keeping the h2s even if it was waiting for
flow control if we no longer are subscribed for receiving or sending, as
nobody will do anything once we can write in the mux, anyway. Failing to do
so may lead to h2s being kept opened forever.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: mux-h2: Make sure we destroyed the h2s once shutr/shutw is done.
Olivier Houchard [Thu, 21 Mar 2019 14:47:13 +0000 (15:47 +0100)] 
BUG/MEDIUM: mux-h2: Make sure we destroyed the h2s once shutr/shutw is done.

If we're waiting until we can send a shutr and/or a shutw, once we're done
and not considering sending anything, destroy the h2s, and eventually the
h2c if we're done with the whole connection, or it will never be done.

This should be backported to 1.9.

6 years agoRevert "MEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter"
Willy Tarreau [Thu, 21 Mar 2019 17:00:30 +0000 (18:00 +0100)] 
Revert "MEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter"

This reverts commit f52170d2f47efbace729bc88349eb189968df568.

This commit was merged too early, some areas are not ready and
transfers from H1 to H2 often stall. Christopher suggested to wait
for the other parts to be ready before reintroducing it.

6 years agoBUG/MINOR: doc: Be accurate on the behavior on pool-purge-delay.
Olivier Houchard [Tue, 19 Mar 2019 15:44:02 +0000 (16:44 +0100)] 
BUG/MINOR: doc: Be accurate on the behavior on pool-purge-delay.

Setting pool-purge-delay to 0 disables the pool, it doesn't keep the
connection forever, so correctly states this.

This should be backported to 1.9.

6 years agoMINOR: lua: Don't handle the header Expect in lua HTTP applets anymore
Christopher Faulet [Fri, 1 Mar 2019 11:02:08 +0000 (12:02 +0100)] 
MINOR: lua: Don't handle the header Expect in lua HTTP applets anymore

This header is now handled in HTTP analyzers the same way for all HTTP applets.

6 years agoCLEANUP: cache: don't export http_cache_applet anymore
Willy Tarreau [Tue, 19 Mar 2019 08:57:55 +0000 (09:57 +0100)] 
CLEANUP: cache: don't export http_cache_applet anymore

This one can become static since it's not used by http/htx anymore.

6 years agoMINOR: http/applets: Handle all applets intercepting HTTP requests the same way
Christopher Faulet [Fri, 1 Mar 2019 10:44:26 +0000 (11:44 +0100)] 
MINOR: http/applets: Handle all applets intercepting HTTP requests the same way

In addition to stats and cache applets, there are also HTTP applet services
declared in an http-request rule. All these applets are now handled the same
way. Among other things, the header Expect is handled at the same place for all
these applets.

6 years agoMINOR: stats/cache: Handle the header Expect when applets are registered
Christopher Faulet [Fri, 1 Mar 2019 10:36:26 +0000 (11:36 +0100)] 
MINOR: stats/cache: Handle the header Expect when applets are registered

First of all, it is a way to handle 100-Continue for the cache without
duplicating code. Then, for the stats, it is no longer necessary to wait for the
request body.

6 years agoMINOR: proto_htx: Add function to handle the header "Expect: 100-continue"
Christopher Faulet [Fri, 1 Mar 2019 10:19:40 +0000 (11:19 +0100)] 
MINOR: proto_htx: Add function to handle the header "Expect: 100-continue"

The function htx_handle_expect_hdr() is now responsible to search the header
"Expect" and send the corresponding response if necessary.

6 years agoMINOR: proto_http: Add function to handle the header "Expect: 100-continue"
Christopher Faulet [Fri, 1 Mar 2019 10:16:34 +0000 (11:16 +0100)] 
MINOR: proto_http: Add function to handle the header "Expect: 100-continue"

The function http_handle_expect_hdr() is now responsible to search the header
"Expect" and send the corresponding response if necessary.

6 years agoBUG/MEDIUM: lua: Fully consume large requests when an HTTP applet ends
Christopher Faulet [Wed, 27 Feb 2019 21:06:23 +0000 (22:06 +0100)] 
BUG/MEDIUM: lua: Fully consume large requests when an HTTP applet ends

In Lua, when an HTTP applet ends (in HTX and legacy HTTP), we must flush
remaining outgoing data on the request. But only outgoing data at time the
applet is called are consumed. If a request with a huge body is sent, an error
is triggerred because a SHUTW is catched for an unfinisehd request.

Now, we consume request data until the end. In fact, we don't try to shutdown
the request's channel for write anymore.

This patch must be backported to 1.9 after some observation period. It should
probably be backported in prior versions too. But honnestly, with refactoring
on the connection layer and the stream interface in 1.9, it is probably safer
to not do so.