]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
5 years agoBUILD/MEDIUM: threads: enable cpu_affinity on osx
David Carlier [Fri, 13 Sep 2019 04:12:58 +0000 (05:12 +0100)] 
BUILD/MEDIUM: threads: enable cpu_affinity on osx

Enable it but on a per thread basis only using Darwin native API.

5 years agoBUILD/SMALL: threads: enable threads on osx
David Carlier [Fri, 13 Sep 2019 03:39:21 +0000 (04:39 +0100)] 
BUILD/SMALL: threads: enable threads on osx

Enable multi thread on Darwin platform too.

5 years agoBUILD/MEDIUM: threads: rename thread_info struct to ha_thread_info
David Carlier [Fri, 13 Sep 2019 04:03:12 +0000 (05:03 +0100)] 
BUILD/MEDIUM: threads: rename thread_info struct to ha_thread_info

On Darwin, the thread_info name exists as a standard function thus
we need to rename our array to ha_thread_info to fix this conflict.

5 years agoBUILD: travis-ci: limit build to branches "master" and "next"
Willy Tarreau [Thu, 17 Oct 2019 04:53:55 +0000 (06:53 +0200)] 
BUILD: travis-ci: limit build to branches "master" and "next"

Occasionally some short-lived branches are pushed to help developers
rebase their work, these ones do not need to be built. This patch
explicitly lists "master" and "next" as the two only branches of
interest. It also adds a comment with the URL for the build status.

5 years agoMINOR: mux-h1: Force close mode for proxy responses with an unfinished request
Christopher Faulet [Wed, 16 Oct 2019 07:41:07 +0000 (09:41 +0200)] 
MINOR: mux-h1: Force close mode for proxy responses with an unfinished request

When a response generated by HAProxy is handled by the mux H1, if the
corresponding request has not fully been received, the close mode is
forced. Thus, the client is notified the connection will certainly be closed
abruptly, without waiting the end of the request.

5 years agoMINOR: htx: Add a flag on HTX to known when a response was generated by HAProxy
Christopher Faulet [Wed, 16 Oct 2019 07:38:27 +0000 (09:38 +0200)] 
MINOR: htx: Add a flag on HTX to known when a response was generated by HAProxy

The flag HTX_FL_PROXY_RESP is now set on responses generated by HAProxy,
excluding responses returned by applets and services. It is an informative flag
set by the applicative layer.

5 years agoBUG/MINOR: http-htx: Properly set htx flags on error files to support keep-alive
Christopher Faulet [Wed, 16 Oct 2019 07:09:04 +0000 (09:09 +0200)] 
BUG/MINOR: http-htx: Properly set htx flags on error files to support keep-alive

When an error file was loaded, the flag HTX_SL_F_XFER_LEN was never set on the
HTX start line because of a bug. During the headers parsing, the flag
H1_MF_XFER_LEN is never set on the h1m. But it was the condition to set
HTX_SL_F_XFER_LEN on the HTX start-line. Instead, we must only rely on the flags
H1_MF_CLEN or H1_MF_CHNK.

Because of this bug, it was impossible to keep a connection alive for a response
generated by HAProxy. Now the flag HTX_SL_F_XFER_LEN is set when an error file
have a content length (chunked responses are unsupported at this stage) and the
connection may be kept alive if there is no connection header specified to
explicitly close it.

This patch must be backported to 2.0 and 1.9.

5 years agoMINOR: version: make the version strings variables, not constants
Willy Tarreau [Wed, 16 Oct 2019 07:44:55 +0000 (09:44 +0200)] 
MINOR: version: make the version strings variables, not constants

It currently is not possible to figure the exact haproxy version from a
core file for the sole reason that the version is stored into a const
string and as such ends up in the .text section that is not part of a
core file. By turning them into variables we move them to the data
section and they appear in core files. In order to help finding them,
we just prepend an extra variable in front of them and we're able to
immediately spot the version strings from a core file:

  $ strings core | fgrep -A2 'HAProxy version'
  HAProxy version follows
  2.1-dev2-e0f48a-88
  2019/10/15

(These are haproxy_version and haproxy_date respectively). This may be
backported to 2.0 since this part is not support to impact anything but
the developer's time spent debugging.

5 years agoBUG/MINOR: ssl: can't load ocsp files
William Lallemand [Tue, 15 Oct 2019 11:44:57 +0000 (13:44 +0200)] 
BUG/MINOR: ssl: can't load ocsp files

246c024 ("MINOR: ssl: load the ocsp in/from the ckch") broke the loading
of OCSP files. The function ssl_sock_load_ocsp_response_from_file() was
not returning 0 upon success which lead to an error after the .ocsp was
read.

5 years agoBUG/MINOR: ssl: fix error messages for OCSP loading
William Lallemand [Tue, 15 Oct 2019 08:05:37 +0000 (10:05 +0200)] 
BUG/MINOR: ssl: fix error messages for OCSP loading

The error messages for OCSP in ssl_sock_load_crt_file_into_ckch() add a
double extension to the filename, that can be confusing. The messages
reference a .issuer.issuer file.

5 years agoBUG/MINOR: WURFL: fix send_log() function arguments
Miroslav Zagorac [Mon, 14 Oct 2019 15:15:56 +0000 (17:15 +0200)] 
BUG/MINOR: WURFL: fix send_log() function arguments

If the user agent data contains text that has special characters that
are used to format the output from the vfprintf() function, haproxy
crashes.  String "%s %s %s" may be used as an example.

% curl -A "%s %s %s" localhost:10080/index.html
curl: (52) Empty reply from server

