]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
4 years agoMEDIUM: stick-tables: Add srvkey option to stick-table
Thayne McCombs [Fri, 20 Nov 2020 08:28:26 +0000 (01:28 -0700)] 
MEDIUM: stick-tables: Add srvkey option to stick-table

This allows using the address of the server rather than the name of the
server for keeping track of servers in a backend for stickiness.

The peers code was also extended to support feeding the dictionary using
this key instead of the name.

Fixes #814

4 years agoBUG/MEDIUM: cache: Fix hash collision in `accept-encoding` handling for `Vary`
Tim Duesterhus [Tue, 29 Dec 2020 11:43:53 +0000 (12:43 +0100)] 
BUG/MEDIUM: cache: Fix hash collision in `accept-encoding` handling for `Vary`

This patch fixes GitHub Issue #988. Commit ce9e7b25217c46db1ac636b2c885a05bf91ae57e
was not sufficient, because it fell back to a hash comparison if the bitmap
of known encodings was not acceptable instead of directly returning the the
cached response is not compatible.

This patch also extends the reg-test to test the hash collision that was
mentioned in #988.

Vary handling is 2.4, no backport needed.

4 years agoCI: GitHub Actions: enable daily Coverity scan
Ilya Shipitsin [Fri, 25 Dec 2020 18:36:52 +0000 (23:36 +0500)] 
CI: GitHub Actions: enable daily Coverity scan

That scan was previously implemented on Travis. Let us migrate
it to GitHub Actions.

Co-authored-by: Tim Duesterhus <tim@bastelstu.be>
4 years agoMINOR: cache: Replace the "process-vary" option's expected values
Remi Tricot-Le Breton [Wed, 23 Dec 2020 17:13:53 +0000 (18:13 +0100)] 
MINOR: cache: Replace the "process-vary" option's expected values

Replace the <0/1> expected values of the process-vary option by a more
usual <on/off> pair.

4 years agoMINOR: cache: Remove redundant test in http_action_req_cache_use
Remi Tricot-Le Breton [Wed, 23 Dec 2020 17:13:52 +0000 (18:13 +0100)] 
MINOR: cache: Remove redundant test in http_action_req_cache_use

The suppressed check is fully covered by the next one and can then be
removed.

4 years agoREGTESTS: cache: Add a specific test for the accept-encoding normalizer
Remi Tricot-Le Breton [Wed, 23 Dec 2020 17:13:51 +0000 (18:13 +0100)] 
REGTESTS: cache: Add a specific test for the accept-encoding normalizer

Those tests check the explicit support of a subset of encodings added to
the accept-encoding normalizer.

4 years agoREGTESTS: cache: Simplify vary.vtc file
Remi Tricot-Le Breton [Wed, 23 Dec 2020 17:13:50 +0000 (18:13 +0100)] 
REGTESTS: cache: Simplify vary.vtc file

This test used chunked responses but it is not needed. All the chunked
responses are replaced by more simple 'bodylen' directives.

4 years agoMEDIUM: cache: Manage a subset of encodings in accept-encoding normalizer
Remi Tricot-Le Breton [Wed, 23 Dec 2020 17:13:49 +0000 (18:13 +0100)] 
MEDIUM: cache: Manage a subset of encodings in accept-encoding normalizer

The accept-encoding normalizer now explicitely manages a subset of
encodings which will all have their own bit in the encoding bitmap
stored in the cache entry. This way two requests with the same primary
key will be served the same cache entry if they both explicitely accept
the stored response's encoding, even if their respective secondary keys
are not the same and do not match the stored response's one.
The actual hash of the accept-encoding will still be used if the
response's encoding is unmanaged.
The encoding matching and the encoding weight parsing are done for every
subpart of the accept-encoding values, and a bitmap of accepted
encodings is built for every request. It is then tested upon any stored
response that has the same primary key until one with an accepted
encoding is found.
The specific "identity" and "*" accept-encoding values are managed too.
When storing a response in the key, we also parse the content-encoding
header in order to only set the response's corresponding encoding's bit
in its cache_entry encoding bitmap.

This patch fixes GitHub issue #988.
It does not need to be backported.

4 years agoMINOR: http: Add helper functions to trim spaces and tabs
Remi Tricot-Le Breton [Wed, 23 Dec 2020 17:13:48 +0000 (18:13 +0100)] 
MINOR: http: Add helper functions to trim spaces and tabs

Add two helper functions that trim leading or trailing spaces and
horizontal tabs from an ist string.

4 years agoMINOR: cache: Add specific secondary key comparison mechanism
Remi Tricot-Le Breton [Wed, 23 Dec 2020 17:13:47 +0000 (18:13 +0100)] 
MINOR: cache: Add specific secondary key comparison mechanism

Add the possibility to define custom comparison functions for every
sub-part of the secondary key hash instead of using a global memcmp.

4 years agoBUG/MINOR: cache: Manage multiple headers in accept-encoding normalization
Remi Tricot-Le Breton [Wed, 23 Dec 2020 17:13:46 +0000 (18:13 +0100)] 
BUG/MINOR: cache: Manage multiple headers in accept-encoding normalization

The accept-encoding part of the secondary key (vary) was only built out
of the first occurrence of the header. So if a client had two
accept-encoding headers, gzip and br for instance, the key would have
been built out of the gzip string. So another client that only managed
gzip would have been sent the cached resource, even if it was a br resource.
The http_find_header function is now called directly by the normalizers
so that they can manage multiple headers if needed.
A request that has more than 16 encodings will be considered as an
illegitimate request and its response will not be stored.

This fixes GitHub issue #987.

It does not need any backport.

4 years agoMINOR: cache: Avoid storing responses whose secondary key was not correctly calculated
Remi Tricot-Le Breton [Wed, 23 Dec 2020 17:13:45 +0000 (18:13 +0100)] 
MINOR: cache: Avoid storing responses whose secondary key was not correctly calculated

If any of the secondary hash normalizing functions raises an error, the
secondary hash will be unusable. In this case, the response will not be
stored anymore.

4 years agoMINOR: cache: Refactoring of secondary_key building functions
Remi Tricot-Le Breton [Wed, 23 Dec 2020 17:13:44 +0000 (18:13 +0100)] 
MINOR: cache: Refactoring of secondary_key building functions

The two secondary_key building functions (prebuild_full_key
and build_key) have roughly the same content so their code can
be mutualized.

4 years agoMINOR: quic: Add traces for quic_packet_encrypt().
Frédéric Lécaille [Fri, 18 Dec 2020 08:48:20 +0000 (09:48 +0100)] 
MINOR: quic: Add traces for quic_packet_encrypt().

Add traces to have an idea why this function may fail. In fact
in never fails when the passed parameters are correct, especially the
lengths. This is not the case when a packet is not correctly built
before being encrypted.

4 years agoMINOR: quic: make a packet build fails when qc_build_frm() fails.
Frédéric Lécaille [Fri, 18 Dec 2020 08:33:27 +0000 (09:33 +0100)] 
MINOR: quic: make a packet build fails when qc_build_frm() fails.

Even if the size of frames built by qc_build_frm() are computed so that
not to overflow a buffer, do not rely on this and always makes a packet
build fails if we could not build a frame.
Also add traces to have an idea where qc_build_frm() fails.
Fixes a memory leak in qc_build_phdshk_apkt().

4 years agoMINOR: quic: Add traces for in flght ack-eliciting packet counter.
Frédéric Lécaille [Wed, 16 Dec 2020 16:33:11 +0000 (17:33 +0100)] 
MINOR: quic: Add traces for in flght ack-eliciting packet counter.

Add trace for this counter. Also shorten its variable name (->ifae_pkts).

4 years agoMINOR: quic: Update the initial salt to that of draft-29.
Frédéric Lécaille [Wed, 16 Dec 2020 10:28:58 +0000 (11:28 +0100)] 
MINOR: quic: Update the initial salt to that of draft-29.

This salt is ued at leat up to draft-32. At this date ngtcp2 always
uses this salt even if it started the draft-33 development.

Note that when the salt is not correct, we cannot remove the header
protection. In this case the packet number length is wrong.

4 years agoMINOR: quic: Display the SSL alert in ->ssl_send_alert() callback.
Frédéric Lécaille [Thu, 10 Dec 2020 16:03:11 +0000 (17:03 +0100)] 
MINOR: quic: Display the SSL alert in ->ssl_send_alert() callback.

At least displays the SSL alert error code passed to ->ssl_send_alert()
QUIC BIO method and the SSL encryption level. This function is newly called
when using picoquic client with a recent version of BoringSSL (Nov 19 2020).
This is not the case with OpenSSL with 32 as QUIC draft implementation.

4 years agoMINOR: quic: Add traces to congestion avoidance NewReno callback.
Frédéric Lécaille [Thu, 10 Dec 2020 13:41:00 +0000 (14:41 +0100)] 
MINOR: quic: Add traces to congestion avoidance NewReno callback.

These traces are missing and are useful do diagnose issue in the congestion
avoidance callback for NewReno algorithm.

4 years agoMINOR: quic: Code reordering to help in reviewing/modifying.
Frédéric Lécaille [Wed, 9 Dec 2020 14:56:48 +0000 (15:56 +0100)] 
MINOR: quic: Code reordering to help in reviewing/modifying.

Reorder by increasing type the switch/case in qc_parse_pkt_frms()
which is the high level frame parser.
Add new STREAM_X frame types to support some tests with ngtcp2 client.

4 years agoMINOR: quic: Flag RX packet as ack-eliciting from the generic parser.
Frédéric Lécaille [Wed, 9 Dec 2020 13:56:18 +0000 (14:56 +0100)] 
MINOR: quic: Flag RX packet as ack-eliciting from the generic parser.

Add ->flags to the QUIC frame parser as this has been done for the builder so
that to flag RX packets as ack-eliciting at low level. This should also be
helpful to maintain the code if we have to add new flags to RX packets.
Remove the statements which does the same thing as higher level in
qc_parse_pkt_frms().

4 years agoMINOR: quic: Make usage of the congestion control window.
Frédéric Lécaille [Tue, 8 Dec 2020 14:58:39 +0000 (15:58 +0100)] 
MINOR: quic: Make usage of the congestion control window.

Remove ->ifcdata which was there to control the CRYPTO data sent to the
peer so that not to saturate its reception buffer. This was a sort
of flow control.
Add ->prep_in_flight counter to the QUIC path struct to control the
number of bytes prepared to be sent so that not to saturare the
congestion control window. This counter is increased each time a
packet was built. This has nothing to see with ->in_flight which
is the real in flight number of bytes which have really been sent.
We are olbiged to maintain two such counters to know how many bytes
of data we can prepared before sending them.
Modify traces consequently which were useful to diagnose issues about
the congestion control window usage.

4 years agoMINOR: quic: Attempt to make trace more readable
Frédéric Lécaille [Wed, 2 Dec 2020 15:11:40 +0000 (16:11 +0100)] 
MINOR: quic: Attempt to make trace more readable

As there is a lot of information in this protocol, this is not
easy to make the traces readable. We remove here a few of them and
shorten some line shortening the variable names.

4 years agoMAJOR: quic: Make usage of ebtrees to store QUIC ACK ranges.
Frédéric Lécaille [Mon, 30 Nov 2020 15:19:22 +0000 (16:19 +0100)] 
MAJOR: quic: Make usage of ebtrees to store QUIC ACK ranges.

Store QUIC ACK ranges in ebtrees in place of lists with a 0(n) time complexity
for insertion.

4 years agoMINOR: quic: Enable the compilation of QUIC modules.
Frédéric Lécaille [Mon, 23 Nov 2020 14:53:17 +0000 (15:53 +0100)] 
MINOR: quic: Enable the compilation of QUIC modules.

Adds the QUIC C object files to the list to compile to support QUIC protocol.
USE_QUIC compilation option must be used for that.

4 years agoMINOR: cfgparse: QUIC default server transport parameters init.
Frédéric Lécaille [Mon, 23 Nov 2020 14:50:46 +0000 (15:50 +0100)] 
MINOR: cfgparse: QUIC default server transport parameters init.

This patch is there to initialize the default transport parameters for QUIC
as a preparation for one of the QUIC next steps to come: fully support QUIC
protocol for haproxy servers.

4 years agoMINOR: quic: QUIC socket management finalization.
Frédéric Lécaille [Mon, 23 Nov 2020 14:46:36 +0000 (15:46 +0100)] 
MINOR: quic: QUIC socket management finalization.

Implement ->accept_conn() callback for QUIC listener sockets.
Note that this patch also implements quic_session_accept() function
which is similar to session_accept_fd() without calling conn_complete_session()
at this time because we do not have any real QUIC mux.

4 years agoMINOR: ssl: QUIC transport parameters parsing.
Frédéric Lécaille [Mon, 23 Nov 2020 14:37:11 +0000 (15:37 +0100)] 
MINOR: ssl: QUIC transport parameters parsing.

This patch modifies the TLS ClientHello message callback so that to parse the QUIC
client transport parameters.

4 years agoMINOR: ssl: SSL CTX initialization modifications for QUIC.
Frédéric Lécaille [Mon, 23 Nov 2020 13:33:30 +0000 (14:33 +0100)] 
MINOR: ssl: SSL CTX initialization modifications for QUIC.

Makes TLS/TCP and QUIC share the same CTX initializer so that not to modify the
caller which is an XPRT callback used both by the QUIC xprt and the SSL xprt over
TCP.

4 years agoMINOR: server: Add QUIC definitions to servers.
Frédéric Lécaille [Mon, 23 Nov 2020 13:29:28 +0000 (14:29 +0100)] 
MINOR: server: Add QUIC definitions to servers.

This patch adds QUIC structs to server struct so that to make the QUIC code
compile. Also initializes the ebtree to store the connections by connection
IDs.

4 years agoMINOR: listener: Add QUIC info to listeners and receivers.
Frédéric Lécaille [Mon, 23 Nov 2020 13:23:21 +0000 (14:23 +0100)] 
MINOR: listener: Add QUIC info to listeners and receivers.

This patch adds a quic_transport_params struct to bind_conf struct
used for the listeners. This is to store the QUIC transport parameters
for the listeners. Also initializes them when calling str2listener().
Before str2sa_range() it's too early to figure we're going to speak QUIC,
and after it's too late as listeners are already created. So it seems that
doing it in str2listener() when the protocol is discovered is the best
place.