haproxy log:
00000000:WURFL-test.clireq[00c7:ffffffff]: GET /index.html HTTP/1.1
00000000:WURFL-test.clihdr[00c7:ffffffff]: host: localhost:10080
00000000:WURFL-test.clihdr[00c7:ffffffff]: user-agent: %s %s %s
00000000:WURFL-test.clihdr[00c7:ffffffff]: accept: */*
segmentation fault (core dumped)

gdb 'where' output:
#0  strlen () at ../sysdeps/x86_64/strlen.S:106
#1  0x00007f7c014a8da8 in _IO_vfprintf_internal (s=s@entry=0x7ffc808fe750, format=<optimized out>,
    format@entry=0x7ffc808fe9c0 "WURFL: retrieve header request returns [%s %s %s]\n",
    ap=ap@entry=0x7ffc808fe8b8) at vfprintf.c:1637
#2  0x00007f7c014cfe89 in _IO_vsnprintf (
    string=0x55cb772c34e0 "WURFL: retrieve header request returns [(null) %s %s %s  B,w\313U",
    maxlen=<optimized out>,
    format=format@entry=0x7ffc808fe9c0 "WURFL: retrieve header request returns [%s %s %s]\n",
    args=args@entry=0x7ffc808fe8b8) at vsnprintf.c:114
#3  0x000055cb758f898f in send_log (p=p@entry=0x0, level=level@entry=5,
    format=format@entry=0x7ffc808fe9c0 "WURFL: retrieve header request returns [%s %s %s]\n")
    at src/log.c:1477
#4  0x000055cb75845e0b in ha_wurfl_log (
    message=message@entry=0x55cb75989460 "WURFL: retrieve header request returns [%s]\n") at src/wurfl.c:47
#5  0x000055cb7584614a in ha_wurfl_retrieve_header (header_name=<optimized out>, wh=0x7ffc808fec70)
    at src/wurfl.c:763

In case WURFL (actually HAProxy) is not compiled with debug option
enabled (-DWURFL_DEBUG), this bug does not come to light.

This patch could be backported in every version supporting
the ScientiaMobile's WURFL. (as far as 1.7)

5 years agoREGTESTS: Adapt proxy_protocol_random_fail.vtc to match normalized URI too
Christopher Faulet [Mon, 14 Oct 2019 14:22:03 +0000 (16:22 +0200)] 
REGTESTS: Adapt proxy_protocol_random_fail.vtc to match normalized URI too

Now, full URI are reported in logs for H2 requests.

5 years agoREGTESTS: Send valid URIs in peers reg-tests and fix HA config to avoid warnings
Christopher Faulet [Mon, 14 Oct 2019 14:10:52 +0000 (16:10 +0200)] 
REGTESTS: Send valid URIs in peers reg-tests and fix HA config to avoid warnings

Absolute path must be used, otherwise, the requests are rejected by HAProxy
because of the recent changes. In addition, the configuration has been slightly
updated to remove warnings at startup.

5 years agoMINOR: h1: Reject requests if the authority does not match the header host
Christopher Faulet [Fri, 11 Oct 2019 11:34:22 +0000 (13:34 +0200)] 
MINOR: h1: Reject requests if the authority does not match the header host

As stated in the RCF7230#5.4, a client must send a field-value for the header
host that is identical to the authority if the target URI includes one. So, now,
by default, if the authority, when provided, does not match the value of the
header host, an error is triggered. To mitigate this behavior, it is possible to
set the option "accept-invalid-http-request". In that case, an http error is
captured without interrupting the request parsing.

5 years agoMINOR: h1: Reject requests with different occurrences of the header host
Christopher Faulet [Fri, 11 Oct 2019 07:01:44 +0000 (09:01 +0200)] 
MINOR: h1: Reject requests with different occurrences of the header host

There is no reason for a client to send several headers host. It even may be
considered as a bug. However, it is totally invalid to have different values for
those. So now, in such case, an error is triggered during the request
parsing. In addition, when several headers host are found with the same value,
only the first instance is kept and others are skipped.

5 years agoBUG/MINOR: mux-h1: Capture ignored parsing errors
Christopher Faulet [Fri, 11 Oct 2019 12:22:00 +0000 (14:22 +0200)] 
BUG/MINOR: mux-h1: Capture ignored parsing errors

When the option "accept-invalid-http-request" is enabled, some parsing errors
are ignored. But the position of the error is reported. In legacy HTTP mode,
such errors were captured. So, we now do the same in the H1 multiplexer.

If required, this patch may be backported to 2.0 and 1.9.

5 years agoCLEANUP: h1-htx: Move htx-to-h1 formatting functions from htx.c to h1_htx.c
Christopher Faulet [Tue, 8 Oct 2019 14:38:42 +0000 (16:38 +0200)] 
CLEANUP: h1-htx: Move htx-to-h1 formatting functions from htx.c to h1_htx.c

The functions "htx_*_to_h1()" have been renamed into "h1_format_htx_*()" and
moved in the file h1_htx.c. It is the right place for such functions.

5 years agoMINOR: mux-h1: Xfer as much payload data as possible during output processing
Christopher Faulet [Mon, 14 Oct 2019 12:01:24 +0000 (14:01 +0200)] 
MINOR: mux-h1: Xfer as much payload data as possible during output processing

When an outgoing HTX message is formatted to a raw message, DATA blocks may be
splitted to not tranfser more data than expected. But if the buffer is almost
full, the formatting is interrupted, leaving some unused free space in the
buffer, because data are too large to be copied in one time.

Now, we transfer as much data as possible. When the message is chunked, we also
count the size used to encode the data.

5 years agoBUG/MINOR: mux-h1: Mark the output buffer as full when the xfer is interrupted
Christopher Faulet [Mon, 14 Oct 2019 12:17:00 +0000 (14:17 +0200)] 
BUG/MINOR: mux-h1: Mark the output buffer as full when the xfer is interrupted

When an outgoing HTX message is formatted to a raw message, if we fail to copy
data of an HTX block into the output buffer, we mark it as full. Before it was
only done calling the function buf_room_for_htx_data(). But this function is
designed to optimize input processing.

This patch must be backported to 2.0 and 1.9.

5 years agoBUG/MINOR: chunk: Fix tests on the chunk size in functions copying data
Christopher Faulet [Mon, 14 Oct 2019 09:29:48 +0000 (11:29 +0200)] 
BUG/MINOR: chunk: Fix tests on the chunk size in functions copying data

When raw data are copied or appended in a chunk, the result must not exceed the
chunk size but it can reach it. Unlike functions to copy or append a string,
there is no terminating null byte.

This patch must be backported as far as 1.8. Note in 1.8, the functions
chunk_cpy() and chunk_cat() don't exist.

5 years agoBUG/MEDIUM: htx: Catch chunk_memcat() failures when HTX data are formatted to h1
Christopher Faulet [Mon, 14 Oct 2019 12:36:51 +0000 (14:36 +0200)] 
BUG/MEDIUM: htx: Catch chunk_memcat() failures when HTX data are formatted to h1

In functions htx_*_to_h1(), most of time several calls to chunk_memcat() are
chained. The expected size is always compared to available room in the buffer to
be sure the full copy will succeed. But it is a bit risky because it relies on
the fact the function chunk_memcat() evaluates the available room in the buffer
in a same way than htx ones. And, unfortunately, it does not. A bug in
chunk_memcat() will always leave a byte unused in the buffer. So, for instance,
when a chunk is copied in an almost full buffer, the last CRLF may be skipped.

To fix the issue, we now rely on the result of chunk_memcat() only.

This patch must be backported to 2.0 and 1.9.

5 years agoBUG/MINOR: ssl: fix OCSP build with BoringSSL
William Lallemand [Mon, 14 Oct 2019 12:51:41 +0000 (14:51 +0200)] 
BUG/MINOR: ssl: fix OCSP build with BoringSSL

246c024 broke the build of the OCSP code with BoringSSL.

Rework it a little so it could load the OCSP buffer of the ckch.

Issue #322.

5 years agoBUILD: ssl: wrong #ifdef for SSL engines code
William Lallemand [Mon, 14 Oct 2019 12:14:59 +0000 (14:14 +0200)] 
BUILD: ssl: wrong #ifdef for SSL engines code

The SSL engines code was written below the OCSP #ifdef, which means you
can't build the engines code if the OCSP is deactived in the SSL lib.

Could be backported in every version since 1.8.

5 years agoBUG/MINOR: ssl: fix build without multi-cert bundles
William Lallemand [Mon, 14 Oct 2019 09:38:36 +0000 (11:38 +0200)] 
BUG/MINOR: ssl: fix build without multi-cert bundles

Commit 150bfa8 broke the build with ssl libs that does not support
multi certificate bundles.

Issue #322.

5 years agoBUG/MINOR: ssl: fix build without SSL
William Lallemand [Mon, 14 Oct 2019 09:12:35 +0000 (11:12 +0200)] 
BUG/MINOR: ssl: fix build without SSL

Commits 222a7c6 and 150bfa8 introduced some SSL initialization in
bind_conf_alloc() which broke the build without SSL.

Issue #322.

5 years agoBUG/MEDIUM: ssl: NULL dereference in ssl_sock_load_cert_sni()
William Lallemand [Mon, 14 Oct 2019 08:46:58 +0000 (10:46 +0200)] 
BUG/MEDIUM: ssl: NULL dereference in ssl_sock_load_cert_sni()

A NULL dereference can occur when inserting SNIs. In the case of
checking for duplicates, if there is already several sni_ctx with the
same key.

Fix issue #321.

6 years agoMINOR: ssl: load the ocsp in/from the ckch
William Lallemand [Fri, 11 Oct 2019 06:59:13 +0000 (08:59 +0200)] 
MINOR: ssl: load the ocsp in/from the ckch

Don't try to load the files containing the issuer and the OCSP response
each time we generate a SSL_CTX.

The .ocsp and the .issuer are now loaded in the struct
cert_key_and_chain only once and then loaded from this structure when
creating a SSL_CTX.

6 years agoMINOR: ssl: load the sctl in/from the ckch
William Lallemand [Thu, 10 Oct 2019 13:16:44 +0000 (15:16 +0200)] 
MINOR: ssl: load the sctl in/from the ckch

Don't try to load the file containing the sctl each time we generate a
SSL_CTX.

The .sctl is now loaded in the struct cert_key_and_chain only once and
then loaded from this structure when creating a SSL_CTX.

Note that this now make possible the use of sctl with multi-cert
bundles.

6 years agoMEDIUM: ssl/cli: 'set ssl cert' updates a certificate from the CLI
William Lallemand [Thu, 19 Sep 2019 15:12:49 +0000 (17:12 +0200)] 
MEDIUM: ssl/cli: 'set ssl cert' updates a certificate from the CLI

    $ echo -e "set ssl cert certificate.pem <<\n$(cat certificate2.pem)\n" | \
    socat stdio /var/run/haproxy.stat
    Certificate updated!

The operation is locked at the ckch level with a HA_SPINLOCK_T which
prevents the ckch architecture (ckch_store, ckch_inst..) to be modified
at the same time. So you can't do a certificate update at the same time
from multiple CLI connections.

SNI trees are also locked with a HA_RWLOCK_T so reading operations are
locked only during a certificate update.

Bundles are supported but you need to update each file (.rsa|ecdsa|.dsa)
independently. If a file is used in the configuration as a bundle AND
as a unique certificate, both will be updated.

Bundles, directories and crt-list are supported, however filters in
crt-list are currently unsupported.

The code tries to allocate every SNIs and certificate instances first,
so it can rollback the operation if that was unsuccessful.

If you have too much instances of the certificate (at least 20000 in my
tests on my laptop), the function can take too much time and be killed
by the watchdog. This will be fixed later. Also with too much
certificates it's possible that socat exits before the end of the
generation without displaying a message, consider changing the socat
timeout in this case (-t2 for example).

The size of the certificate is currently limited by the maximum size of
a payload, that must fit in a buffer.

6 years agoMINOR: ssl: ssl_sock_load_crt_file_into_ckch() is filling from a BIO
William Lallemand [Thu, 19 Sep 2019 12:25:58 +0000 (14:25 +0200)] 
MINOR: ssl: ssl_sock_load_crt_file_into_ckch() is filling from a BIO

The function ssl_sock_load_crt_file_into_ckch() is now able to fill a
ckch using a BIO in input.

6 years agoMEDIUM: ssl: ssl_sock_load_ckchs() alloc a ckch_inst
William Lallemand [Mon, 7 Oct 2019 11:52:11 +0000 (13:52 +0200)] 
MEDIUM: ssl: ssl_sock_load_ckchs() alloc a ckch_inst

The ssl_sock_load_{multi}_ckchs() function were renamed and modified:

- allocate a ckch_inst and loads the sni in it
- return a ckch_inst or NULL
- the sni_ctx are not added anymore in the sni trees from there
- renamed in ckch_inst_new_load_{multi}_store()
- new ssl_sock_load_ckchs() function calls
ckch_inst_new_load_{multi}_store() and add the sni_ctx to the sni trees.

6 years agoMINOR: ssl: ssl_sock_load_multi_ckchs() can properly fail
William Lallemand [Fri, 4 Oct 2019 16:38:51 +0000 (18:38 +0200)] 
MINOR: ssl: ssl_sock_load_multi_ckchs() can properly fail

ssl_sock_load_multi_ckchs() is now able to fail without polluting the
bind_conf trees and leaking memory.

It is a prerequisite to load certificate on-the-fly with the CLI.

The insertion of the sni_ctxs in the trees are done once everything has
been allocated correctly.

6 years agoMINOR: ssl: ssl_sock_load_ckchn() can properly fail
William Lallemand [Fri, 4 Oct 2019 13:37:05 +0000 (15:37 +0200)] 
MINOR: ssl: ssl_sock_load_ckchn() can properly fail

ssl_sock_load_ckchn() is now able to fail without polluting the
bind_conf trees and leaking memory.

It is a prerequisite to load certificate on-the-fly with the CLI.

The insertion of the sni_ctxs in the trees are done once everything has
been allocated correctly.

6 years agoMEDIUM: ssl: split ssl_sock_add_cert_sni()
William Lallemand [Thu, 3 Oct 2019 22:53:29 +0000 (00:53 +0200)] 
MEDIUM: ssl: split ssl_sock_add_cert_sni()

In order to allow the creation of sni_ctx in runtime, we need to split
the function to allow rollback.

We need to be able to allocate all sni_ctxs required before inserting
them in case we need to rollback if we didn't succeed the allocation.

The function was splitted in 2 parts.

The first one ckch_inst_add_cert_sni() allocates a struct sni_ctx, fill
it with the right data and insert it in the ckch_inst's list of sni_ctx.

The second will take every sni_ctx in the ckch_inst and insert them in
the bind_conf's sni tree.

6 years agoMEDIUM: ssl: introduce the ckch instance structure
William Lallemand [Thu, 3 Oct 2019 22:29:42 +0000 (00:29 +0200)] 
MEDIUM: ssl: introduce the ckch instance structure

struct ckch_inst represents an instance of a certificate (ckch_node)
used in a bind_conf. Every sni_ctx created for 1 ckch_node in a
bind_conf are linked in this structure.

This patch allocate the ckch_inst for each bind_conf and inserts the
sni_ctx in its linked list.

6 years agoBUG/MINOR: ssl: abort on sni_keytypes allocation failure
William Lallemand [Fri, 4 Oct 2019 15:36:55 +0000 (17:36 +0200)] 
BUG/MINOR: ssl: abort on sni_keytypes allocation failure

The ssl_sock_populate_sni_keytypes_hplr() function does not return an
error upon an allocation failure.

The process would probably crash during the configuration parsing if the
allocation fail since it tries to copy some data in the allocated
memory.

This patch could be backported as far as 1.5.

6 years agoBUG/MINOR: ssl: free the sni_keytype nodes
William Lallemand [Fri, 4 Oct 2019 15:24:39 +0000 (17:24 +0200)] 
BUG/MINOR: ssl: free the sni_keytype nodes

This patch frees the sni_keytype nodes once the sni_ctxs have been
allocated in ssl_sock_load_multi_ckchn();

Could be backported in every version using the multi-cert SSL bundles.

6 years agoBUG/MINOR: ssl: abort on sni allocation failure
William Lallemand [Thu, 3 Oct 2019 21:46:33 +0000 (23:46 +0200)] 
BUG/MINOR: ssl: abort on sni allocation failure

The ssl_sock_add_cert_sni() function never return an error when a
sni_ctx allocation fail. It silently ignores the problem and continues
to try to allocate other snis.

It is unlikely that a sni allocation will succeed after one failure and
start a configuration without all the snis. But to avoid any problem we
return a -1 upon an sni allocation error and stop the configuration
parsing.

This patch must be backported in every version supporting the crt-list
sni filters. (as far as 1.5)

6 years agoMINOR: ssl: initialize explicitly the sni_ctx trees
William Lallemand [Fri, 4 Oct 2019 09:44:57 +0000 (11:44 +0200)] 
MINOR: ssl: initialize explicitly the sni_ctx trees

6 years agoMINOR: ssl: initialize the sni_keytypes_map as EB_ROOT
William Lallemand [Fri, 4 Oct 2019 16:36:55 +0000 (18:36 +0200)] 
MINOR: ssl: initialize the sni_keytypes_map as EB_ROOT

The sni_keytypes_map was initialized to {0}, it's better to initialize
it explicitly to EB_ROOT

6 years agoREORG: ssl: move structures to ssl_sock.h
William Lallemand [Wed, 11 Sep 2019 14:33:52 +0000 (16:33 +0200)] 
REORG: ssl: move structures to ssl_sock.h

6 years agoREORG: ssl: rename ckch_node to ckch_store
William Lallemand [Tue, 8 Oct 2019 09:36:53 +0000 (11:36 +0200)] 
REORG: ssl: rename ckch_node to ckch_store

A ckch_store is a storage which contains a pointer to one or several
cert_key_and_chain structures.

This patch renames ckch_node to ckch_store, and ckch_n, ckchn to ckchs.

6 years agoMINOR: ssl: crt-list do ckchn_lookup
William Lallemand [Thu, 10 Oct 2019 09:38:13 +0000 (11:38 +0200)] 
MINOR: ssl: crt-list do ckchn_lookup

6 years agoMINOR: mux-h2: also support emitting CONTINUATION on trailers
Willy Tarreau [Fri, 11 Oct 2019 14:58:37 +0000 (16:58 +0200)] 
MINOR: mux-h2: also support emitting CONTINUATION on trailers

Trailers were forgotten by commit cb985a4da6 ("MEDIUM: mux-h2: support
emitting CONTINUATION frames after HEADERS"), this one just fixes this
miss.

6 years agoMINOR: lists: Fix alignement of \ when relevant.
Olivier Houchard [Fri, 11 Oct 2019 14:57:43 +0000 (16:57 +0200)] 
MINOR: lists: Fix alignement of \ when relevant.

Make sure all the \ are properly aligned in macroes, this contains no
functional change.

6 years agoMINOR: lists: Try to use local variables instead of macro arguments.
Olivier Houchard [Fri, 11 Oct 2019 14:55:11 +0000 (16:55 +0200)] 
MINOR: lists: Try to use local variables instead of macro arguments.

When possible, use local variables instead of using the macro arguments
explicitely, otherwise they may be evaluated over and over.

6 years agoMINOR: h2: Document traps to be avoided on multithread.
Olivier Houchard [Fri, 11 Oct 2019 14:33:49 +0000 (16:33 +0200)] 
MINOR: h2: Document traps to be avoided on multithread.

Document a few traps to avoid if we ever attempt to allow the upper layer
of the mux h2 to be run by multiple threads.

6 years agoMEDIUM: task: Split the tasklet list into two lists.
Olivier Houchard [Fri, 11 Oct 2019 14:35:01 +0000 (16:35 +0200)] 
MEDIUM: task: Split the tasklet list into two lists.

As using an mt_list for the tasklet list is costly, instead use a regular list,
but add an mt_list for tasklet woken up by other threads, to be run on the
current thread. At the beginning of process_runnable_tasks(), we just take
the new list, and merge it into the task_list.
This should give us performances comparable to before we started using a
mt_list, but allow us to use tasklet_wakeup() from other threads.

6 years agoMINOR: list: add new macro MT_LIST_BEHEAD
Willy Tarreau [Fri, 4 Oct 2019 16:02:40 +0000 (18:02 +0200)] 
MINOR: list: add new macro MT_LIST_BEHEAD

This macro atomically cuts the head of a list and returns the list
of elements as a detached list, meaning that they're all linked
together without any head. If the list was empty, NULL is returned.

6 years agoMINOR: lists: add new macro LIST_SPLICE_END_DETACHED
Willy Tarreau [Fri, 4 Oct 2019 16:01:39 +0000 (18:01 +0200)] 
MINOR: lists: add new macro LIST_SPLICE_END_DETACHED

This macro adds a detached list at the end of an existing
list. The detached list is a list without head, containing
only elements.

6 years agoBUILD: stats: fix missing '=' sign in array declaration
Willy Tarreau [Fri, 11 Oct 2019 14:31:46 +0000 (16:31 +0200)] 
BUILD: stats: fix missing '=' sign in array declaration

I introduced this mistake when adding the description for the stats
metrics, it's even amazing it built and worked at all! This was
reported by Travis CI on non-GNU platforms :

src/stats.c:92:39: warning: use of GNU 'missing =' extension in designator [-Wgnu-designator]
    [INF_NAME]               { .name = "Name",                        .desc = "Product name" },
                             ^
                             =
No backport is needed.

6 years agoBUG/MEDIUM: applet: always check a fast running applet's activity before killing
Willy Tarreau [Fri, 11 Oct 2019 12:15:47 +0000 (14:15 +0200)] 
BUG/MEDIUM: applet: always check a fast running applet's activity before killing

In issue #277 is reported a strange problem related to a fast-spinning
applet which seems to show valid progress being made. It's uncertain how
this can happen, maybe some very specific timing patterns manage to place
just a few bytes in each buffer and result in the peers applet being called
a lot. But it appears possible to artificially cross the spinning threshold
by asking for monster stats page (500 MB) and limiting the send() size to
1 MSS (1460 bytes), causing the stats page to be called for very small
blocks which most often do not leave enough room to place a new chunk.

The idea developed in this patch consists in not crashing for an applet
which reaches a very high call rate if it shows some indication of
progress. Detecting progress on applets is not trivial but in our case
we know that they must at least not claim to wait for a buffer allocation
if this buffer is present, wait for room if the buffer is empty, ask for
more data without polling if such data are still present, nor leave with
an empty input buffer without having written anything nor read anything
from the other side while a shutw is pending.

Doing so doesn't affect normal behaviors nor abuses of our existing
applets and does at least protect against an applet performing an
early return without processing events, or one causing an endless
loop by asking for impossible conditions.

This must be backported to 2.0.

6 years agoMINOR: stats: fill all the descriptions for "show info" and "show stat"
Willy Tarreau [Wed, 9 Oct 2019 14:41:38 +0000 (16:41 +0200)] 
MINOR: stats: fill all the descriptions for "show info" and "show stat"

Now "show info desc", "show info typed desc" and "show stat typed desc"
will report (hopefully) accurate descriptions of each field. These ones
were verified in the code. When some metrics are specific to the process
or the thread, they are indicated. Sometimes a config option is known
for a setting and it is reported as well. The purpose mainly is to help
sysadmins in field more easily sort out issues vs non-issues. In part
inspired by this very informative talk :

    https://kernel-recipes.org/en/2019/metrics-are-money/

Example:

  $ socat - /var/run/haproxy.sock <<< "show info desc"
  Name: HAProxy:"Product name"
  Version: 2.1-dev2-991035-31:"Product version"
  Release_date: 2019/10/09:"Date of latest source code update"
  Nbthread: 1:"Number of started threads (global.nbthread)"
  Nbproc: 1:"Number of started worker processes (global.nbproc)"
  Process_num: 1:"Relative process number (1..Nbproc)"
  Pid: 11975:"This worker process identifier for the system"
  Uptime: 0d 0h00m10s:"How long ago this worker process was started (days+hours+minutes+seconds)"
  Uptime_sec: 10:"How long ago this worker process was started (seconds)"
  Memmax_MB: 0:"Worker process's hard limit on memory usage in MB (-m on command line)"
  PoolAlloc_MB: 0:"Amount of memory allocated in pools (in MB)"
  PoolUsed_MB: 0:"Amount of pool memory currently used (in MB)"
  PoolFailed: 0:"Number of failed pool allocations since this worker was started"
  Ulimit-n: 300000:"Hard limit on the number of per-process file descriptors"
  Maxsock: 300000:"Hard limit on the number of per-process sockets"
  Maxconn: 149982:"Hard limit on the number of per-process connections (configured or imposed by Ulimit-n)"
  Hard_maxconn: 149982:"Hard limit on the number of per-process connections (imposed by Memmax_MB or Ulimit-n)"
  CurrConns: 0:"Current number of connections on this worker process"
  CumConns: 1:"Total number of connections on this worker process since started"
  CumReq: 1:"Total number of requests on this worker process since started"
  MaxSslConns: 0:"Hard limit on the number of per-process SSL endpoints (front+back), 0=unlimited"
  CurrSslConns: 0:"Current number of SSL endpoints on this worker process (front+back)"
  CumSslConns: 0:"Total number of SSL endpoints on this worker process since started (front+back)"
  Maxpipes: 0:"Hard limit on the number of pipes for splicing, 0=unlimited"
  PipesUsed: 0:"Current number of pipes in use in this worker process"
  PipesFree: 0:"Current number of allocated and available pipes in this worker process"
  ConnRate: 0:"Number of front connections created on this worker process over the last second"
  ConnRateLimit: 0:"Hard limit for ConnRate (global.maxconnrate)"
  MaxConnRate: 0:"Highest ConnRate reached on this worker process since started (in connections per second)"
  SessRate: 0:"Number of sessions created on this worker process over the last second"
  SessRateLimit: 0:"Hard limit for SessRate (global.maxsessrate)"
  MaxSessRate: 0:"Highest SessRate reached on this worker process since started (in sessions per second)"
  SslRate: 0:"Number of SSL connections created on this worker process over the last second"
  SslRateLimit: 0:"Hard limit for SslRate (global.maxsslrate)"
  MaxSslRate: 0:"Highest SslRate reached on this worker process since started (in connections per second)"
  SslFrontendKeyRate: 0:"Number of SSL keys created on frontends in this worker process over the last second"
  SslFrontendMaxKeyRate: 0:"Highest SslFrontendKeyRate reached on this worker process since started (in SSL keys per second)"
  SslFrontendSessionReuse_pct: 0:"Percent of frontend SSL connections which did not require a new key"
  SslBackendKeyRate: 0:"Number of SSL keys created on backends in this worker process over the last second"
  SslBackendMaxKeyRate: 0:"Highest SslBackendKeyRate reached on this worker process since started (in SSL keys per second)"
  SslCacheLookups: 0:"Total number of SSL session ID lookups in the SSL session cache on this worker since started"
  SslCacheMisses: 0:"Total number of SSL session ID lookups that didn't find a session in the SSL session cache on this worker since started"
  CompressBpsIn: 0:"Number of bytes submitted to HTTP compression in this worker process over the last second"
  CompressBpsOut: 0:"Number of bytes out of HTTP compression in this worker process over the last second"
  CompressBpsRateLim: 0:"Limit of CompressBpsOut beyond which HTTP compression is automatically disabled"
  Tasks: 10:"Total number of tasks in the current worker process (active + sleeping)"
  Run_queue: 1:"Total number of active tasks+tasklets in the current worker process"
  Idle_pct: 100:"Percentage of last second spent waiting in the current worker thread"
  node: wtap.local:"Node name (global.node)"
  Stopping: 0:"1 if the worker process is currently stopping, otherwise zero"
  Jobs: 14:"Current number of active jobs on the current worker process (frontend connections, master connections, listeners)"
  Unstoppable Jobs: 0:"Current number of unstoppable jobs on the current worker process (master connections)"
  Listeners: 13:"Current number of active listeners on the current worker process"
  ActivePeers: 0:"Current number of verified active peers connections on the current worker process"
  ConnectedPeers: 0:"Current number of peers having passed the connection step on the current worker process"
  DroppedLogs: 0:"Total number of dropped logs for current worker process since started"
  BusyPolling: 0:"1 if busy-polling is currently in use on the worker process, otherwise zero (config.busy-polling)"
  FailedResolutions: 0:"Total number of failed DNS resolutions in current worker process since started"
  TotalBytesOut: 0:"Total number of bytes emitted by current worker process since started"
  BytesOutRate: 0:"Number of bytes emitted by current worker process over the last second"

6 years agoMINOR: stats: make "show stat" and "show info"
Willy Tarreau [Wed, 9 Oct 2019 13:44:21 +0000 (15:44 +0200)] 
MINOR: stats: make "show stat" and "show info"

Now "show info" supports "desc" after the default and "typed" formats,
and "show stat" supports this after the typed format. In both cases
this appends the description for the represented metric between double
quotes. The same could be done for JSON output but would possibly require
to update the schema first.

6 years agoMINOR: stats: prepare to add a description with each stat/info field
Willy Tarreau [Wed, 9 Oct 2019 05:39:11 +0000 (07:39 +0200)] 
MINOR: stats: prepare to add a description with each stat/info field

Several times some users have expressed the non-intuitive aspect of some
of our stat/info metrics and suggested to add some help. This patch
replaces the char* arrays with an array of name_desc so that we now have
some reserved room to store a description with each stat or info field.
These descriptions are currently empty and not reported yet.

6 years agoMINOR: stats: support the "desc" output format modifier for info and stat
Willy Tarreau [Wed, 9 Oct 2019 09:43:59 +0000 (11:43 +0200)] 
MINOR: stats: support the "desc" output format modifier for info and stat

Now "show info" and "show stat" can parse "desc" as an output format
modifier that will be passed down the chain to add some descriptions
to the fields depending on the format in use. For now it is not
exploited.

6 years agoMINOR: stats: uniformize the calling convention of the dump functions
Willy Tarreau [Wed, 9 Oct 2019 09:27:51 +0000 (11:27 +0200)] 
MINOR: stats: uniformize the calling convention of the dump functions

Some functions used to take flags + appctx with flags==appctx.flags,
others neither, others just one of them. Some functions used to have
the flags before the object being dumped (server) while others had
it after (listener). This patch aims at cleaning this up a little bit
by following this principle:
  - low-level functions which do not need the appctx take flags only
  - medium-level functions which already use the appctx for other
    reasons do not keep the flags
  - top-level functions which already have the stream-int don't need
    the flags nor the appctx.

6 years agoMINOR: stats: make stats_dump_fields_json() directly take flags
Willy Tarreau [Wed, 9 Oct 2019 09:19:29 +0000 (11:19 +0200)] 
MINOR: stats: make stats_dump_fields_json() directly take flags

It used to take an inverted flag for STAT_STARTED, let's make it take
the raw flags instead.

6 years agoMINOR: stats: get rid of the STAT_SHOWADMIN flag
Willy Tarreau [Wed, 9 Oct 2019 09:11:46 +0000 (11:11 +0200)] 
MINOR: stats: get rid of the STAT_SHOWADMIN flag

This flag is used to decide to show the check box in front of a proxy
on the HTML stat page. It is always equal to STAT_ADMIN except when the
proxy has no backend capability (i.e. a pure frontend) or has no server,
in which case it's only used to avoid leaving an empty column at the
beginning of the table. Not only this is pretty useless, but it also
causes the columns not to align well when mixing multiple proxies with
or without servers.

Let's simply always use STAT_ADMIN and get rid of this flag.

6 years agoMINOR: stats: set the appctx flags when initializing the applet only
Willy Tarreau [Wed, 9 Oct 2019 09:00:22 +0000 (11:00 +0200)] 
MINOR: stats: set the appctx flags when initializing the applet only

When "show stat" is emitted on the CLI, we need to set the relevant
flags on the appctx. We must not re-adjust them while dumping a proxy.

6 years agoMINOR: stats: always merge the uri_auth flags into the appctx flags
Willy Tarreau [Wed, 9 Oct 2019 08:50:01 +0000 (10:50 +0200)] 
MINOR: stats: always merge the uri_auth flags into the appctx flags

Now we only use the appctx flags everywhere in the code, and the uri_auth
flags are read only by the HTTP analyser which presets the appctx ones.
This will allow to simplify access to the flags everywhere.

6 years agoMINOR: stats: replace the ST_* uri_auth flags with STAT_*
Willy Tarreau [Wed, 9 Oct 2019 08:19:16 +0000 (10:19 +0200)] 
MINOR: stats: replace the ST_* uri_auth flags with STAT_*

We used to rely on some config flags defined in uri_auth.h set during
parsing, and another set of STAT_* flags defined in stats.h set at run
time, with a somewhat gray area between the two sets. This is confusing
in the stats code as both are called "flags" in various functions and
it's quite hard to know which one describes what.

This patch cleans this up by replacing all ST_* by a newly assigned
value from the STAT_* set so that we can now use unified flags to
describe both the configuration and the current state. There is no
functional change at all.

6 years agoMINOR: stats: get rid of the ST_CONVDONE flag
Willy Tarreau [Wed, 9 Oct 2019 07:59:22 +0000 (09:59 +0200)] 
MINOR: stats: get rid of the ST_CONVDONE flag

This flag was added in 1.4-rc1 by commit 329f74d463 ("[BUG] uri_auth: do
not attemp to convert uri_auth -> http-request more than once") to
address the case where two proxies inherit the stats settings from
the defaults instance, and the first one compiles the expression while
the second one uses it. In this case since they use the exact same
uri_auth pointer, only the first one should compile and the second one
must not fail the check. This was addressed by adding an ST_CONVDONE
flag indicating that the expression conversion was completed and didn't
need to be done again. But this is a hack and it becomes cumbersome in
the middle of the other flags which are all relevant to the stats
applet. Let's instead fix it by checking if we're dealing with an
alias of the defaults instance and refrain from compiling this twice.
This allows us to remove the ST_CONVDONE flag.

A typical config requiring this check is :

   defaults
        mode http
        stats auth foo:bar

   listen l1
        bind :8080

   listen l2
        bind :8181

Without this (or previous) check it would cmoplain when checking l2's
validity since the rule was already built.

6 years agoMINOR: stats: mention in the help message support for "json" and "typed"
Willy Tarreau [Wed, 9 Oct 2019 05:19:02 +0000 (07:19 +0200)] 
MINOR: stats: mention in the help message support for "json" and "typed"

Both "show info" and "show stat" support the "typed" output format and
the "json" output format. I just never can remind them, which is an
indication that some help is missing.

6 years agoMEDIUM: h2: use the normalized URI encoding for absolute form requests
Willy Tarreau [Tue, 8 Oct 2019 16:33:19 +0000 (18:33 +0200)] 
MEDIUM: h2: use the normalized URI encoding for absolute form requests

H2 strongly recommends that clients exclusively use the absolute form
for requests, which contains a scheme, an authority and a path, instead
of the old format involving the Host header and a path. Thus there is
no way to distinguish between a request intended for a proxy and an
origin request, and as such proxied requests are lost.

This patch makes sure to keep the encoding of all absolute form requests
so that the URI is kept end-to-end. If the scheme is http or https, there
is an uncertainty so the request is tagged as a normalized URI so that
the other end (H1) can decide to emit it in origin form as this is by far
the most commonly expected one, and it's certain that quite a number of
H1 setups are not ready to cope with absolute URIs.

There is a direct visible impact of this change, which is that the uri
sample fetch will now return absolute URIs (as they really come on the
wire) whenever these are used. It also means that default http logs will
report absolute URIs.

If a situation is once met where a client uses H2 to join an H1 proxy
with haproxy in the middle, then it will be trivial to add an option to
ask the H1 output to use absolute encoding for such requests.

Later we may be able to consider that the normalized URI is the default
output format and stop sending them in origin form unless an option is
set.

Now chaining multiple instances keeps the semantics as far as possible
along the whole chain :

 1) H1 to H1
  H1:"GET /"       --> H1:"GET /"       # log: /
  H1:"GET http://" --> H1:"GET http://" # log: http://
  H1:"GET ftp://"  --> H1:"GET ftp://"  # log: ftp://

 2) H2 to H1
  H2:"GET /"       --> H1:"GET /"       # log: /
  H2:"GET http://" --> H1:"GET /"       # log: http://
  H2:"GET ftp://"  --> H1:"GET ftp://"  # log: ftp://

 3) H1 to H2 to H2 to H1
  H1:"GET /"       --> H2:"GET /"       --> H2:"GET /"       --> H1:"GET /"
  H1:"GET http://" --> H2:"GET http://" --> H2:"GET http://" --> H1:"GET /"
  H1:"GET ftp://"  --> H2:"GET ftp://"  --> H2:"GET ftp://"  --> H1:"GET ftp://"

Thus there is zero loss on H1->H1, H1->H2 nor H2->H2, and H2->H1 is
normalized in origin format if ambiguous.

6 years agoMEDIUM: mux-h2: do not map Host to :authority on output
Willy Tarreau [Tue, 8 Oct 2019 16:16:18 +0000 (18:16 +0200)] 
MEDIUM: mux-h2: do not map Host to :authority on output

Instead of mapping the Host header field to :authority, we now act
differently if the request is in origin form or in absolute form.
If it's absolute, we extract the scheme and the authority from the
request, fix the path if it's empty, and drop the Host header.
Otherwise we take the scheme from the http/https flags in the HTX
layer, make the URI be the path only, and emit the Host header,
as indicated in RFC7540#8.1.2.3. This allows to distinguish between
absolute and origin requests for H1 to H2 conversions.

6 years agoMINOR: h2: report in the HTX flags when the request has an authority
Willy Tarreau [Tue, 8 Oct 2019 15:34:50 +0000 (17:34 +0200)] 
MINOR: h2: report in the HTX flags when the request has an authority

The other side will need to know when to emit an authority or not. We
need to pass this information in the HTX flags.

6 years agoMEDIUM: h2: make the request parser rebuild a complete URI
Willy Tarreau [Tue, 8 Oct 2019 14:53:07 +0000 (16:53 +0200)] 
MEDIUM: h2: make the request parser rebuild a complete URI

Till now we've been producing path components of the URI and using the
:authority header only to be placed into the host part. But this practice
is not correct, as if we're used to convey H1 proxy requests over H2 then
over H1, the absolute URI is presented as a path on output, which is not
valid. In addition the scheme on output is not updated from the absolute
URI either.

Now the request parser will continue to deliver origin-form for request
received using the http/https schemes, but will use the absolute-form
when dealing with other schemes, by concatenating the scheme, the authority
and the path if it's not '*'.

6 years agoMINOR: h1-htx: Only use the path of a normalized URI to format a request line
Christopher Faulet [Tue, 8 Oct 2019 13:43:39 +0000 (15:43 +0200)] 
MINOR: h1-htx: Only use the path of a normalized URI to format a request line

When a request start-line is converted to its raw representation, if its URI is
normalized, only the path part is used. Most of H2 clients send requests using
the absolute form (:scheme + :authority + :path), regardless the request is sent
to a proxy or not. But, when the request is relayed to an H1 origin server, it
is unusual to send it using the absolute form. And, even if the servers must
support this form, some old servers may reject it. So, for such requests, we
only get the path of the absolute URI. Most of time, it will be the right
choice. However, an option will probably by added to customize this behavior.

6 years agoMEDIUM: http-htx: Keep the Host header and the request start-line synchronized
Christopher Faulet [Tue, 8 Oct 2019 13:24:52 +0000 (15:24 +0200)] 
MEDIUM: http-htx: Keep the Host header and the request start-line synchronized

In HTTP, the request authority, if any, and the Host header must be identical
(excluding any userinfo subcomponent and its "@" delimiter). So now, during the
request analysis, when the Host header is updated, the start-line is also
updated. The authority of an absolute URI is changed accordingly. Symmetrically,
if the URI is changed, if it contains an authority, then then Host header is
also changed. In this latter case, the flags of the start-line are also updated
to reflect the changes on the URI.

6 years agoMINOR: h1-htx: Set the flag HTX_SL_F_HAS_AUTHORITY during the request parsing
Christopher Faulet [Tue, 8 Oct 2019 13:01:34 +0000 (15:01 +0200)] 
MINOR: h1-htx: Set the flag HTX_SL_F_HAS_AUTHORITY during the request parsing

When an h1 request is received and parsed, this flag is set if it is a CONNECT
request or if an absolute URI is detected.

6 years agoMINOR: http: Add a function to get the authority into a URI
Christopher Faulet [Tue, 8 Oct 2019 12:56:58 +0000 (14:56 +0200)] 
MINOR: http: Add a function to get the authority into a URI

The function http_get_authority() may be used to parse a URI and looks for the
authority, between the scheme and the path. An option may be used to skip the
user info (part before the '@'). Most of time, the user info will be ignored.

6 years agoMINOR: htx: Add 2 flags on the start-line to have more info about the uri
Christopher Faulet [Tue, 8 Oct 2019 12:27:52 +0000 (14:27 +0200)] 
MINOR: htx: Add 2 flags on the start-line to have more info about the uri

The first flag, HTX_SL_F_HAS_AUTHORITY, is set when the uri contains an
authority. For the H1, it happens when a CONNECT request is received or when an
absolute uri is used. For the H2, it happens when the pseudo header ":authority"
is provided.

The second one, HTX_SL_F_NORMALIZED_URI, is set when the received uri is
represented as an absolute uri because of the protocol requirements. For now, it
is only used for h2 requests, when the pseudo headers :authority and :scheme are
found. Internally, the uri is represented as an absolute uri. This flag allows
us to make the difference between an absolute uri in h1 and h2.

6 years agoMINOR: h2: clarify the rules for how to convert an H2 request to HTX
Willy Tarreau [Tue, 8 Oct 2019 09:59:37 +0000 (11:59 +0200)] 
MINOR: h2: clarify the rules for how to convert an H2 request to HTX

The H2 request parsing is not trivial given that we have multiple
possible syntaxes. Mainly we can have :authority or not, and when
a CONNECT method is seen, :scheme and :path are missing. This mostly
updates the functions' comments and header index assignments to make
them less confusing. Functionally there is no change.

6 years agoDOC: fix typo in Prometheus exporter doc
Rick Rackow [Tue, 8 Oct 2019 09:28:06 +0000 (11:28 +0200)] 
DOC: fix typo in Prometheus exporter doc

It's just a minor typo in a section title.

6 years agoBUG/MINOR: mux-h1/mux-fcgi/trace: Fix position of the 4th arg in some traces
Christopher Faulet [Tue, 8 Oct 2019 09:59:47 +0000 (11:59 +0200)] 
BUG/MINOR: mux-h1/mux-fcgi/trace: Fix position of the 4th arg in some traces

In these muxes, when an integer value is provided in a trace, it must be the 4th
argument. The 3rd one, if defined, is always an HTX message. Unfortunately, some
traces are buggy and the 4th argument is erroneously passed in 3rd position.

No backport needed.

6 years agoMEDIUM: mux-h2: support emitting CONTINUATION frames after HEADERS
Willy Tarreau [Mon, 7 Oct 2019 14:56:34 +0000 (16:56 +0200)] 
MEDIUM: mux-h2: support emitting CONTINUATION frames after HEADERS

There are some reports of users not being able to pass "enterprise"
traffic through haproxy when using H2 because it doesn't emit CONTINUATION
frames and as such is limited to headers no longer than the negociated
max-frame-size which usually is 16 kB.

This patch implements support form emitting CONTINUATION when a HEADERS
frame cannot fit within a limit of mfs. It does this by first filling a
buffer-wise frame, then truncating it starting from the tail to append
CONTINUATION frames. This makes sure that we can truncate on any byte
without being forced to stop on a header boundary, and ensures that the
common case (no fragmentation) doesn't add any extra cost. By moving
the tail first we make sure that each byte is moved only once, thus the
performance impact remains negligible.

This addresses github issue #249.

6 years agoDOC: clarify some points around http-send-name-header's behavior
Willy Tarreau [Mon, 7 Oct 2019 12:58:02 +0000 (14:58 +0200)] 
DOC: clarify some points around http-send-name-header's behavior

The directive causes existing an header to be removed, which is not
explicitly mentioned though already being relied on, and also mention
the fast that it should not be used to modify transport level headers
and that doing it on Host is more than border-line and definitely not
a supported long-term option eventhough it currently works.

6 years agoBUG/MEDIUM: cache: make sure not to cache requests with absolute-uri
Willy Tarreau [Mon, 7 Oct 2019 12:06:34 +0000 (14:06 +0200)] 
BUG/MEDIUM: cache: make sure not to cache requests with absolute-uri

If a request contains an absolute URI and gets its Host header field
rewritten, or just the request's URI without touching the Host header
field, it can lead to different Host and authority parts. The cache
will always concatenate the Host and the path while a server behind
would instead ignore the Host and use the authority found in the URI,
leading to incorrect content possibly being cached.

Let's simply refrain from caching absolute requests for now, which
also matches what the comment at the top of the function says. Later
we can improve this by having a special handling of the authority.

This should be backported as far as 1.8.

6 years agoMINOR: mux-fcgi/trace: Register a new trace source with its events
Christopher Faulet [Fri, 4 Oct 2019 13:21:17 +0000 (15:21 +0200)] 
MINOR: mux-fcgi/trace: Register a new trace source with its events

As for the mux h1 and h2, traces are now supported in the mux fcgi. All parts of
the multiplexer is covered by these traces. Events are splitted by categories
(fconn, fstrm, stream, rx, tx and rsp) for a total of ~40 different events with
5 verboisty levels.

In traces, the first argument is always a connection. So it is easy to get the
fconn (conn->ctx). The second argument is always a fstrm. The third one is an
HTX message. Depending on the context it is the request or the response. In all
cases it is owned by a channel. Finally, the fourth argument is an integer
value. Its meaning depends on the calling context.

6 years agoMINOR: fcgi: Add function to get the string representation of a record type
Christopher Faulet [Fri, 4 Oct 2019 13:20:47 +0000 (15:20 +0200)] 
MINOR: fcgi: Add function to get the string representation of a record type

This function will be used to emit traces in the FCGI multiplexer.

6 years agoMINOR: mux-h1: Try to wakeup the stream on output buffer allocation
Christopher Faulet [Fri, 4 Oct 2019 08:22:47 +0000 (10:22 +0200)] 
MINOR: mux-h1: Try to wakeup the stream on output buffer allocation

When the output buffer allocation failed, we block stream processing. When
finally a buffer is available and we succed to allocate the output buffer, it
seems fair to wake up the stream.

6 years agoBUG/MINOR: mux-h1: Adjust header case when chunked encoding is add to a message
Christopher Faulet [Fri, 4 Oct 2019 08:23:51 +0000 (10:23 +0200)] 
BUG/MINOR: mux-h1: Adjust header case when chunked encoding is add to a message

When an outgoing h1 message is formatted, if it is considered as chunked but the
corresponding header is missing, we add it. And as all other h1 headers, if
configured so, the case of this header must be adjusted.

No backport needed.

6 years agoBUG/MINOR: mux-h1: Adjust header case when the server name is add to a request
Christopher Faulet [Wed, 2 Oct 2019 09:06:13 +0000 (11:06 +0200)] 
BUG/MINOR: mux-h1: Adjust header case when the server name is add to a request

As all other h1 headers, if configured so, the case of this header must be adjusted.

No backport needed.

6 years agoMINOR: http: Remove headers matching the name of http-send-name-header option
Christopher Faulet [Wed, 2 Oct 2019 08:51:38 +0000 (10:51 +0200)] 
MINOR: http: Remove headers matching the name of http-send-name-header option

It is not explicitly stated in the documentation, but some users rely on this
behavior. When the server name is inserted in a request, headers with the same
name are first removed.

This patch is not tagged as a bug, because it is not explicitly documented. We
choose to keep the same implicit behavior to not break existing
configuration. Because this option is used very little, it is not a big deal.

6 years agoMINOR: proxy: Store http-send-name-header in lower case
Christopher Faulet [Wed, 2 Oct 2019 08:45:55 +0000 (10:45 +0200)] 
MINOR: proxy: Store http-send-name-header in lower case

All HTTP header names are now handled in lower case. So this one is now stored
in lower case. It will simplify some processing in HTTP muxes.

6 years agoMINOR: mux-h1/trace: register a new trace source with its events
Christopher Faulet [Tue, 1 Oct 2019 20:08:43 +0000 (22:08 +0200)] 
MINOR: mux-h1/trace: register a new trace source with its events

As for the mux h2, traces are now supported in the mux h1. All parts of the
multiplexer is covered by these traces. Events are splitted by categories (h1c,
h1s, stream, rx and tx) for a total of ~30 different events with 5 verboisty
levels.

In traces, the first argument is always a connection. So it is easy to get the
h1c (conn->ctx). The second argument is always a h1s. The third one is an HTX
message. Depending on the context it is the request or the response. In all
cases it is owned by a channel. Finally, the fourth argument is an integer
value. Its meaning depends on the calling context.

6 years agoMINOR: htx: Adapt htx_dump() to be used from traces
Christopher Faulet [Tue, 1 Oct 2019 20:03:49 +0000 (22:03 +0200)] 
MINOR: htx: Adapt htx_dump() to be used from traces

This function now dumps info about the HTX message into a buffer, passed as
argument. In addition, it is possible to only dump meta information, without the
message content.

6 years agoMINOR: h1-htx: Update h1_copy_msg_data() to ease the traces in the mux-h1
Christopher Faulet [Tue, 1 Oct 2019 19:52:49 +0000 (21:52 +0200)] 
MINOR: h1-htx: Update h1_copy_msg_data() to ease the traces in the mux-h1

This function now uses the address of the pointer to the htx message where the
copy must be performed. This way, when a zero-copy is performed, there is no
need to refresh the caller's htx message. It is a bit easier to do that way,
especially to add traces in the mux-h1.

6 years agoBUG/MINOR: mux-h2/trace: Fix traces on h2c initialization
Christopher Faulet [Fri, 4 Oct 2019 13:19:43 +0000 (15:19 +0200)] 
BUG/MINOR: mux-h2/trace: Fix traces on h2c initialization

When a new H2 connection is initialized, the connection context is not changed
before the end. So, traces emitted during this initialization are buggy, except
the last one when no error occurred, because the connection context is not an
h2c.

To fix the bug, the connection context is saved and set as soon as possible. So,
the connection can always safely be used in all traces, except for the very
first one. And on error, the connection context is restored.

No need to backport.

6 years agoBUG/MINOR: peers: crash on reload without local peer.
Frédéric Lécaille [Fri, 4 Oct 2019 06:30:04 +0000 (08:30 +0200)] 
BUG/MINOR: peers: crash on reload without local peer.

When we configure a "peers" section without local peer, this makes haproxy
old process crash on reload.

Such a configuration file allows to reproduce this issue:

  global
    stats socket /tmp/sock1 mode 666 level admin
    stats timeout 10s

  peers peers
    peer localhost 127.0.0.1:1024

This bug was introduced by this commit:
  "MINOR: cfgparse: Make "peer" lines be parsed as "server" lines"

This commit introduced a new condition to detect a "peers" section without
local peer. This is a "peers" section with a frontend struct which has no ->id
initialized member. Such a "peers" section must be removed.

This patch adds this new condition to remove such peers sections without local
peer as this was always done before.

Must be backported to 2.0.

6 years agoBUG/MEDIUM: tasks: Don't forget to decrement tasks_run_queue.
Olivier Houchard [Thu, 3 Oct 2019 12:55:34 +0000 (14:55 +0200)] 
BUG/MEDIUM: tasks: Don't forget to decrement tasks_run_queue.

When executing tasks, don't forget to decrement tasks_run_queue once we
popped one task from the task_list. tasks_run_queue used to be decremented
by __tasklet_remove_from_tasklet_list(), but we now call MT_LIST_POP().

6 years agoBUG/MEDIUM: mux-h2: do not enforce timeout on long connections
Willy Tarreau [Tue, 1 Oct 2019 08:12:00 +0000 (10:12 +0200)] 
BUG/MEDIUM: mux-h2: do not enforce timeout on long connections

Alexandre Derumier reported issue #308 in which the client timeout will
strike on an H2 mux when it's shorter than the server's response time.
What happens in practice is that there is no activity on the connection
and there's no data pending on output so we can expire it. But this does
not take into account the possibility that some streams are in fact
waiting for the data layer above. So what we do now is that we enforce
the timeout when:
  - there are no more streams
  - some data are pending in the output buffer
  - some streams are blocked on the connection's flow control
  - some streams are blocked on their own flow control
  - some streams are in the send/sending list

In all other cases the connection will not timeout as it means that some
streams are actively used by the data layer.

This fix must be backported to 2.0, 1.9 and probably 1.8 as well. It
depends on the new "blocked_list" field introduced by "MINOR: mux-h2:
add a per-connection list of blocked streams". It would be nice to
also backport "ebtree: make eb_is_empty() and eb_is_dup() take a const"
to avoid a build warning.

6 years agoBUILD: ebtree: make eb_is_empty() and eb_is_dup() take a const
Willy Tarreau [Wed, 2 Oct 2019 13:21:58 +0000 (15:21 +0200)] 
BUILD: ebtree: make eb_is_empty() and eb_is_dup() take a const

For whatever absurd reason these ones do not take a const, resulting in
some haproxy functions being forced to confusingly use variables instead
of const arguments. Let's fix this and backport it to older versions.

6 years agoMINOR: mux-h2: add a per-connection list of blocked streams
Willy Tarreau [Wed, 2 Oct 2019 08:49:59 +0000 (10:49 +0200)] 
MINOR: mux-h2: add a per-connection list of blocked streams

Currently the H2 mux doesn't have a list of all the streams blocking on
the H2 side. It only knows about those trying to send or waiting for a
connection window update. It is problematic to enforce timeouts because
we never know if a stream has to live as long as the data layer wants or
has to be timed out becase it's waiting for a stream window update. This
patch adds a new list, "blocked_list", to store streams blocking on
stream flow control, or later, dependencies. Streams blocked on sfctl
are now added there. It doesn't modify the rest of the logic.

6 years agoMINOR: mux-h2/trace: missing conn pointer in demux full message
Willy Tarreau [Wed, 2 Oct 2019 09:05:46 +0000 (11:05 +0200)] 
MINOR: mux-h2/trace: missing conn pointer in demux full message

One trace was missing the connection's pointer, reporting "demux buffer full"
without indicating for what connection it was.

6 years ago[RELEASE] Released version 2.1-dev2 v2.1-dev2
Willy Tarreau [Tue, 1 Oct 2019 16:13:09 +0000 (18:13 +0200)] 
[RELEASE] Released version 2.1-dev2

Released version 2.1-dev2 with the following main changes :
    - DOC: management: document reuse and connect counters in the CSV format
    - DOC: management: document cache_hits and cache_lookups in the CSV format
    - BUG/MINOR: dns: remove irrelevant dependency on a client connection
    - MINOR: applet: make appctx use their own pool
    - BUG/MEDIUM: checks: Don't attempt to receive data if we already subscribed.
    - BUG/MEDIUM: http/htx: unbreak option http_proxy
    - BUG/MINOR: backend: do not try to install a mux when the connection failed
    - MINOR: mux-h2: Don't adjust anymore the amount of data sent in h2_snd_buf()
    - BUG/MINOR: http_fetch: Fix http_auth/http_auth_group when called from TCP rules
    - BUG/MINOR: http_htx: Initialize HTX error messages for TCP proxies
    - BUG/MINOR: cache/htx: Make maxage calculation HTX aware
    - BUG/MINOR: hlua: Make the function txn:done() HTX aware
    - MINOR: proto_htx: Directly call htx_check_response_for_cacheability()
    - MINOR: proto_htx: Rely on the HTX function to apply a redirect rules
    - MINOR: proto_htx: Add the function htx_return_srv_error()
    - MINOR: backend/htx: Don't rewind output data to set the sni on a srv connection
    - MINOR: proto_htx: Don't stop forwarding when there is a post-connect processing
    - DOC: htx: Update comments in HTX files
    - CLEANUP: htx: Remove the unsued function htx_add_blk_type_size()
    - MINOR: htx: Deduce the number of used blocks from tail and head values
    - MINOR: htx: Use an array of char to store HTX blocks
    - MINOR: htx: Slightly update htx_dump() to report better messages
    - DOC: htx: Add internal documentation about the HTX
    - MAJOR: http: Deprecate and ignore the option "http-use-htx"
    - MEDIUM: mux-h2: Remove support of the legacy HTTP mode
    - CLEANUP: h2: Remove functions converting h2 requests to raw HTTP/1.1 ones
    - MINOR: connection: Remove the multiplexer protocol PROTO_MODE_HTX
    - MINOR: stream: Rely on HTX analyzers instead of legacy HTTP ones
    - MEDIUM: http_fetch: Remove code relying on HTTP legacy mode
    - MINOR: config: Remove tests on the option 'http-use-htx'
    - MINOR: stream: Remove tests on the option 'http-use-htx' in stream_new()
    - MINOR: proxy: Remove tests on the option 'http-use-htx' during H1 upgrade
    - MINOR: hlua: Remove tests on the option 'http-use-htx' to reject TCP applets
    - MINOR: cache: Remove tests on the option 'http-use-htx'
    - MINOR: contrib/prometheus-exporter: Remove tests on the option 'http-use-htx'
    - CLEANUP: proxy: Remove the flag PR_O2_USE_HTX
    - MINOR: proxy: Don't adjust connection mode of HTTP proxies anymore
    - MEDIUM: backend: Remove code relying on the HTTP legacy mode
    - MEDIUM: hlua: Remove code relying on the legacy HTTP mode
    - MINOR: http_act: Remove code relying on the legacy HTTP mode
    - MEDIUM: cache: Remove code relying on the legacy HTTP mode
    - MEDIUM: compression: Remove code relying on the legacy HTTP mode
    - MINOR: flt_trace: Remove code relying on the legacy HTTP mode
    - MINOR: stats: Remove code relying on the legacy HTTP mode
    - MAJOR: filters: Remove code relying on the legacy HTTP mode
    - MINOR: stream: Remove code relying on the legacy HTTP mode
    - MAJOR: http: Remove the HTTP legacy code
    - MINOR: hlua: Remove useless test on TX_CON_WANT_* flags
    - MINOR: proto_http: Remove unused http txn flags
    - MINOR: proto_http: Remove the unused flag HTTP_MSGF_WAIT_CONN
    - CLEANUP: proto_http: Group remaining flags of the HTTP transaction
    - CLEANUP: channel: Remove the unused flag CF_WAKE_CONNECT
    - CLEANUP: proto_http: Remove unecessary includes and comments
    - CLEANUP: proto_http: Move remaining code from proto_http.c to proto_htx.c
    - REORG: proto_htx: Move HTX analyzers & co to http_ana.{c,h} files
    - BUG/MINOR: debug: Remove flags CO_FL_SOCK_WR_ENA/CO_FL_SOCK_RD_ENA
    - MINOR: proxy: Remove support of the option 'http-tunnel'
    - DOC: config: Update as a result of the legacy HTTP removal
    - MEDIUM: config: Remove parsing of req* and rsp* directives
    - MINOR: proxy: Remove the unused list of block rules
    - MINOR: proxy/http_ana: Remove unused req_exp/rsp_exp and req_add/rsp_add lists
    - DOC: config: Remove unsupported req* and rsp* keywords
    - MINOR: global: Preset tune.max_http_hdr to its default value
    - MINOR: http: Don't store raw HTTP errors in chunks anymore
    - BUG/MINOR: session: Emit an HTTP error if accept fails only for H1 connection
    - BUG/MINOR: session: Send a default HTTP error if accept fails for a H1 socket
    - CLEANUP: mux-h2: Remove unused flags H2_SF_CHNK_*
    - BUG/MINOR: checks: do not exit tcp-checks from the middle of the loop
    - MINOR: config: Warn only if the option http-use-htx is used with "no" prefix
    - BUG/MEDIUM: mux-h1: Trim excess server data at the end of a transaction
    - MINOR: connection: add conn_get_src() and conn_get_dst()
    - MINOR: frontend: switch to conn_get_{src,dst}() for logging and debugging
    - MINOR: backend: switch to conn_get_{src,dst}() for port and address mapping
    - MINOR: ssl: switch to conn_get_dst() to retrieve the destination address
    - MINOR: tcp: replace various calls to conn_get_{from,to}_addr with conn_get_{src,dst}
    - MINOR: stream-int: use conn_get_{src,dst} in conn_si_send_proxy()
    - MINOR: stream/cli: use conn_get_{src,dst} in "show sess" and "show peers" output
    - MINOR: log: use conn_get_{dst,src}() to retrieve the cli/frt/bck/srv/ addresses
    - MINOR: http/htx: use conn_get_dst() to retrieve the destination address
    - MINOR: lua: use conn_get_{src,dst} to retrieve connection addresses
    - MINOR: http: check the source address via conn_get_src() in sample fetch functions
    - CLEANUP: connection: remove the now unused conn_get_{from,to}_addr()
    - MINOR: connection: add new src and dst fields
    - MINOR: connection: use conn->{src,dst} instead of &conn->addr.{from,to}
    - MINOR: ssl-sock: use conn->dst instead of &conn->addr.to
    - MINOR: lua: switch to conn->dst for a connection's target address
    - MINOR: peers: use conn->dst for the peer's target address
    - MINOR: htx: switch from conn->addr.{from,to} to conn->{src,dst}
    - MINOR: stream: switch from conn->addr.{from,to} to conn->{src,dst}
    - MINOR: proxy: switch to conn->src in error snapshots
    - MINOR: session: use conn->src instead of conn->addr.from
    - MINOR: tcp: replace conn->addr.{from,to} with conn->{src,dst}
    - MINOR: unix: use conn->dst for the target address in ->connect()
    - MINOR: sockpair: use conn->dst for the target address in ->connect()
    - MINOR: log: use conn->{src,dst} instead of conn->addr.{from,to}
    - MINOR: checks: replace conn->addr.to with conn->dst
    - MINOR: frontend: switch from conn->addr.{from,to} to conn->{src,dst}
    - MINOR: http: convert conn->addr.from to conn->src in sample fetches
    - MEDIUM: backend: turn all conn->addr.{from,to} to conn->{src,dst}
    - MINOR: connection: create a new pool for struct sockaddr_storage
    - MEDIUM: connection: make sure all address producers allocate their address
    - MAJOR: connection: remove the addr field
    - MINOR: connection: don't use clear_addr() anymore, just release the address
    - MINOR: stream: add a new target_addr entry in the stream structure
    - MAJOR: stream: store the target address into s->target_addr
    - MINOR: peers: now remove the remote connection setup code
    - MEDIUM: lua: do not allocate the remote connection anymore
    - MEDIUM: backend: always release any existing prior connection in connect_server()
    - MEDIUM: backend: remove impossible cases from connect_server()
    - BUG/MINOR: mux-h1: Close server connection if input data remains in h1_detach()
    - BUG/MEDIUM: tcp-checks: do not dereference inexisting conn_stream
    - BUG/MINOR: http_ana: Be sure to have an allocated buffer to generate an error
    - BUG/MINOR: http_htx: Support empty errorfiles
    - BUG/CRITICAL: http_ana: Fix parsing of malformed cookies which start by a delimiter
    - BUG/MEDIUM: protocols: add a global lock for the init/deinit stuff
    - BUG/MINOR: proxy: always lock stop_proxy()
    - MEDIUM: mux-h1: Add the support of headers adjustment for bogus HTTP/1 apps
    - BUILD: threads: add the definition of PROTO_LOCK
    - BUG/MEDIUM: lb-chash: Fix the realloc() when the number of nodes is increased
    - BUG/MEDIUM: streams: Don't switch the SI to SI_ST_DIS if we have data to send.
    - BUG/MINOR: log: make sure writev() is not interrupted on a file output
    - DOC: improve the wording in CONTRIBUTING about how to document a bug fix
    - MEDIUM: h1: Don't try to subscribe if we managed to read data.
    - MEDIUM: h1: Don't wake the H1 tasklet if we got the whole request.
    - REGTESTS: checks: exclude freebsd target for tcp-check_multiple_ports.vtc
    - BUG/MINOR: hlua/htx: Reset channels analyzers when txn:done() is called
    - BUG/MEDIUM: hlua: Check the calling direction in lua functions of the HTTP class
    - MINOR: hlua: Don't set request analyzers on response channel for lua actions
    - MINOR: hlua: Add a flag on the lua txn to know in which context it can be used
    - BUG/MINOR: hlua: Only execute functions of HTTP class if the txn is HTTP ready
    - BUG/MINOR: htx: Fix free space addresses calculation during a block expansion
    - MINOR: ssl: merge ssl_sock_load_cert_file() and ssl_sock_load_cert_chain_file()
    - MEDIUM: ssl: use cert_key_and_chain struct in ssl_sock_load_cert_file()
    - MEDIUM: ssl: split the loading of the certificates
    - MEDIUM: ssl: lookup and store in a ckch_node tree
    - MEDIUM: ssl: load DH param in struct cert_key_and_chain
    - BUG/MAJOR: queue/threads: avoid an AB/BA locking issue in process_srv_queue()
    - MINOR: ssl: use STACK_OF for chain certs
    - MINOR: ssl: add extra chain compatibility
    - MINOR: ssl: check private key consistency in loading
    - MINOR: ssl: do not look at DHparam with OPENSSL_NO_DH
    - CLEANUP: ssl: ssl_sock_load_crt_file_into_ckch
    - MINOR: ssl: clean ret variable in ssl_sock_load_ckchn
    - MAJOR: fd: Get rid of the fd cache.
    - MEDIUM: pollers: Remember the state for read and write for each threads.
    - MEDIUM: mux-h2: don't try to read more than needed
    - BUG/BUILD: ssl: fix build with openssl < 1.0.2
    - BUG/MEDIUM: ssl: does not try to free a DH in a ckch
    - BUG/MINOR: debug: fix a small race in the thread dumping code
    - MINOR: wdt: also consider that waiting in the thread dumper is normal
    - REGTESTS: checks: make 4be_1srv_health_checks more reliable
    - BUILD: ssl: BoringSSL add EVP_PKEY_base_id
    - BUG/MEDIUM: ssl: don't free the ckch in multi-cert bundle
    - BUG/MINOR: ssl: fix ressource leaks on error
    - BUG/MEDIUM: lb-chash: Ensure the tree integrity when server weight is increased
    - BUG/MAJOR: http/sample: use a static buffer for raw -> htx conversion
    - BUG/MINOR: stream-int: make sure to always release empty buffers after sending
    - BUG/MEDIUM: ssl: open the right path for multi-cert bundle
    - BUG/MINOR: stream-int: also update analysers timeouts on activity
    - BUG/MEDIUM: mux-h2: unbreak receipt of large DATA frames
    - BUG/MEDIUM: mux-h2: split the stream's and connection's window sizes
    - BUG/MEDIUM: proxy: Make sure to destroy the stream on upgrade from TCP to H2
    - DOC: Add 'Question.md' issue template, discouraging asking questions
    - BUG/MEDIUM: fd: Always reset the polled_mask bits in fd_dodelete().
    - BUG/MEDIUM: pollers: Clear the poll_send bits as well.
    - BUILD: travis-ci: enable daily Coverity scan
    - BUG/MINOR: mux-h2: don't refrain from sending an RST_STREAM after another one
    - BUG/MINOR: mux-h2: use CANCEL, not STREAM_CLOSED in h2c_frt_handle_data()
    - BUG/MINOR: mux-h2: do not send REFUSED_STREAM on aborted uploads
    - BUG/MEDIUM: mux-h2: do not recheck a frame type after a state transition
    - BUG/MINOR: mux-h2: always send stream window update before connection's
    - BUG/MINOR: mux-h2: always reset rcvd_s when switching to a new frame
    - BUG/MEDIUM: checks: make sure to close nicely when we're the last to speak
    - BUG/MEDIUM: stick-table: Wrong stick-table backends parsing.
    - CLEANUP: mux-h2: move the demuxed frame check code in its own function
    - MINOR: cache: add method to cache hash
    - MINOR: cache: allow caching of OPTIONS request
    - BUG/MINOR: ssl: fix 0-RTT for BoringSSL
    - MINOR: ssl: ssl_fc_has_early should work for BoringSSL
    - BUG/MINOR: pools: don't mark the thread harmless if already isolated
    - BUG/MINOR: buffers/threads: always clear a buffer's head before releasing it
    - CLEANUP: buffer: replace b_drop() with b_free()
    - CLEANUP: task: move the cpu_time field to the task-only part
    - MINOR: cli: add two new states to print messages on the CLI
    - MINOR: cli: add cli_msg(), cli_err(), cli_dynmsg(), cli_dynerr()
    - CLEANUP: cli: replace all occurrences of manual handling of return messages
    - BUG/MEDIUM: proxy: Don't forget the SF_HTX flag when upgrading TCP=>H1+HTX.
    - BUG/MEDIUM: proxy: Don't use cs_destroy() when freeing the conn_stream.
    - BUG/MINOR: lua: fix setting netfilter mark
    - BUG/MINOR: Fix prometheus '# TYPE' and '# HELP' headers
    - BUG/MEDIUM: lua: Fix test on the direction to set the channel exp timeout
    - BUG/MINOR: stats: Wait the body before processing POST requests
    - MINOR: fd: make sure to mark the thread as not stuck in fd_update_events()
    - BUG/MEDIUM: mux_pt: Don't call unsubscribe if we did not subscribe.
    - BUILD: travis-ci: trigger non-mainstream configurations only on daily builds.
    - MINOR: debug: indicate the applet name when the task is task_run_applet()
    - MINOR: tools: add append_prefixed_str()
    - MINOR: lua: export applet and task handlers
    - MEDIUM: debug: make the thread dump code show Lua backtraces
    - BUG/MEDIUM: h1: Always try to receive more in h1_rcv_buf().
    - MINOR: list: add LIST_SPLICE() to merge one list into another
    - MINOR: tools: add a DEFNULL() macro to use NULL for empty args
    - REORG: trace: rename trace.c to calltrace.c and mention it's not thread-safe
    - MINOR: sink: create definitions a minimal code for event sinks
    - MINOR: sink: add a support for file descriptors
    - MINOR: trace: start to create a new trace subsystem
    - MINOR: trace: add allocation of buffer-sized trace buffers
    - MINOR: trace/cli: register the "trace" CLI keyword to list the sources
    - MINOR: trace/cli: parse the "level" argument to configure the trace verbosity
    - MINOR: trace/cli: add "show trace" to report trace state and statistics
    - MINOR: trace: implement a very basic trace() function
    - MINOR: trace: add the file name and line number in the prefix
    - MINOR: trace: make trace() now also take a level in argument
    - MINOR: trace: implement a call to a decode function
    - MINOR: trace: add per-level macros to produce traces
    - MINOR: trace: add a definition of typed arguments to trace()
    - MINOR: trace: make sure to always stop the locking when stopping or pausing
    - MINOR: trace: add the possibility to lock on some arguments
    - MINOR: trace: parse the "lock" argument to trace
    - MINOR: trace: retrieve useful pointers and enforce lock-on
    - DOC: management: document the "trace" and "show trace" commands
    - BUILD: trace: make the lockon_ptr const to silence a warning without threads
    - BUG/MEDIUM: mux-h1: do not truncate trailing 0CRLF on buffer boundary
    - BUG/MEDIUM: mux-h1: do not report errors on transfers ending on buffer full
    - DOC: fixed typo in management.txt
    - BUG/MINOR: mworker: disable SIGPROF on re-exec
    - BUG/MEDIUM: listener/threads: fix an AB/BA locking issue in delete_listener()
    - BUG/MEDIUM: url32 does not take the path part into account in the returned hash.
    - MINOR: backend: Add srv_queue converter
    - MINOR: sink: set the fd-type sinks to non-blocking
    - MINOR: tools: add a function varint_bytes() to report the size of a varint
    - MINOR: buffer: add functions to read/write varints from/to buffers
    - MINOR: fd: add fd_write_frag_line() to send a fragmented line to an fd
    - MINOR: sink: now call the generic fd write function
    - MINOR: ring: add a new mechanism for retrieving/storing ring data in buffers
    - MINOR: ring: add a ring_write() function
    - MINOR: ring: add a generic CLI io_handler to dump a ring buffer
    - MINOR: sink: add support for ring buffers
    - MINOR: sink: implement "show events" to show supported sinks and dump the rings
    - MINOR: sink: now report the number of dropped events on output
    - MINOR: trace: support a default callback for the source
    - MINOR: trace: extend the source location to 13 chars
    - MINOR: trace: show thread number and source name in the trace
    - MINOR: trace: change the TRACE() calling convention to put the args and cb last
    - MINOR: connection: add the fc_pp_authority fetch -- authority TLV, from PROXYv2
    - MINOR: tools: add a generic struct "name_desc" for name-description pairs
    - MINOR: trace: replace struct trace_lockon_args with struct name_desc
    - MINOR: trace: change the "payload" level to "data" and move it
    - MINOR: trace: prepend the function name for developer level traces
    - MINOR: trace: also report the trace level in the output
    - MINOR: trace: change the detail_level to per-source verbosity
    - MINOR: mux-h2/trace: register a new trace source with its events
    - MINOR: mux-h2/trace: add the default decoding callback
    - MEDIUM: mux-h2/trace: add lots of traces all over the code
    - MINOR: mux-h2: add functions to convert an h2c/h2s state to a string
    - MINOR: mux-h2/trace: add a new verbosity level "clean"
    - MINOR: mux-h2/trace: only decode the start-line at verbosity other than "minimal"
    - MINOR: mux-h2/trace: always report the h2c/h2s state and flags
    - MINOR: mux-h2/trace: report h2s->id before h2c->dsi for the stream ID
    - CLEANUP: mux-h2/trace: reformat the "received" messages for better alignment
    - CLEANUP: mux-h2/trace: lower-case event names
    - MINOR: trace: extend default event names to 12 chars
    - BUG/MINOR: ring: fix the way watchers are counted
    - MINOR: cli: extend the CLI context with a list and two offsets
    - MINOR: mux-h2/trace: report the connection pointer and state before FRAME_H
    - MEDIUM: ring: implement a wait mode for watchers
    - BUG/MEDIUM: mux-h2/trace: do not dereference h2c->conn after failed idle
    - BUG/MEDIUM: mux-h2/trace: fix missing braces added with traces
    - BUG/MINOR: ring: b_peek_varint() returns a uint64_t, not a size_t
    - CLEANUP: fd: remove leftovers of the fdcache
    - MINOR: fd: add a new "initialized" bit in the fdtab struct
    - MINOR: fd/log/sink: make the non-blocking initialization depend on the initialized bit
    - MEDIUM: log: use the new generic fd_write_frag_line() function
    - MINOR: log: add a target type instead of hacking the address family
    - MEDIUM: log: add support for logging to a ring buffer
    - MINOR: send-proxy-v2: sends authority TLV according to TLV received
    - MINOR: build: add linux-glibc-legacy build TARGET
    - BUG/MEDIUM: peers: local peer socket not bound.
    - BUILD: connection: silence gcc warning with extra parentheses
    - BUG/MINOR: http-ana: Reset response flags when 1xx messages are handled
    - BUG/MINOR: h1: Properly reset h1m when parsing is restarted
    - BUG/MINOR: mux-h1: Fix size evaluation of HTX messages after headers parsing
    - BUG/MINOR: mux-h1: Don't stop anymore input processing when the max is reached
    - BUG/MINOR: mux-h1: Be sure to update the count before adding EOM after trailers
    - BUG/MEDIUM: cache: Properly copy headers splitted on several shctx blocks
    - BUG/MEDIUM: cache: Don't cache objects if the size of headers is too big
    - BUG/MINOR: mux-h1: Fix a possible null pointer dereference in h1_subscribe()
    - MEDIUM: fd: remove the FD_EV_POLLED status bit
    - MEDIUM: fd: simplify the fd_*_{recv,send} functions using BTS/BTR
    - MINOR: fd: make updt_fd_polling() a normal function
    - CONTRIB: debug: add new program "poll" to test poll() events
    - BUG/MINOR: checks: stop polling for write when we have nothing left to send
    - BUG/MINOR: checks: start sending the request right after connect()
    - BUG/MINOR: checks: make __event_chk_srv_r() report success before closing
    - BUG/MINOR: checks: do not uselessly poll for reads before the connection is up
    - BUG/MINOR: mux-h1: Fix a UAF in cfg_h1_headers_case_adjust_postparser()
    - BUILD: CI: add basic CentOS 6 cirrus build
    - MINOR: contrib/prometheus-exporter: Report DRAIN/MAINT/NOLB status for servers
    - BUG/MINOR: lb/leastconn: ignore the server weights for empty servers
    - BUG/MAJOR: ssl: ssl_sock was not fully initialized.
    - MEDIUM: fd: mark the FD as ready when it's inserted
    - MINOR: fd: add two new calls fd_cond_{recv,send}()
    - MEDIUM: connection: enable reading only once the connection is confirmed
    - MINOR: fd: add two flags ERR and SHUT to describe FD states
    - MEDIUM: fd: do not use the FD_POLL_* flags in the pollers anymore
    - BUG/MEDIUM: connection: don't keep more idle connections than ever needed
    - MINOR: stats: report the number of idle connections for each server
    - BUILD: CI: skip reg-tests/connection/proxy_protocol_random_fail.vtc on CentOS 6
    - BUILD/MINOR: auth: enabling for osx
    - BUG/MINOR: listener: Fix a possible null pointer dereference
    - BUG/MINOR: ssl: always check for ssl connection before getting its XPRT context
    - MINOR: stats: Add JSON export from the stats page
    - BUG/MINOR: filters: Properly set the HTTP status code on analysis error
    - MINOR: sample: Add UUID-fetch
    - CLEANUP: mux-h2: Remove unused flag H2_SF_DATA_CHNK
    - BUG/MINOR: acl: Fix memory leaks when an ACL expression is parsed
    - BUG/MINOR: backend: Fix a possible null pointer dereference
    - BUG/MINOR: Missing stat_field_names (since f21d17bb)
    - BUG/MEDIUM: stick-table: Properly handle "show table" with a data type argument
    - BUILD: CI: temporarily disable ASAN
    - MINOR: htx: Add a flag on HTX message to report processing errors
    - MINOR: mux-h1: Report a processing error during output processing
    - MINOR: http-ana: Handle HTX errors first during message analysis
    - MINOR: http-ana: Remove err_state field from http_msg
    - MINOR: config: Support per-proxy and per-server deinit functions callbacks
    - MINOR: config: Support per-proxy and per-server post-check functions callbacks
    - MINOR: http_fetch: Add sample fetches to get auth method/user/pass
    - MINOR: istbuf: Add the function b_isteqi()
    - MINOR: log: Provide a function to emit a log for an application
    - MINOR: http: Add function to parse value of the header Status
    - MEDIUM: mux-h1/h1-htx: move HTX convertion of H1 messages in dedicated file
    - MINOR: h1-htx: Use the same function to copy message payload in all cases
    - MINOR: muxes/htx: Ignore pseudo header during message formatting
    - MINOR: fcgi: Add code related to FCGI protocol
    - MEDIUM: fcgi-app: Add FCGI application and filter
    - MEDIUM: mux-fcgi: Add the FCGI multiplexer
    - MINOR: doc: Add documentation about the FastCGI support
    - BUG/MINOR: build: Fix compilation of mux_fcgi.c when compiled without SSL
    - BUILD: CI: install golang-1.13 when building BoringSSL
    - BUG/MINOR: mux-h2: Be sure to have a connection to unsubcribe
    - BUG/MINOR: mux-fcgi: Be sure to have a connection to unsubcribe
    - CLEANUP: fcgi-app: Remove useless test on fcgi_conf pointer
    - BUG/MINOR: mux-fcgi: Don't compare the filter name in its parsing callback
    - BUG/MAJOR: mux-h2: Handle HEADERS frames received after a RST_STREAM frame
    - BUG/MEDIUM: check/threads: make external checks run exclusively on thread 1
    - MEDIUM: list: Separate "locked" list from regular list.
    - MINOR: mt_lists: Add new macroes.
    - MEDIUM: servers: Use LIST_DEL_INIT() instead of LIST_DEL().
    - MINOR: mt_lists: Do nothing in MT_LIST_ADD/MT_LIST_ADDQ if already in list.
    - MINOR: mt_lists: Give MT_LIST_ADD, MT_LIST_ADDQ and MT_LIST_DEL a return value.
    - MEDIUM: tasklets: Make the tasklet list a struct mt_list.
    - TESTS: Add a stress-test for mt_lists.
    - BUILD: travis-ci: add PCRE2, SLZ build
    - BUG/MINOR: build: fix event ports (Solaris)
    - BUG/MEDIUM: namespace: fix fd leak in master-worker mode
    - OPTIM: listeners: use tasklets for the multi-queue rings
    - BUILD: makefile: work around yet another GCC fantasy (-Wstring-plus-int)
    - BUG/MINOR: stream-int: Process connection/CS errors first in si_cs_send()
    - BUG/MEDIUM: stream-int: Process connection/CS errors during synchronous sends
    - BUG/MEDIUM: checks: make sure the connection is ready before trying to recv
    - CLEANUP: task: remove impossible test
    - CLEANUP: task: cache the task_per_thread pointer
    - MINOR: task: split the tasklet vs task code in process_runnable_tasks()
    - MINOR: task: introduce a thread-local "sched" variable for local scheduler stuff
    - CLEANUP: mux-fcgi: Remove the unused function fcgi_strm_id()
    - BUG/MINOR: mux-fcgi: Use a literal string as format in app_log()
    - BUG/MEDIUM: tasklets: Make sure we're waking the target thread if it sleeps.
    - MINOR: h2/trace: indicate 'F' or 'B' to locate the side of an h2c in traces
    - MINOR: h2/trace: report the frame type when known
    - BUG/MINOR: mux-h2: do not wake up blocked streams before the mux is ready
    - BUG/MEDIUM: namespace: close open namespaces during soft shutdown
    - MINOR: time: add timeofday_as_iso_us() to return instant time as ISO
    - MINOR: sink: finally implement support for SINK_FMT_{TIMED,ISO}
    - MINOR: sink: change ring buffer "buf0"'s format to "timed"
    - BUG/MEDIUM: mux-h2: don't reject valid frames on closed streams
    - BUG/MINOR: mux-fcgi: silence a gcc warning about null dereference
    - BUG/MINOR: mux-h2: Fix missing braces because of traces in h2_detach()
    - BUG/MINOR: mux-h2: Use the dummy error when decoding headers for a closed stream
    - BUG/MAJOR: mux_h2: Don't consume more payload than received for skipped frames
    - BUG/MINOR: mux-h1: Do h2 upgrade only on the first request
    - BUG/MEDIUM: spoe: Use a different engine-id per process
    - MINOR: spoe: Improve generation of the engine-id
    - MINOR: spoe: Support the async mode with several threads
    - MINOR: http: Add server name header from HTTP multiplexers
    - CLEANUP: http-ana: Remove the unused function http_send_name_header()
    - MINOR: stats: Add the support of float fields in stats
    - BUG/MINOR: contrib/prometheus-exporter: Return the time averages in seconds
    - DOC: Fix documentation about the cli command to get resolver stats
    - BUG/MEDIUM: fcgi: fix missing list tail in sample fetch registration
    - BUG/MINOR: stats: Add a missing break in a switch statement
    - BUG/MINOR: lua: Properly initialize the buffer's fields for string samples in hlua_lua2(smp|arg)
    - CLEANUP: lua: Get rid of obsolete (size_t *) cast in hlua_lua2(smp|arg)
    - BUG/MEDIUM: lua: Store stick tables into the sample's `t` field
    - CLEANUP: proxy: Remove `proxy_tbl_by_name`
    - BUILD: ssl: fix a warning when built with openssl < 1.0.2
    - DOC: replace utf-8 quotes by ascii ones
    - BUG/MEDIUM: fd: HUP is an error only when write is active
    - BUG/MINOR: action: do-resolve does not yield on requests with body
    - Revert "MINOR: cache: allow caching of OPTIONS request"

6 years agoRevert "MINOR: cache: allow caching of OPTIONS request"
Willy Tarreau [Tue, 1 Oct 2019 15:59:17 +0000 (17:59 +0200)] 
Revert "MINOR: cache: allow caching of OPTIONS request"

This reverts commit 1263540fe824c74bc3c668fec3476b880d65b27c.

As discussed in issues #214 and #251, this is not the correct way to
cache CORS responses, since it relies on hacking the cache to cache
the OPTIONS method which is explicitly non-cacheable and for which
we cannot rely on any standard caching semantics (cache headers etc
are not expected there). Let's roll this back for now and keep that
for a more reliable and flexible CORS-specific solution later.

6 years agoBUG/MINOR: action: do-resolve does not yield on requests with body
Baptiste Assmann [Tue, 1 Oct 2019 13:32:40 +0000 (15:32 +0200)] 
BUG/MINOR: action: do-resolve does not yield on requests with body

@davidmogar reported a github issue (#227) about problems with
do-resolve action when the request contains a body.
The variable was never populated in such case, despite tcpdump shows a
valid DNS response coming back.

The do-resolve action is a task in HAProxy and so it's waken by the
scheduler each time the scheduler think such task may have some work to
do.
When a simple HTTP request is sent, then the task is called, it sends
the DNS request, then the scheduler will wake up the task again later
once the DNS response is there.
Now, when the client send a PUT or a POST request (or any other type)
with a BODY, then the do-resolve action if first waken up once the
headers are processed. It sends the DNS request. Then, when the bytes
for the body are processed by HAProxy AND the DNS response has not yet
been received, then the action simply terminates and cleans up all the
data associated to this resolution...

This patch detect such behavior and if the action is now waken up while
a DNS resolution is in RUNNING state, then the action will tell the
scheduler to wake it up again later.

Backport status: 2.0 and above

6 years agoBUG/MEDIUM: fd: HUP is an error only when write is active
Willy Tarreau [Tue, 1 Oct 2019 09:46:40 +0000 (11:46 +0200)] 
BUG/MEDIUM: fd: HUP is an error only when write is active

William reported that since commit 6b3089856f ("MEDIUM: fd: do not use
the FD_POLL_* flags in the pollers anymore") the master's CLI often
fails to access sub-processes. There are two causes to this. One is
that we did report FD_POLL_ERR on an FD as soon as FD_EV_SHUT_W was
seen, which is automatically inherited from POLLHUP. And since we do
not store the current shutdown state of an FD we can't know if the
poller reports a sudden close resulting from an error or just a
byproduct of a previous shutdown(WR) followed by a read0. The current
patch addresses this by only considering this when the FD was active,
since a shutdown FD is not active. The second issue is that *somewhere*
down the chain, channel data are ignored if an error is reported on a
channel. This results in content truncation, but this cause was not
figured yet.

No backport is needed.