Also adds two ebtrees to the underlying receivers to store the connection
by connections IDs (one for the original connection IDs, and another
one for the definitive connection IDs which really identify the connections.

However it doesn't seem normal that it is stored in the receiver nor the
listener. There should be a private context in the listener so that
protocols can store internal information. This element should in
fact be the listener handle.

Something still feels wrong, and probably we'll have to make QUIC and
SSL co-exist: a proof of this is that there's some explicit code in
bind_parse_ssl() to prevent the "ssl" keyword from replacing the xprt.

4 years agoMINOR: quic: Import C source code files for QUIC protocol.
Frédéric Lécaille [Mon, 23 Nov 2020 13:14:04 +0000 (14:14 +0100)] 
MINOR: quic: Import C source code files for QUIC protocol.

This patch imports all the C files for QUIC protocol implementation with few
modifications from 20200720-quic branch of quic-dev repository found at
https://github.com/haproxytech/quic-dev.

Traces were implemented to help with the development.

4 years agoMINOR: quic: Add definitions for QUIC protocol.
Frédéric Lécaille [Mon, 23 Nov 2020 13:10:37 +0000 (14:10 +0100)] 
MINOR: quic: Add definitions for QUIC protocol.

This patch imports all the definitions for QUIC protocol with few modifications
from 20200720-quic branch of quic-dev repository found at
https://github.com/haproxytech/quic-dev.

4 years agoMINOR: tools: Add support for QUIC addresses parsing.
Frédéric Lécaille [Mon, 23 Nov 2020 10:36:57 +0000 (11:36 +0100)] 
MINOR: tools: Add support for QUIC addresses parsing.

Add "quic4" and "quic6" keywords to str2sa_range() to parse QUIC IPv4
and IPv6 addresses respectively.

4 years agoMINOR: cfgparse: Do not modify the QUIC xprt when parsing "ssl".
Frédéric Lécaille [Mon, 23 Nov 2020 10:33:12 +0000 (11:33 +0100)] 
MINOR: cfgparse: Do not modify the QUIC xprt when parsing "ssl".

When parsing "ssl" keyword for TLS bindings, we must not use the same xprt as the one
for TLS/TCP connections. So, do not modify the QUIC xprt which will be initialized
when parsing QUIC addresses wich "ssl" bindings.

4 years agoMINOR: ssl: Export definitions required by QUIC.
Frédéric Lécaille [Mon, 23 Nov 2020 10:19:04 +0000 (11:19 +0100)] 
MINOR: ssl: Export definitions required by QUIC.

QUIC needs to initialize its BIO and SSL session the same way as for SSL over TCP
connections. It needs also to use the same ClientHello callback.
This patch only exports functions and variables shared between QUIC and SSL/TCP
connections.

4 years agoMINOR: connection: Add a new xprt to connection.
Frédéric Lécaille [Mon, 23 Nov 2020 10:09:48 +0000 (11:09 +0100)] 
MINOR: connection: Add a new xprt to connection.

Simply adds XPRT_QUIC new enum to integrate QUIC transport protocol.

4 years agoMINOR: ssl_sock: Initialize BIO and SSL objects outside of ssl_sock_init()
Frédéric Lécaille [Mon, 9 Nov 2020 14:59:23 +0000 (15:59 +0100)] 
MINOR: ssl_sock: Initialize BIO and SSL objects outside of ssl_sock_init()

This patch extraces the code which initializes the BIO and SSL session
objects so that to reuse it elsewhere later for QUIC conections which
only needs SSL and BIO objects at th TLS layer stack level to work.

4 years agoMINOR: quic: Redefine control layer callbacks which are QUIC specific.
Frédéric Lécaille [Fri, 6 Nov 2020 14:49:49 +0000 (15:49 +0100)] 
MINOR: quic: Redefine control layer callbacks which are QUIC specific.

We add src/quic_sock.c QUIC specific socket management functions as callbacks
for the control layer: ->accept_conn, ->default_iocb and ->rx_listening.
accept_conn() will have to be defined. The default I/O handler only recvfrom()
the datagrams received. Furthermore, ->rx_listening callback always returns 1 at
this time but should returns 0 when reloading the processus.

4 years agoMINOR: connection: Attach a "quic_conn" struct to "connection" struct.
Frédéric Lécaille [Fri, 6 Nov 2020 14:40:16 +0000 (15:40 +0100)] 
MINOR: connection: Attach a "quic_conn" struct to "connection" struct.

This is a simple patch to prepare the integration of QUIC support to come.
quic_conn struct is supposed to embed any QUIC specific information for a QUIC
connection.

4 years agoMINOR: protocol: Create proto_quic QUIC protocol layer.
Frédéric Lécaille [Mon, 2 Nov 2020 13:27:08 +0000 (14:27 +0100)] 
MINOR: protocol: Create proto_quic QUIC protocol layer.

As QUIC is a connection oriented protocol, this file is almost a copy of
proto_tcp without TCP specific features. To suspend/resume a QUIC receiver
we proceed the same way as for proto_udp receivers.

With the recent updates to the listeners, we don't need a specific set of
quic*_add_listener() functions, the default ones are sufficient. The fields
declaration were reordered to make the various layers more visible like in
other protocols.

udp_suspend_receiver/udp_resume_receiver are up-to-date (the check for INHERITED
is present) and the code being UDP-specific, it's normal to use UDP here.
Note that in the future we might more reasily reference stacked layers so that
there's no more need for specifying the pointer here.

4 years agoREGTESTS: add tests for the xxh3 converter
Dragan Dosen [Tue, 22 Dec 2020 21:02:59 +0000 (22:02 +0100)] 
REGTESTS: add tests for the xxh3 converter

4 years agoMINOR: sample: add the xxh3 converter
Dragan Dosen [Tue, 22 Dec 2020 20:44:33 +0000 (21:44 +0100)] 
MINOR: sample: add the xxh3 converter

This patch adds support for the XXH3 variant of hash function that
generates a 64-bit hash.

4 years agoCLEANUP: xxhash: remove the unused src/xxhash.c
Dragan Dosen [Tue, 22 Dec 2020 13:47:48 +0000 (14:47 +0100)] 
CLEANUP: xxhash: remove the unused src/xxhash.c

The source file src/xxhash.c is removed, as we use XXH_INLINE_ALL.

4 years agoMEDIUM: xxhash: use the XXH_INLINE_ALL macro to inline all functions
Dragan Dosen [Tue, 22 Dec 2020 13:46:47 +0000 (14:46 +0100)] 
MEDIUM: xxhash: use the XXH_INLINE_ALL macro to inline all functions

This way we make all xxhash functions inline, with implementations being
directly included within xxhash.h.

Makefile is updated as well, since we don't need to compile and link
xxhash.o anymore.

Inlining should improve performance on small data inputs.

4 years agoMEDIUM: xxhash: use the XXH3 functions to generate 64-bit hashes
Dragan Dosen [Tue, 22 Dec 2020 12:22:34 +0000 (13:22 +0100)] 
MEDIUM: xxhash: use the XXH3 functions to generate 64-bit hashes

Replace the XXH64() function calls with the XXH3 variant function
XXH3_64bits_withSeed() where possible.

4 years agoIMPORT: xxhash: update to v0.8.0 that introduces stable XXH3 variant
Dragan Dosen [Tue, 22 Dec 2020 11:00:37 +0000 (12:00 +0100)] 
IMPORT: xxhash: update to v0.8.0 that introduces stable XXH3 variant

A new XXH3 variant of hash functions shows a noticeable improvement in
performance (especially on small data), and also brings 128-bit support,
better inlining and streaming capabilities.

Performance comparison is available here:

  https://github.com/Cyan4973/xxHash/wiki/Performance-comparison

4 years agoMINOR: atomic: don't use ; to separate instruction on aarch64.
Olivier Houchard [Wed, 23 Dec 2020 00:23:41 +0000 (01:23 +0100)] 
MINOR: atomic: don't use ; to separate instruction on aarch64.

The assembler on MacOS aarch64 interprets ; as the beginning of comments,
so it is not suitable for separating instructions in inline asm. Use \n
instead.

This should be backported to 2.3, 2.2, 2.1, 2.0 and 1.9.

4 years agoCI: travis-ci: drop coverity scan builds
Ilya Shipitsin [Tue, 22 Dec 2020 17:51:52 +0000 (22:51 +0500)] 
CI: travis-ci: drop coverity scan builds

we ran out of travis-ci minutes on December 2020. I would keep
exotic architectures like arm64, s390, ppc64le on travis and move
Coverity scan to Github Actions.

so, let us drop coverity scan from travis-ci.

4 years agoREGTESTS: complete http-check test
Amaury Denoyelle [Tue, 22 Dec 2020 13:08:53 +0000 (14:08 +0100)] 
REGTESTS: complete http-check test

Add a new check for a pseudo-websocket handshake, specifying the
Connection header to verify if it is properly handled by http-check send
directive. Also check that default http/1.1 checks have the header
Connection: close.

4 years agoMINOR: check: do not ignore a connection header for http-check send
Amaury Denoyelle [Tue, 22 Dec 2020 13:08:52 +0000 (14:08 +0100)] 
MINOR: check: do not ignore a connection header for http-check send

Allow the user to specify a custom Connection header for http-check
send. This is useful for example to implement a websocket upgrade check.

If no connection header has been set, a 'Connection: close' header is
automatically appended to allow the server to close the connection
immediately after the request/response.

Update the documentation related to http-check send.

This fixes the github issue #1009.

4 years agoMINOR: time: increase the minimum wakeup interval to 60s
Willy Tarreau [Tue, 22 Dec 2020 09:35:43 +0000 (10:35 +0100)] 
MINOR: time: increase the minimum wakeup interval to 60s

The MAX_DELAY_MS which is set an upper limit to the poll wait time and
force a wakeup this often used to be set to 1 second in order to easily
spot and correct time drifts. This was added 12 years ago at an era
where virtual machines were starting to become common in server
environments while not working particularly well. Nowadays, such issues
are not as common anymore, however forcing 64 threads to wake up every
single second starts to make the process visible on otherwise idle
systems. Let's increase this wakeup interval to one minute. In the worst
case it will make idle threads wake every second, which remains low.

If this is not sufficient anymore on some systems, another approach
would consist in implementing a deep-sleep mode which only triggers
after a while and which is always disabled if any time drift is
observed.

4 years agoBUILD: hpack: hpack-tbl-t.h uses VAR_ARRAY but does not include compiler.h
Christian Ruppert [Mon, 9 Nov 2020 08:15:21 +0000 (09:15 +0100)] 
BUILD: hpack: hpack-tbl-t.h uses VAR_ARRAY but does not include compiler.h

This fixes building hpack from contrib, which failed because of the
undeclared VAR_ARRAY:

make -C contrib/hpack
...
cc -O2 -Wall -g -I../../include -fwrapv -fno-strict-aliasing   -c -o gen-enc.o gen-enc.c
In file included from gen-enc.c:18:
../../include/haproxy/hpack-tbl-t.h:105:23: error: 'VAR_ARRAY' undeclared here (not in a function)
  105 |  struct hpack_dte dte[VAR_ARRAY]; /* dynamic table entries */
...

As discussed in the thread below, let's redefine VAR_ARRAY in this file
so that it remains self-sustaining:

   https://www.mail-archive.com/haproxy@formilux.org/msg39212.html

4 years agoBUG/MEDIUM: mux_h2: Add missing braces in h2_snd_buf()around trace+wakeup
Tim Duesterhus [Mon, 21 Dec 2020 18:40:16 +0000 (19:40 +0100)] 
BUG/MEDIUM: mux_h2: Add missing braces in h2_snd_buf()around trace+wakeup

This is a regression in 7838a79ba ("MEDIUM: mux-h2/trace: add lots of traces
all over the code"). The issue was found using -Wmisleading-indentation.
This patch fixes GitHub issue #1015.

The impact of this bug is that it could in theory cause occasional delays
on some long responses for connections having otherwise no traffic.

This patch should be backported to 2.1+, the commit was first tagged in
v2.1-dev2.

4 years ago[RELEASE] Released version 2.4-dev4 v2.4-dev4
Willy Tarreau [Mon, 21 Dec 2020 10:54:56 +0000 (11:54 +0100)] 
[RELEASE] Released version 2.4-dev4

Released version 2.4-dev4 with the following main changes :
    - BUG/MEDIUM: lb-leastconn: Reposition a server using the right eweight
    - BUG/MEDIUM: mux-h1: Fix a deadlock when a 408 error is pending for a client
    - BUG/MEDIUM: ssl/crt-list: bad behavior with "commit ssl cert"
    - BUG/MAJOR: cache: Crash because of disabled entry not removed from the tree
    - BUILD: SSL: fine guard for SSL_CTX_add_server_custom_ext call
    - MEDIUM: cache: Add a secondary entry counter and insertion limitation
    - MEDIUM: cache: Avoid going over duplicates lists too often
    - MINOR: cache: Add a max-secondary-entries cache option
    - CI: cirrus: drop CentOS 6 builds
    - BUILD: Makefile: have "make clean" destroy .o/.a/.s in contrib subdirs as well
    - MINOR: vars: replace static functions with global ones
    - MINOR: opentracing: add ARGC_OT enum
    - CONTRIB: opentracing: add the OpenTracing filter
    - DOC: opentracing: add the OpenTracing filter section
    - REGTESTS: make use of HAPROXY_ARGS and pass -dM by default
    - BUG/MINOR: http: Establish a tunnel for all 2xx responses to a CONNECT
    - BUG/MINOR: mux-h1: Don't set CS_FL_EOI too early for protocol upgrade requests
    - BUG/MEDIUM: http-ana: Never for sending data in TUNNEL mode
    - CLEANUP: mux-h2: Rename h2s_frt_make_resp_data() to be generic
    - CLEANUP: mux-h2: Rename h2c_frt_handle_data() to be generic
    - BUG/MEDIUM: mux-h1: Handle h1_process() failures on a pipelined request
    - CLEANUP: debug: mark the RNG's seed as unsigned
    - CONTRIB: halog: fix build issue caused by %L printf format
    - CONTRIB: halog: mark the has_zero* functions unused
    - CONTRIB: halog: fix signed/unsigned build warnings on counts and timestamps
    - CONTRIB: debug: address "poll" utility build on non-linux platforms
    - BUILD: plock: remove dead code that causes a warning in gcc 11
    - BUILD: ssl: fine guard for SSL_CTX_get0_privatekey call
    - BUG/MINOR: dns: SRV records ignores duplicated AR records
    - DOC: fix "smp_size" vs "sample_size" in "log" directive arguments
    - CLEANUP: assorted typo fixes in the code and comments
    - DOC: assorted typo fixes in the documentation
    - CI: codespell: whitelist "te" and "nd" words

4 years agoCI: codespell: whitelist "te" and "nd" words
Ilya Shipitsin [Sun, 20 Dec 2020 20:03:12 +0000 (01:03 +0500)] 
CI: codespell: whitelist "te" and "nd" words

te is widely used abbrevation for "transfer encoding"
nd is variable name "name description"

we need to teach codespell those are legitimate

4 years agoDOC: assorted typo fixes in the documentation
Ilya Shipitsin [Sun, 20 Dec 2020 20:22:40 +0000 (01:22 +0500)] 
DOC: assorted typo fixes in the documentation

This is another round of cleanups in various docs

4 years agoCLEANUP: assorted typo fixes in the code and comments
Ilya Shipitsin [Sun, 20 Dec 2020 20:16:17 +0000 (01:16 +0500)] 
CLEANUP: assorted typo fixes in the code and comments

This is 13n iteration of typo fixes

4 years agoDOC: fix "smp_size" vs "sample_size" in "log" directive arguments
Jan Wagner [Thu, 17 Dec 2020 21:22:32 +0000 (22:22 +0100)] 
DOC: fix "smp_size" vs "sample_size" in "log" directive arguments

The "log" directive syntax shows an argument named "smp_size" but the
description mentions "sample_size". Let's fix this.

4 years agoBUG/MINOR: dns: SRV records ignores duplicated AR records
Baptiste Assmann [Wed, 25 Nov 2020 07:17:59 +0000 (08:17 +0100)] 
BUG/MINOR: dns: SRV records ignores duplicated AR records

This bug happens when a service has multiple records on the same host
and the server provides the A/AAAA resolution in the response as AR
(Additional Records).

In such condition, the first occurence of the host will be taken from
the Additional section, while the second (and next ones) will be process
by an independent resolution task (like we used to do before 2.2).
This can lead to a situation where the "synchronisation" of the
resolution may diverge, like described in github issue #971.

Because of this behavior, HAProxy mixes various type of requests to
resolve the full list of servers: SRV+AR for all "first" occurences and
A/AAAA for all other occurences of an existing hostname.
IE: with the following type of response:

   ;; ANSWER SECTION:
   _http._tcp.be2.tld.     3600    IN      SRV     5 500 80 A2.tld.
   _http._tcp.be2.tld.     3600    IN      SRV     5 500 86 A3.tld.
   _http._tcp.be2.tld.     3600    IN      SRV     5 500 80 A1.tld.
   _http._tcp.be2.tld.     3600    IN      SRV     5 500 85 A3.tld.

   ;; ADDITIONAL SECTION:
   A2.tld.                 3600    IN      A       192.168.0.2
   A3.tld.                 3600    IN      A       192.168.0.3
   A1.tld.                 3600    IN      A       192.168.0.1
   A3.tld.                 3600    IN      A       192.168.0.3

the first A3 host is resolved using the Additional Section and the
second one through a dedicated A request.

When linking the SRV records to their respective Additional one, a
condition was missing (chek if said SRV record is already attached to an
Additional one), leading to stop processing SRV only when the target
SRV field matches the Additional record name. Hence only the first
occurence of a target was managed by an additional record.
This patch adds a condition in this loop to ensure the record being
parsed is not already linked to an Additional Record. If so, we can
carry on the parsing to find a possible next one with the same target
field value.

backport status: 2.2 and above

4 years agoBUILD: ssl: fine guard for SSL_CTX_get0_privatekey call
Ilya Shipitsin [Fri, 18 Dec 2020 22:12:12 +0000 (03:12 +0500)] 
BUILD: ssl: fine guard for SSL_CTX_get0_privatekey call

SSL_CTX_get0_privatekey is openssl/boringssl specific function present
since openssl-1.0.2, let us define readable guard for it, not depending
on HA_OPENSSL_VERSION

4 years agoBUILD: plock: remove dead code that causes a warning in gcc 11
Willy Tarreau [Mon, 21 Dec 2020 09:27:18 +0000 (10:27 +0100)] 
BUILD: plock: remove dead code that causes a warning in gcc 11

As Ilya reported in issue #998, gcc 11 complains about misleading code
indentation which is in fact caused by dead assignments to zero after
a loop which stops on zero. Let's clean both of these.

4 years agoCONTRIB: debug: address "poll" utility build on non-linux platforms
Willy Tarreau [Mon, 21 Dec 2020 07:43:50 +0000 (08:43 +0100)] 
CONTRIB: debug: address "poll" utility build on non-linux platforms

MSG_NOSIGNAL and MSG_MORE are not defined everywhere, let's make them
zero when not defined. It will roughly result in the same behavior,
albeit a bit less optimal, which is no big deal when debugging. This
should fix issue #1014.

4 years agoCONTRIB: halog: fix signed/unsigned build warnings on counts and timestamps
Willy Tarreau [Mon, 21 Dec 2020 07:40:04 +0000 (08:40 +0100)] 
CONTRIB: halog: fix signed/unsigned build warnings on counts and timestamps

Some variables were signed while they were compared to unsigned ones,
causing warnings to be issued when -Wextra is enabled.

4 years agoCONTRIB: halog: mark the has_zero* functions unused
Willy Tarreau [Mon, 21 Dec 2020 07:35:24 +0000 (08:35 +0100)] 
CONTRIB: halog: mark the has_zero* functions unused

These ones will depend on the use of memchr() or not, let's mark them unused
to avoid the warning reported in issue #1013.

4 years agoCONTRIB: halog: fix build issue caused by %L printf format
Willy Tarreau [Mon, 21 Dec 2020 07:29:09 +0000 (08:29 +0100)] 
CONTRIB: halog: fix build issue caused by %L printf format

%Ld isn't standard, %lld is more portable. In addition, the format
should be %llu since the printed values are unsigned. This should
address issue #1013.

4 years agoCLEANUP: debug: mark the RNG's seed as unsigned
Willy Tarreau [Fri, 18 Dec 2020 15:26:36 +0000 (16:26 +0100)] 
CLEANUP: debug: mark the RNG's seed as unsigned

Since commit 8a069eb9a ("MINOR: debug: add a trivial PRNG for scheduler
stress-tests"), 32-bit gcc 4.7 emits this warning when parsing the
initial seed for the debugger's RNG (2463534242):

  src/debug.c:46:1: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]

Let's mark it explicitly unsigned.

4 years agoBUG/MEDIUM: mux-h1: Handle h1_process() failures on a pipelined request
Christopher Faulet [Fri, 18 Dec 2020 14:13:47 +0000 (15:13 +0100)] 
BUG/MEDIUM: mux-h1: Handle h1_process() failures on a pipelined request

On frontend side, when a conn-stream is detached from a H1 connection, the
H1 stream is destroyed and if we already have some data to parse (a
pipelined request), we process these data immedialtely calling
h1_process(). Then we adjust the H1 connection timeout. But h1_process() may
fail and release the H1 connection. For instance, a parsing error may be
reported. Thus, when that happens, we must not use anymore the H1 connection
and exit.

This patch must be backported as far as the 2.2. This bug can impact the 2.3
and the 2.2, in theory, if h1 stream creation fails. But, concretly, it only
fails on the 2.4 because the requests are now parsed at this step.

4 years agoCLEANUP: mux-h2: Rename h2c_frt_handle_data() to be generic
Christopher Faulet [Mon, 7 Dec 2020 17:27:03 +0000 (18:27 +0100)] 
CLEANUP: mux-h2: Rename h2c_frt_handle_data() to be generic

h2c_frt_handle_data() is now used to parse DATA frames on the frontend and
the backend side. Thus it is renamed into h2c_handle_data().

4 years agoCLEANUP: mux-h2: Rename h2s_frt_make_resp_data() to be generic
Christopher Faulet [Wed, 2 Dec 2020 14:12:40 +0000 (15:12 +0100)] 
CLEANUP: mux-h2: Rename h2s_frt_make_resp_data() to be generic

h2s_frt_make_resp_data() is now used to emit DATA frames on the frontend and
the backend side. Thus it is renamed into h2s_make_data().

4 years agoBUG/MEDIUM: http-ana: Never for sending data in TUNNEL mode
Christopher Faulet [Tue, 15 Dec 2020 12:32:55 +0000 (13:32 +0100)] 
BUG/MEDIUM: http-ana: Never for sending data in TUNNEL mode

When a channel is set in TUNNEL mode, we now always set the CF_NEVER_WAIT flag,
to be sure to never wait for sending data. It is important because in TUNNEL
mode, we have no idea if more data are expected or not. Setting this flag
prevent the MSG_MORE flag to be set on the connection.

It is only a problem with the HTX, since the 2.2. On previous versions, the
MSG_MORE flag is only set on the mux initiative. In fact, the problem arises
because there is an ambiguity in tunnel mode about the HTX_FL_EOI flag. In this
mode, from the mux point of view, while the SHUTR is not received more data are
expected. But from the channel point of view, we want to send data asap.

At short term, this fix is good enough and is valid anyway. But for the long
term more reliable solution must be found. At least, the to_forward field must
regain its original meaning.

This patch must be backported as far as 2.2.

4 years agoBUG/MINOR: mux-h1: Don't set CS_FL_EOI too early for protocol upgrade requests
Christopher Faulet [Mon, 7 Dec 2020 17:21:27 +0000 (18:21 +0100)] 
BUG/MINOR: mux-h1: Don't set CS_FL_EOI too early for protocol upgrade requests

When a protocol upgrade request is received, once parsed, it is waiting for
the response in the DONE state. But we must not set the flag CS_FL_EOI
because we don't know if a protocol upgrade will be performed or not.

Now, it is set on the response path, if both sides reached the DONE
state. If a protocol upgrade is finally performed, both side are switched in
TUNNEL state. Thus the CS_FL_EOI flag is not set.

If backported, this patch must be adapted because for now it relies on last
2.4-dev changes. It may be backported as far as 2.0.

4 years agoBUG/MINOR: http: Establish a tunnel for all 2xx responses to a CONNECT
Christopher Faulet [Mon, 7 Dec 2020 17:10:32 +0000 (18:10 +0100)] 
BUG/MINOR: http: Establish a tunnel for all 2xx responses to a CONNECT

As stated in the rfc7231, section 4.3.6, an HTTP tunnel via a CONNECT method
is successfully established if the server replies with any 2xx status
code. However, only 200 responses are considered as valid. With this patch,
any 2xx responses are now considered to estalish the tunnel.

This patch may be backported on demand to all stable versions and adapted
for the legacy HTTP. It works this way since a very long time and nobody
complains.

4 years agoREGTESTS: make use of HAPROXY_ARGS and pass -dM by default
Willy Tarreau [Wed, 16 Dec 2020 09:39:20 +0000 (10:39 +0100)] 
REGTESTS: make use of HAPROXY_ARGS and pass -dM by default

Enabling memory poisonning is often pretty effective for detecting
uninitialized structure fields. Let's enable it by default and let
the user change the arguments at will (e.g. forcing some memory limits
or disabling a poller). This will work with the latest vtest version
to date (02a9bc1).

4 years agoDOC: opentracing: add the OpenTracing filter section
Miroslav Zagorac [Sun, 13 Dec 2020 17:32:57 +0000 (18:32 +0100)] 
DOC: opentracing: add the OpenTracing filter section

4 years agoCONTRIB: opentracing: add the OpenTracing filter
Miroslav Zagorac [Wed, 9 Dec 2020 15:54:31 +0000 (16:54 +0100)] 
CONTRIB: opentracing: add the OpenTracing filter

This commit adds the OpenTracing filter (hereinafter we will use the
abbreviated name 'the OT filter') to the contrib tree.

The OT filter adds native support for using distributed tracing in HAProxy.
This is enabled by sending an OpenTracing compliant request to one of the
supported tracers; such as Datadog, Jaeger, Lightstep and Zipkin tracers.
Please note: tracers are not listed by any preference, but alphabetically.

The OT filter is a standard HAProxy filter, so what applies to others also
applies to this one (of course, by that I mean what is described in the
documentation, more precisely in the doc/internals/filters.txt file).

The OT filter activation is done explicitly by specifying it in the HAProxy
configuration.  If this is not done, the OT filter in no way participates
in the work of HAProxy.

As for the impact on HAProxy speed, this is documented with several tests
located in the test directory, and the result is found in the README-speed-*
files.  In short, the speed of operation depends on the way it is used and
the complexity of the configuration, from an almost immeasurable impact to
a significant deceleration (5x and more).  I think that in some normal use
the speed of HAProxy with the filter on will be quite satisfactory with a
slowdown of less than 4%.

The OT filter allows intensive use of ACLs, which can be defined anywhere in
the configuration.  Thus, it is possible to use the filter only for those
connections that are of interest to us.

More detailed documentation related to the operation, configuration and use
of the filter can be found in the contrib/opentracing directory.

To make the OpenTracing filter easier to configure and compile, several
entries have been added to the Makefile.  When running the make utility,
it is possible to use several new arguments:

  USE_OT=1     : enable the OpenTracing filter
  OT_DEBUG=1   : compile the OpenTracing filter in debug mode
  OT_INC=path  : force the include path to libopentracing-c-wrapper
  OT_LIB=path  : force the lib path to libopentracing-c-wrapper
  OT_RUNPATH=1 : add libopentracing-c-wrapper RUNPATH to haproxy executable

If USE_OT is set, then an additional Makefile from the contrib/opentracing
directory is included in the compilation process.

4 years agoMINOR: opentracing: add ARGC_OT enum
Miroslav Zagorac [Wed, 9 Dec 2020 15:31:48 +0000 (16:31 +0100)] 
MINOR: opentracing: add ARGC_OT enum

Due to the addition of the OpenTracing filter it is necessary to define
ARGC_OT enum.  This value is used in the functions fmt_directive() and
smp_resolve_args().

4 years agoMINOR: vars: replace static functions with global ones
Miroslav Zagorac [Wed, 9 Dec 2020 15:34:29 +0000 (16:34 +0100)] 
MINOR: vars: replace static functions with global ones

The OpenTracing filter uses several internal HAProxy functions to work
with variables and therefore requires two static local HAProxy functions,
var_accounting_diff() and var_clear(), to be declared global.

In fact, the var_clear() function was not originally defined as static,
but it lacked a declaration.

4 years agoBUILD: Makefile: have "make clean" destroy .o/.a/.s in contrib subdirs as well
Willy Tarreau [Wed, 16 Dec 2020 13:14:38 +0000 (14:14 +0100)] 
BUILD: Makefile: have "make clean" destroy .o/.a/.s in contrib subdirs as well

Now that we sometimes link some contrib subparts directly into the
haproxy binary, it's becoming a real problem that they're not cleaned
on make clean.  Some of the tools there are useful as .so or pure
binaries and we don't want to remove them, but anything intermediary
susceptible to be linked into haproxy should be clenaed. This is what
this patch does for 3 levels of subdirs into contrib/, without touching
the rest. It should be sufficient for the vast majority of use cases.

4 years agoCI: cirrus: drop CentOS 6 builds
Ilya Shipitsin [Wed, 16 Dec 2020 08:06:53 +0000 (13:06 +0500)] 
CI: cirrus: drop CentOS 6 builds

CentOS 6 packages were removed from repo. Also, I was not able
to get it working using centos vault.

Further discussion on ML:

https://www.mail-archive.com/haproxy@formilux.org/msg38908.html

4 years agoMINOR: cache: Add a max-secondary-entries cache option
Remi Tricot-Le Breton [Thu, 10 Dec 2020 16:58:43 +0000 (17:58 +0100)] 
MINOR: cache: Add a max-secondary-entries cache option

This new option allows to tune the maximum number of simultaneous
entries with the same primary key in the cache (secondary entries).
When we try to store a response in the cache and there are already
max-secondary-entries living entries in the cache, the storage will
fail (but the response will still be sent to the client).
It defaults to 10 and does not have a maximum number.

4 years agoMEDIUM: cache: Avoid going over duplicates lists too often
Remi Tricot-Le Breton [Thu, 10 Dec 2020 16:58:42 +0000 (17:58 +0100)] 
MEDIUM: cache: Avoid going over duplicates lists too often

The secondary entry counter cannot be updated without going over all the
items of a duplicates list periodically. In order to avoid doing it too
often and to impact the cache's performances, a timestamp is added to
the cache_entry. It will store the timestamp (with second precision) of
the last iteration over the list (actually the last call of the
clear_expired_duplicates function). This way, this function will not be
called more than once per second for a given duplicates list.

4 years agoMEDIUM: cache: Add a secondary entry counter and insertion limitation
Remi Tricot-Le Breton [Thu, 10 Dec 2020 16:58:41 +0000 (17:58 +0100)] 
MEDIUM: cache: Add a secondary entry counter and insertion limitation

Add an arbitrary maximum number of secondary entries per primary hash
(10 for now) to the cache. This prevents the cache from being filled
with duplicates of the same resource.
This works thanks to an entry counter that is kept in one of the
duplicates of the list (the last one).
When an entry is added to the list, the ebtree's implementation ensures
that it will be added to the end of the existing list so the only thing
to do to keep the counter updated is to get the previous counter from
the second to last entry.
Likewise, when an entry is explicitely deleted, we update the counter
from the list's last item.

4 years agoBUILD: SSL: fine guard for SSL_CTX_add_server_custom_ext call
Ilya Shipitsin [Thu, 26 Nov 2020 21:39:48 +0000 (02:39 +0500)] 
BUILD: SSL: fine guard for SSL_CTX_add_server_custom_ext call

SSL_CTX_add_server_custom_ext is openssl specific function present
since openssl-1.0.2, let us define readable guard for it, not depending
on HA_OPENSSL_VERSION

4 years agoBUG/MAJOR: cache: Crash because of disabled entry not removed from the tree
Remi Tricot-Le Breton [Tue, 15 Dec 2020 13:30:12 +0000 (14:30 +0100)] 
BUG/MAJOR: cache: Crash because of disabled entry not removed from the tree

The cache entries are now added into the tree even when they are not
complete yet. If we realized while trying to add a response's payload
that the shctx was full, the entry was disabled through the
disable_cache_entry function, which cleared the key field of the entry's
node, but without actually removing it from the tree. So the shctx row
could be stolen from the entry and the row's content be rewritten while
a lookup in the tree would still find a reference to the old entry. This
caused a random crash in case of cache saturation and row reuse.
This patch adds the missing removal of the node from the tree next to
the reset of the key in disable_cache_entry.

This bug was introduced by commit 3243447 ("MINOR: cache: Add entry
to the tree as soon as possible")

It does not need to be backported.

4 years agoBUG/MEDIUM: ssl/crt-list: bad behavior with "commit ssl cert"
William Lallemand [Tue, 15 Dec 2020 13:57:46 +0000 (14:57 +0100)] 
BUG/MEDIUM: ssl/crt-list: bad behavior with "commit ssl cert"

In issue #1004, it was reported that it is not possible to remove
correctly a certificate after updating it when it came from a crt-list.

Indeed the "commit ssl cert" command on the CLI does not update the list
of ckch_inst in the crtlist_entry. Because of this, the "del ssl
crt-list" command does not remove neither the instances nor the SNIs
because they were never linked to the crtlist_entry.

This patch fixes the issue by inserting the ckch_inst in the
crtlist_entry once generated.

Must be backported as far as 2.2.

4 years agoBUG/MEDIUM: mux-h1: Fix a deadlock when a 408 error is pending for a client
Christopher Faulet [Mon, 14 Dec 2020 09:06:12 +0000 (10:06 +0100)] 
BUG/MEDIUM: mux-h1: Fix a deadlock when a 408 error is pending for a client

When a frontend H1 connection timed out waiting for the next request, a 408
error message is returned to the client. It is performed into the H1C task
process function, h1_timeout_task(), and under the idle connection takeover
lock. If the 408 error message cannot be sent immediately, we wait for a
next retry. In this case, the lock must be released.

This bug was introduced by the commit c4bfa59f1d ("MAJOR: mux-h1: Create the
client stream as later as possible") and is specific to the 2.4-DEV. No
backport needed.

4 years agoBUG/MEDIUM: lb-leastconn: Reposition a server using the right eweight
Christopher Faulet [Fri, 11 Dec 2020 14:36:01 +0000 (15:36 +0100)] 
BUG/MEDIUM: lb-leastconn: Reposition a server using the right eweight

Depending on the context, the current eweight or the next one must be used
to reposition a server in the tree. When the server state is updated, for
instance its weight, the next eweight must be used because it is not yet
committed. However, when the server is used, on normal conditions, the
current eweight must be used.

In fact, it is only a bug on the 1.8. On newer versions, the changes on a
server are performed synchronously. But it is safer to rely on the right
eweight value to avoid any futur bugs.

On the 1.8, it is important to do so, because the server state is updated
and committed inside the rendez-vous point. Thus, the next server state may
be unsync with the current state for a short time, waiting all threads join
the rendez-vous point. It is especially a problem if the next eweight is set
to 0. Because otherwise, it must not be used to reposition the server in the
tree, leading to a divide by 0.

This patch must be backported as far as 1.8.

4 years ago[RELEASE] Released version 2.4-dev3 v2.4-dev3
Willy Tarreau [Fri, 11 Dec 2020 16:22:51 +0000 (17:22 +0100)] 
[RELEASE] Released version 2.4-dev3

Released version 2.4-dev3 with the following main changes :
    - MINOR: log: Logging HTTP path only with %HPO
    - BUG/MINOR: mux-h2/stats: make stream/connection proto errors more accurate
    - MINOR: traces: add a new level "error" below the "user" level
    - MINOR: mux-h2/trace: add traces at level ERROR for protocol errors
    - BUG/MINOR: mux-h2/stats: not all GOAWAY frames are errors
    - BUG/MINOR: lua: missing "\n" in error message
    - BUG/MINOR: lua: lua-load doesn't check its parameters
    - BUG/MINOR: lua: Post init register function are not executed beyond the first one
    - BUG/MINOR: lua: Some lua init operation are processed unsafe
    - MINOR: actions: Export actions lookup functions
    - MINOR: actions: add a function returning a service pointer from its name
    - MINOR: cli: add a function to look up a CLI service description
    - BUG/MINOR: lua: warn when registering action, conv, sf, cli or applet multiple times
    - MINOR: cache: Improve accept_encoding_normalizer
    - MINOR: cache: Add entry to the tree as soon as possible
    - BUG/MINOR: trace: Wrong displayed trace level
    - BUG/MAJOR: ring: tcp forward on ring can break the reader counter.
    - MINOR: lua: simplify hlua_alloc() to only rely on realloc()
    - MEDIUM: lua-thread: use atomics for memory accounting
    - MINOR: lua-thread: remove struct hlua from function hlua_prepend_path()
    - MEDIUM: lua-thread: make hlua_post_init() no longer use the runtime execution function
    - MINOR: lua-thread: hlua_ctx_renew() is never called with main gL lua state
    - MINOR: lua-thread: Use NULL context for main lua state
    - MINOR: lua-thread: Stop usage of struct hlua for the global lua state
    - MINOR: lua-thread: Replace embedded struct hlua_function by a pointer
    - MINOR: lua-thread: Split hlua_init() function in two parts
    - MINOR: lua-thread: make hlua_ctx_init() get L from its caller
    - MINOR: lua-thread: Split hlua_load function in two parts
    - MINOR: lua-thread: Split hlua_post_init() function in two parts
    - MINOR: lua-thread: Add the "thread" core variable
    - MEDIUM: lua-thread: No longer use locked context in initialization parts
    - MEDIUM: lua-thread: Apply lock only if the parent state is the main thread
    - MINOR: lua-thread: Replace global gL var with an array of states
    - MINOR: lua-thread: Replace "struct hlua_function" allocation by dedicated function
    - MINOR: lua-thread: Replace state_from by state_id
    - MINOR: lua-thread: Store each function reference and init reference in array
    - MEDIUM: lua-thread: Add the lua-load-per-thread directive
    - MINOR: lua-thread: Add verbosity in errors
    - REGTESTS: add a test for the threaded Lua code
    - BUILD/MINOR: haproxy DragonFlyBSD affinity build update.
    - DOC/MINOR: Fix formatting in Management Guide
    - MINOR: cache: Do not store stale entry
    - MINOR: cache: Add extra "cache-control" value checks
    - MEDIUM: cache: Remove cache entry in case of POST on the same resource
    - MINOR: cache: Consider invalid Age values as stale
    - BUG/MEDIUM: lua-thread: some parts must be initialized once
    - BUG/MINOR: lua-thread: close all states on deinit
    - BUG/MINOR: listener: use sockaddr_in6 for IPv6
    - BUG/MINOR: mux-h1: Handle keep-alive timeout for idle frontend connections
    - MINOR: session: Add the idle duration field into the session
    - MINOR: mux-h1: Update session idle duration when data are received
    - MINOR: mux-h1: Reset session dates and durations info when the CS is detached
    - MINOR: logs: Use session idle duration when no stream is provided
    - MINOR: stream: Always get idle duration from the session
    - MINOR: stream: Don't retrieve anymore timing info from the mux csinfo
    - MINOR: mux-h1: Don't provide anymore timing info using cs_info structure
    - MINOR: muxes: Remove get_cs_info callback function now useless
    - MINOR: stream: Pass an optional input buffer when a stream is created
    - MINOR: mux-h1: Add a flag to disable reads to wait opposite side
    - MEDIUM: mux-h1: Use a h1c flag to block reads when splicing is in-progress
    - MINOR: mux-h1: Introduce H1C_F_IS_BACK flag on the H1 connection
    - MINOR: mux-h1: Separate parsing and formatting errors at H1 stream level
    - MINOR: mux-h1: Split front/back h1 stream creation in 2 functions
    - MINOR: mux-h1: Add a rxbuf into the H1 stream
    - MINOR: mux-h1: Don't set CS flags in internal parsing functions
    - MINOR: mux-h1: Add embryonic and attached states on the H1 connection
    - MINOR: mux-h1: rework the h1_timeout_task() function
    - MINOR: mux-h1: Reset more H1C flags when a H1 stream is destroyed
    - MINOR: mux-h1: Disable reads if an error was reported on the H1 stream
    - MINOR: mux-h1: Rework how shutdowns are handled
    - MINOR: mux-h1: Rework h1_refresh_timeout to be easier to read
    - MINOR: mux-h1: Process next request for IDLE connection only
    - MINOR: mux-h1: Add a idle expiration date on the H1 connection
    - MINOR: stick-tables: Add functions to update some values of a tracked counter
    - MINOR: session: Add functions to increase http values of tracked counters
    - MINOR: mux: Add a ctl parameter to get the exit status of the multiplexers
    - MINOR: logs: Get the multiplexer exist status when no stream is provided
    - MINOR: mux-h1: Add functions to send HTTP errors from the mux
    - MAJOR: mux-h1: Create the client stream as later as possible
    - DOC: config: Add notes about errors emitted by H1 mux
    - CLEANUP: mux-h1: Rename H1C_F_CS_* flags and reorder H1C flags
    - MINOR: http-ana: Remove useless update of t_idle duration of the stream
    - CLEANUP: htx: Remove HTX_FL_UPGRADE unsued flag
    - MEDIUM: http-ana: Don't process partial or empty request anymore
    - CLEANUP: http-ana: Remove TX_WAIT_NEXT_RQ unsued flag
    - CLEANUP: connection: Remove CS_FL_READ_PARTIAL flag
    - REGTESTS: Fix proxy_protocol_tlv_validation
    - MINOR: http-ana: Properly set message flags from the start-line flags
    - MINOR: h1-htx/http-ana: Set BODYLESS flag on message in TUNNEL state
    - MINOR: protocol: add a ->set_port() helper to address families
    - MINOR: listener: automatically set the port when creating listeners
    - MINOR: listener: now use a generic add_listener() function
    - MEDIUM: ssl: fatal error with bundle + openssl < 1.1.1
    - BUG/MEDIUM: stream: Xfer the input buffer to a fully created stream
    - BUG/MINOR: stream: Don't use input buffer after the ownership xfer
    - MINOR: protocol: remove the redundant ->sock_domain field
    - MINOR: protocol: export protocol definitions
    - CLEANUP: protocol: group protocol struct members by usage
    - MINOR: protocol: add a set of ctrl_init/ctrl_close methods for setup/teardown
    - MINOR: connection: use the control layer's init/close
    - MINOR: udp: export udp_suspend_receiver() and udp_resume_receiver()
    - BUG/MAJOR: spoa/python: Fixing return None
    - DOC: spoa/python: Fixing typo in IP related error messages
    - DOC: spoa/python: Rephrasing memory related error messages
    - DOC: spoa/python: Fixing typos in comments
    - BUG/MINOR: spoa/python: Cleanup references for failed Module Addobject operations
    - BUG/MINOR: spoa/python: Cleanup ipaddress objects if initialization fails
    - BUG/MEDIUM: spoa/python: Fixing PyObject_Call positional arguments
    - BUG/MEDIUM: spoa/python: Fixing references to None
    - DOC: email change of the DeviceAtlas maintainer
    - MINOR: cache: Dump secondary entries in "show cache"
    - CLEANUP: connection: use fd_stop_both() instead of conn_stop_polling()
    - MINOR: stream-int: don't touch polling anymore on shutdown
    - MINOR: connection: implement cs_drain_and_close()
    - MINOR: mux-pt: take care of CS_SHR_DRAIN in shutr()
    - MINOR: checks: use cs_drain_and_close() instead of draining the connection
    - MINOR: checks: don't call conn_cond_update_polling() anymore
    - CLEANUP: connection: open-code conn_cond_update_polling() and update the comment
    - CLEANUP: connection: remove the unused conn_{stop,cond_update}_polling()
    - BUG/MINOR: http-check: Use right condition to consider HTX message as full
    - BUG/MINOR: tcpcheck: Don't rearm the check timeout on each read
    - MINOR: tcpcheck: Only wait for more payload data on HTTP expect rules
    - BUG/MINOR: tools: make parse_time_err() more strict on the timer validity
    - BUG/MINOR: tools: Reject size format not starting by a digit
    - MINOR: action: define enum for timeout type of the set-timeout rule
    - MINOR: stream: prepare the hot refresh of timeouts
    - MEDIUM: stream: support a dynamic server timeout
    - MEDIUM: stream: support a dynamic tunnel timeout
    - MEDIUM: http_act: define set-timeout server/tunnel action
    - MINOR: frontend: add client timeout sample fetch
    - MINOR: backend: add timeout sample fetches
    - MINOR: stream: add sample fetches
    - MINOR: stream: add timeout sample fetches
    - REGTESTS: add regtest for http-request set-timeout
    - CLEANUP: remove the unused fd_stop_send() in conn_xprt_shutw{,_hard}()
    - CLEANUP: connection: remove the unneeded fd_stop_{recv,send} on read0/shutw
    - MINOR: connection: remove sock-specific code from conn_sock_send()
    - REORG: connection: move the socket iocb (conn_fd_handler) to sock.c
    - MINOR: protocol: add a ->drain() function at the connection control layer
    - MINOR: connection: make conn_sock_drain() use the control layer's ->drain()
    - MINOR: protocol: add a pair of check_events/ignore_events functions at the ctrl layer
    - MEDIUM: connection: make use of the control layer check_events/ignore_events

4 years agoMEDIUM: connection: make use of the control layer check_events/ignore_events
Willy Tarreau [Fri, 11 Dec 2020 16:06:11 +0000 (17:06 +0100)] 
MEDIUM: connection: make use of the control layer check_events/ignore_events

This changes the subscribe/unsubscribe functions to rely on the control
layer's check_events/ignore_events. At the moment only the socket version
of these functions is present so the code should basically be the same.

4 years agoMINOR: protocol: add a pair of check_events/ignore_events functions at the ctrl layer
Willy Tarreau [Fri, 11 Dec 2020 16:02:50 +0000 (17:02 +0100)] 
MINOR: protocol: add a pair of check_events/ignore_events functions at the ctrl layer

Right now the connection subscribe/unsubscribe code needs to manipulate
FDs, which is not compatible with QUIC. In practice what we need there
is to be able to either subscribe or wake up depending on readiness at
the moment of subscription.

This commit introduces two new functions at the control layer, which are
provided by the socket code, to check for FD readiness or subscribe to it
at the control layer. For now it's not used.

4 years agoMINOR: connection: make conn_sock_drain() use the control layer's ->drain()
Willy Tarreau [Fri, 11 Dec 2020 15:20:34 +0000 (16:20 +0100)] 
MINOR: connection: make conn_sock_drain() use the control layer's ->drain()

Now we don't touch the fd anymore there, instead we rely on the ->drain()
provided by the control layer. As such the function was renamed to
conn_ctrl_drain().

4 years agoMINOR: protocol: add a ->drain() function at the connection control layer
Willy Tarreau [Fri, 11 Dec 2020 15:19:12 +0000 (16:19 +0100)] 
MINOR: protocol: add a ->drain() function at the connection control layer

This is what we need to drain pending incoming data from an connection.
The code was taken from conn_sock_drain() without the connection-specific
stuff. It still takes a connection for now for API simplicity.

4 years agoREORG: connection: move the socket iocb (conn_fd_handler) to sock.c
Willy Tarreau [Fri, 11 Dec 2020 14:54:36 +0000 (15:54 +0100)] 
REORG: connection: move the socket iocb (conn_fd_handler) to sock.c

conn_fd_handler() is 100% specific to socket code. It's about time
it moves to sock.c which manipulates socket FDs. With it comes
conn_fd_check() which tests for the socket's readiness. The ugly
connection status check at the end of the iocb was moved to an inlined
function in connection.h so that if we need it for other socket layers
it's not too hard to reuse.

The code was really only moved and not changed at all.

4 years agoMINOR: connection: remove sock-specific code from conn_sock_send()
Willy Tarreau [Fri, 11 Dec 2020 14:26:55 +0000 (15:26 +0100)] 
MINOR: connection: remove sock-specific code from conn_sock_send()

The send() loop present in this function and the error handling is already
present in raw_sock_from_buf(). Let's rely on it instead and stop touching
the FD from this place. The send flag was changed to use a more agnostic
CO_SFL_*. The name was changed to "conn_ctrl_send()" to remind that it's
meant to be used to send at the lowest level.

4 years agoCLEANUP: connection: remove the unneeded fd_stop_{recv,send} on read0/shutw
Willy Tarreau [Fri, 11 Dec 2020 12:56:12 +0000 (13:56 +0100)] 
CLEANUP: connection: remove the unneeded fd_stop_{recv,send} on read0/shutw

These are two other areas where this fd_stop_recv()/fd_stop_send() makes no
sense anymore. Both happen by definition while the FD is *not* subscribed,
since nowadays it's subscribed after failing recv()/send(), in which case
we cannot close.

4 years agoCLEANUP: remove the unused fd_stop_send() in conn_xprt_shutw{,_hard}()
Willy Tarreau [Fri, 11 Dec 2020 12:49:19 +0000 (13:49 +0100)] 
CLEANUP: remove the unused fd_stop_send() in conn_xprt_shutw{,_hard}()

These functions used to disable polling for writes when shutting down
but this is no longer used as it still happens later when closing if the
connection was subscribed to FD events. Let's just remove this fake and
undesired dependency on the FD layer.

4 years agoREGTESTS: add regtest for http-request set-timeout
Amaury Denoyelle [Thu, 10 Dec 2020 12:44:01 +0000 (13:44 +0100)] 
REGTESTS: add regtest for http-request set-timeout

This test compares the timeout value for requests using the sample
fetches in accordance with the application of set-timeout rules.

4 years agoMINOR: stream: add timeout sample fetches
Amaury Denoyelle [Thu, 10 Dec 2020 12:43:58 +0000 (13:43 +0100)] 
MINOR: stream: add timeout sample fetches

Add cur_server_timeout and cur_tunnel_timeout.

These sample fetches return the current timeout value for a stream. This
is useful to retrieve the value of a timeout which was changed via a
set-timeout rule.

4 years agoMINOR: stream: add sample fetches
Amaury Denoyelle [Thu, 10 Dec 2020 12:43:57 +0000 (13:43 +0100)] 
MINOR: stream: add sample fetches

Prepare the possibility to register sample fetches on the stream.

This commit is necessary to implement sample fetches to retrieve the
current timeout values.