]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
3 years agoBUG/MEDIUM: ssl: initialize correctly ssl w/ default-server
William Lallemand [Tue, 28 Dec 2021 17:47:17 +0000 (18:47 +0100)] 
BUG/MEDIUM: ssl: initialize correctly ssl w/ default-server

This bug was introduced by d817dc73 ("MEDIUM: ssl: Load client
certificates in a ckch for backend servers") in which the creation of
the SSL_CTX for a server was moved to the configuration parser when
using a "crt" keyword instead of being done in ssl_sock_prepare_srv_ctx().

The patch 0498fa40 ("BUG/MINOR: ssl: Default-server configuration ignored by
server") made it worse by setting the same SSL_CTX for every servers
using a default-server. Resulting in any SSL option on a server applied
to every server in its backend.

This patch fixes the issue by reintroducing a string which store the
path of certificate inside the server structure, and loading the
certificate in ssl_sock_prepare_srv_ctx() again.

This is a quick fix to backport, a cleaner way can be achieve by always
creating the SSL_CTX in ssl_sock_prepare_srv_ctx() and splitting
properly the ssl_sock_load_srv_cert() function.

This patch fixes issue #1488.

Must be backported as far as 2.4.

3 years agoMINOR: debug: add support for -dL to dump library names at boot
Willy Tarreau [Tue, 28 Dec 2021 14:43:11 +0000 (15:43 +0100)] 
MINOR: debug: add support for -dL to dump library names at boot

This is a second help to dump loaded library names late at boot, once
external code has already been initialized. The purpose is to provide
a format that makes it easy to pass to "tar" to produce an archive
containing the executable and the list of dependencies. For example
if haproxy is started as "haproxy -f foo.cfg", a config check only
will suffice to quit before starting, "-q" will be used to disable
undesired output messages, and -dL will be use to dump libraries.
This will result in such a command to trivially produce a tarball
of loaded libraries:

   ./haproxy -q -c -dL -f foo.cfg | tar -T - -hzcf archive.tgz

3 years agoMINOR: debug: add ability to dump loaded shared libraries
Willy Tarreau [Tue, 28 Dec 2021 08:57:10 +0000 (09:57 +0100)] 
MINOR: debug: add ability to dump loaded shared libraries

Many times core dumps reported by users who experience trouble are
difficult to exploit due to missing system libraries. Sometimes,
having just a list of loaded libraries and their respective addresses
can already provide some hints about some problems.

This patch makes a step in that direction by adding a new "show libs"
command that will try to enumerate the list of object files that are
loaded in memory, relying on the dynamic linker for this. It may also
be used to detect that some foreign code embarks other undesired libs
(e.g. some external Lua modules).

At the moment it's only supported on glibc when USE_DL is set, but it's
implemented in a way that ought to make it reasonably easy to be extended
to other platforms.

3 years agoMINOR: compat: detect support for dl_iterate_phdr()
Willy Tarreau [Tue, 28 Dec 2021 14:13:12 +0000 (15:13 +0100)] 
MINOR: compat: detect support for dl_iterate_phdr()

We'll use this glibc function to dump loaded libs. It's been
available since glibc-2.2.4, and as it requires dlpi headers defined
in link.h, it implicitly relies on dlfcn, thus we condition it to
USE_DL. Other operating systems or libc might have different
dependencies so let's stick to the bare minimum for now.

3 years agoBUILD: opentracing: display warning in case of using OT_USE_VARS at compile time
Miroslav Zagorac [Mon, 27 Dec 2021 11:44:07 +0000 (12:44 +0100)] 
BUILD: opentracing: display warning in case of using OT_USE_VARS at compile time

Please do not set the OT_USE_VARS configuration variable, as the source
will probably not be able to compile!  For now, this variable can only
be used for experimental purposes, and is not intended for wider use.

For further clarification, please see commit 4cb2c83f4.

Must be backported to 2.5.

3 years agoCI: Github Actions: do not show VTest failures if build failed
Ilya Shipitsin [Sat, 25 Dec 2021 08:53:04 +0000 (13:53 +0500)] 
CI: Github Actions: do not show VTest failures if build failed

this is mostly cleanup, issue is minor. If build failed, VTest execution
tried to be performed as well as VTest result show. This change ignores
those steps if build failed.

3 years agoBUG/MEDIUM: peers: properly skip conn_cur from incoming messages
Willy Tarreau [Fri, 24 Dec 2021 12:38:49 +0000 (13:38 +0100)] 
BUG/MEDIUM: peers: properly skip conn_cur from incoming messages

The approach used for skipping conn_cur in commit db2ab8218 ("MEDIUM:
stick-table: never learn the "conn_cur" value from peers") was wrong,
it only works with simple tables but as soon as frequency counters or
arrays are exchanged after conn_cur, the stream is desynchronized and
incorrect values are read. This is because the fields have a variable
length depending on their types and cannot simply be skipped by a
"continue" statement.

Let's change the approach to make sure we continue to completely parse
these local-only fields, and only drop the value at the moment we're
about to store them, since this is exactly the intent.

A simpler approach could consist in having two sets of stktable_data_ptr()
functions, one for retrieval and one for storage, and to make the store
function return a NULL pointer for local types. For now this doesn't
seem worth the trouble.

This fixes github issue #1497. Thanks to @brenc for the reproducer.

This must be backported to 2.5.

3 years agoBUG/MEDIUM: backend: fix possible sockaddr leak on redispatch
Willy Tarreau [Fri, 24 Dec 2021 10:27:53 +0000 (11:27 +0100)] 
BUG/MEDIUM: backend: fix possible sockaddr leak on redispatch

A subtle change of target address allocation was introduced with commit
68cf3959b ("MINOR: backend: rewrite alloc of stream target address") in
2.4. Prior to this patch, a target address was allocated by function
assign_server_address() only if none was previously allocated. After
the change, the allocation became unconditional. Most of the time it
makes no difference, except when we pass multiple times through
connect_server() with SF_ADDR_SET cleared.

The most obvious fix would be to avoid allocating that address there
when already set, but the root cause is that since introduction of
dynamically allocated addresses, the SF_ADDR_SET flag lies. It can
be cleared during redispatch or during a queue redistribution without
the address being released.

This patch instead gives back all its correct meaning to SF_ADDR_SET
and guarantees that when not set no address is allocated, by freeing
that address at the few places the flag is cleared. The flag could
even be removed so that only the address is checked but that would
require to touch many areas for no benefit.

The easiest way to test it is to send requests to a proxy with l7
retries enabled, which forwards to a server returning 500:

  defaults
    mode http
    timeout client 1s
    timeout server 1s
    timeout connect 1s
    retry-on all-retryable-errors
    retries 1
    option redispatch

  listen proxy
    bind *:5000
    server app 0.0.0.0:5001

  frontend dummy-app
    bind :5001
    http-request return status 500

Issuing "show pools" on the CLI will show that pool "sockaddr" grows
as requests are redispatched, and remains stable with the fix. Even
"ps" will show that the process' RSS grows by ~160B per request.

This fix will need to be backported to 2.4. Note that before 2.5,
there's no strm->si[1].dst, strm->target_addr must be used instead.

This addresses github issue #1499. Special thanks to Daniil Leontiev
for providing a well-documented reproducer.

3 years agoBUG/MINOR: quic: fix potential use of uninit pointer
Amaury Denoyelle [Thu, 23 Dec 2021 15:32:24 +0000 (16:32 +0100)] 
BUG/MINOR: quic: fix potential use of uninit pointer

Properly initialized the ssl_sock_ctx pointer in qc_conn_init. This is
required to avoid to set an undefined pointer in qc.xprt_ctx if argument
*xprt_ctx is NULL.

3 years agoBUG/MINOR: quic: fix potential null dereference
Amaury Denoyelle [Thu, 23 Dec 2021 15:27:56 +0000 (16:27 +0100)] 
BUG/MINOR: quic: fix potential null dereference

This is not a real issue because found_in_dcid can not be set if qc is
NULL.

3 years agoMEDIUM: quic: implement refcount for quic_conn
Amaury Denoyelle [Thu, 23 Dec 2021 09:02:50 +0000 (10:02 +0100)] 
MEDIUM: quic: implement refcount for quic_conn

Implement a refcount on quic_conn instance. By default, the refcount is
0. Two functions are implemented to manipulate it.
* qc_conn_take() which increments the refcount
* qc_conn_drop() which decrements it. If the refcount is 0 *BEFORE*
  the substraction, the instance is freed.

The refcount is incremented on retrieve_qc_conn_from_cid() or when
allocating a new quic_conn in qc_lstnr_pkt_rcv(). It is substracted most
notably by the xprt.close operation and at the end of
qc_lstnr_pkt_rcv(). The increments/decrements should be conducted under
the CID lock to guarantee thread-safety.

3 years agoMINOR: quic: delete timer task on quic_close()
Amaury Denoyelle [Thu, 23 Dec 2021 14:06:56 +0000 (15:06 +0100)] 
MINOR: quic: delete timer task on quic_close()

The timer task is attached to the connection-pinned thread. Only this
thread can delete it. With the future refcount implementation of
quic_conn, every thread can be responsible to remove the quic_conn via
quic_conn_free(). Thus, the timer task deletion is moved from the
calling function quic_close().

3 years agoMINOR: quic: replace usage of ssl_sock_ctx by quic_conn
Amaury Denoyelle [Wed, 22 Dec 2021 10:06:34 +0000 (11:06 +0100)] 
MINOR: quic: replace usage of ssl_sock_ctx by quic_conn

Big refactoring on xprt-quic. A lot of functions were using the
ssl_sock_ctx as argument to only access the related quic_conn. All these
arguments are replaced by a quic_conn parameter.

As a convention, the quic_conn instance is always the first parameter of
these functions.

This commit is part of the rearchitecture of xprt-quic layers and the
separation between xprt and connection instances.

3 years agoMINOR: quic: remove unnecessary if in qc_pkt_may_rm_hp()
Amaury Denoyelle [Thu, 23 Dec 2021 15:02:24 +0000 (16:02 +0100)] 
MINOR: quic: remove unnecessary if in qc_pkt_may_rm_hp()

Remove the shortcut to use the INITIAL encryption level when removing
header protection on first connection packet.

This change is useful for the following change which removes
ssl_sock_ctx in argument lists in favor of the quic_conn instance.

3 years agoMINOR: quic: store ssl_sock_ctx reference into quic_conn
Amaury Denoyelle [Wed, 22 Dec 2021 17:20:38 +0000 (18:20 +0100)] 
MINOR: quic: store ssl_sock_ctx reference into quic_conn

Add a pointer in quic_conn to its related ssl_sock_ctx. This change is
required to avoid to use the connection instance to access it.

This commit is part of the rearchitecture of xprt-quic layers and the
separation between xprt and connection instances. It will be notably
useful when the connection allocation will be delayed.

3 years agoMINOR: quic: remove unnecessary call to free_quic_conn_cids()
Amaury Denoyelle [Thu, 23 Dec 2021 10:30:11 +0000 (11:30 +0100)] 
MINOR: quic: remove unnecessary call to free_quic_conn_cids()

free_quic_conn_cids() was called in quic_build_post_handshake_frames()
if an error occured. However, the only error is an allocation failure of
the CID which does not required to call it.

This change is required for future refcount implementation. The CID lock
will be removed from the free_quic_conn_cids() and to the caller.

3 years agoBUG/MINOR: quic: upgrade rdlock to wrlock for ODCID removal
Amaury Denoyelle [Wed, 22 Dec 2021 10:29:05 +0000 (11:29 +0100)] 
BUG/MINOR: quic: upgrade rdlock to wrlock for ODCID removal

When a quic_conn is found in the DCID tree, it can be removed from the
first ODCID tree. However, this operation must absolutely be run under a
write-lock to avoid race condition. To avoid to use the lock too
frequently, node.leaf_p is checked. This value is set to NULL after
ebmb_delete.

3 years agoREORG: quic: remove qc_ prefix on functions which not used it directly
Amaury Denoyelle [Thu, 23 Dec 2021 09:37:19 +0000 (10:37 +0100)] 
REORG: quic: remove qc_ prefix on functions which not used it directly

The qc_* prefix should be reserved to functions which used a specific
quic_conn instance and are expected to be pinned on the connection
thread.

3 years agoMINOR: quic: Add CONNECTION_CLOSE phrase to trace
Frédéric Lécaille [Thu, 23 Dec 2021 14:19:15 +0000 (15:19 +0100)] 
MINOR: quic: Add CONNECTION_CLOSE phrase to trace

Some applications may send some information about the reason why they decided
to close a connection. Add them to CONNECTION_CLOSE frame traces.
Take the opportunity of this patch to shorten some too long variable names
without any impact.

3 years agoMINOR: quic: Add traces for RX frames (flow control related)
Frédéric Lécaille [Thu, 23 Dec 2021 13:11:25 +0000 (14:11 +0100)] 
MINOR: quic: Add traces for RX frames (flow control related)

Add traces about important frame types to chunk_tx_frm_appendf()
and call this function for any type of frame when parsing a packet.
Move it to quic_frame.c

3 years agoDEBUG: ssl: make sure we never change a servername on established connections
Willy Tarreau [Thu, 23 Dec 2021 10:12:13 +0000 (11:12 +0100)] 
DEBUG: ssl: make sure we never change a servername on established connections

Since this case was already met previously with commit 655dec81b
("BUG/MINOR: backend: do not set sni on connection reuse"), let's make
sure that we don't change reused connection settings. This could be
generalized to most settings that are only in effect before the handshake
in fact (like set_alpn and a few other ones).

3 years agoMINOR: pools: work around possibly slow malloc_trim() during gc
Willy Tarreau [Thu, 23 Dec 2021 08:26:30 +0000 (09:26 +0100)] 
MINOR: pools: work around possibly slow malloc_trim() during gc

During 2.4-dev, support for malloc_trim() was implemented to ease
release of memory in a stopping process. This was found to be quite
effective and later backported to 2.3.7.

Then it was found that sometimes malloc_trim() could take a huge time
to complete it if was competing with other threads still allocating and
releasing memory, reason why it was decided in 2.5-dev to move
malloc_trim() under the thread isolation that was already in place in
the shared pool version of pool_gc() (this was commit 26ed1835).

However, other instances of pool_gc() that used to call malloc_trim()
were not updated since they were not using thread isolation. Currently
we have two other such instances, one for when there is absolutely no
pool and one for when there are only thread-local pools.

Christian Ruppert reported in GH issue #1490 that he's sometimes seeing
and old process die upon reload when upgrading from 2.3 to 2.4, and
that this happens inside malloc_trim(). The problem is that since
2.4-dev11 with commit 0bae07592 we detect modern libc that provide a
faster thread-aware allocator and do not maintain shared pools anymore.
As such we're using again the simpler pool_gc() implementations that do
not use thread isolation around the malloc_trim() call.

All this code was cleaned up recently and the call moved to a new
function trim_all_pools(). This patch implements explicit thread isolation
inside that function so that callers do not have to care about this
anymore. The thread isolation is conditional so that this doesn't affect
the one already in place in the larger version of pool_gc(). This way it
will solve the problem for all callers.

This patch must be backported as far as 2.3. It may possibly require
some adaptations. If trim_all_pools() is not present, copy-pasting the
tests in each version of pool_gc() will have the same effect.

Thanks to Christian for his detailed report and his testing.

3 years agoMINOR: quic: Drop asap Retry or Version Negotiation packets
Frédéric Lécaille [Wed, 22 Dec 2021 19:39:12 +0000 (20:39 +0100)] 
MINOR: quic: Drop asap Retry or Version Negotiation packets

These packet are only sent by servers. We drop them as soon as possible
when we are an haproxy listener.

3 years agoMINOR: quic: xprt traces fixes
Frédéric Lécaille [Wed, 22 Dec 2021 16:40:38 +0000 (17:40 +0100)] 
MINOR: quic: xprt traces fixes

Empty parameters are permitted with TRACE_*() macros. If removed, must
be replaced by NULL.

3 years agoMINOR: quic: Handle the cases of overlapping STREAM frames
Frédéric Lécaille [Wed, 22 Dec 2021 15:13:43 +0000 (16:13 +0100)] 
MINOR: quic: Handle the cases of overlapping STREAM frames

This is the same treatment for bidi and uni STREAM frames. This is a duplication
code which should me remove building a function for both these types of streams.

3 years agoMINOR: quic: Wrong dropped packet skipping
Frédéric Lécaille [Wed, 22 Dec 2021 09:17:01 +0000 (10:17 +0100)] 
MINOR: quic: Wrong dropped packet skipping

There were cases where some dropped packets were not well skipped. This led
the low level QUIC packet parser to continue from wrong packet boundaries.

3 years agoMINOR: quic: unchecked qc_retrieve_conn_from_cid() returned value
Frédéric Lécaille [Tue, 21 Dec 2021 13:48:58 +0000 (14:48 +0100)] 
MINOR: quic: unchecked qc_retrieve_conn_from_cid() returned value

If qc_retrieve_conn_from_cid() did not manage to retrieve the connection
from packet CIDs, we must drop them.

3 years agoMINOR: quic: Add stream IDs to qcs_push_frame() traces
Frédéric Lécaille [Tue, 21 Dec 2021 10:53:33 +0000 (11:53 +0100)] 
MINOR: quic: Add stream IDs to qcs_push_frame() traces

This is only for debug purpose.

3 years agoMINOR: quic: add quic_conn instance in traces for qc_new_conn
Amaury Denoyelle [Tue, 21 Dec 2021 13:51:56 +0000 (14:51 +0100)] 
MINOR: quic: add quic_conn instance in traces for qc_new_conn

The connection instance has been replaced by a quic_conn as first
argument to QUIC traces. It is possible to report the quic_conn instance
in the qc_new_conn(), contrary to the connection which is not
initialized at this stage.

3 years agoMINOR: quic: use quic_conn as argument to traces
Amaury Denoyelle [Tue, 21 Dec 2021 13:29:15 +0000 (14:29 +0100)] 
MINOR: quic: use quic_conn as argument to traces

Replace the connection instance for first argument of trace callback by
a quic_conn instance. The QUIC trace module is properly initialized with
the first argument refering to a quic_conn.

Replace every connection instances in TRACE_* macros invocation in
xprt-quic by its related quic_conn. In some case, the connection is
still used to access the quic_conn. It may cause some problem on the
future when the connection will be completly separated from the xprt
layer.

This commit is part of the rearchitecture of xprt-quic layers and the
separation between xprt and connection instances.

3 years agoMINOR: trace: add quic_conn argument definition
Amaury Denoyelle [Tue, 21 Dec 2021 10:26:02 +0000 (11:26 +0100)] 
MINOR: trace: add quic_conn argument definition

Prepare trace support for quic_conn instances as argument. This will be
used by the xprt-quic layer in replacement of the connection.

This commit is part of the rearchitecture of xprt-quic layers and the
separation between xprt and connection instances.

3 years agoMINOR: quic: add const qualifier for traces function
Amaury Denoyelle [Tue, 21 Dec 2021 13:28:26 +0000 (14:28 +0100)] 
MINOR: quic: add const qualifier for traces function

Add const qualifier on arguments of several dump functions used in the
trace callback. This is required to be able to replace the first trace
argument by a quic_conn instance. The first argument is a const pointer
and so the members accessed through it must also be const.

3 years agoMINOR: quic: add reference to quic_conn in ssl context
Amaury Denoyelle [Tue, 21 Dec 2021 10:41:52 +0000 (11:41 +0100)] 
MINOR: quic: add reference to quic_conn in ssl context

Add a new member in ssl_sock_ctx structure to reference the quic_conn
instance if used in the QUIC stack. This member is initialized during
qc_conn_init().

This is needed to be able to access to the quic_conn without relying on
the connection instance. This commit is part of the rearchitecture of
xprt-quic layers and the separation between xprt and connection
instances.

3 years agoREORG: quic: move mux function outside of xprt
Amaury Denoyelle [Tue, 21 Dec 2021 10:53:10 +0000 (11:53 +0100)] 
REORG: quic: move mux function outside of xprt

Move qcc_get_qcs() function from xprt_quic.c to mux_quic.c. This
function is used to retrieve the qcs instance from a qcc with a stream
id. This clearly belongs to the mux-quic layer.

3 years agoCLEANUP: quic: rename quic_conn instances to qc
Amaury Denoyelle [Tue, 21 Dec 2021 13:45:39 +0000 (14:45 +0100)] 
CLEANUP: quic: rename quic_conn instances to qc

Use the convention of naming quic_conn instance as qc to not confuse it
with a connection instance. The changes occured for qc_parse_pkt_frms(),
qc_build_frms() and qc_do_build_pkt().

3 years agoDOC: fix misspelled keyword "resolve_retries" in resolvers
Thierry Fournier [Wed, 15 Dec 2021 18:03:52 +0000 (19:03 +0100)] 
DOC: fix misspelled keyword "resolve_retries" in resolvers

"resolve_retries" was spelled "resolve_retires".

3 years agoMINOR: quic: Wrong packet refcount handling in qc_pkt_insert()
Frédéric Lécaille [Mon, 20 Dec 2021 13:41:19 +0000 (14:41 +0100)] 
MINOR: quic: Wrong packet refcount handling in qc_pkt_insert()

The QUIC connection I/O handler qc_conn_io_cb() could be called just after
qc_pkt_insert() have inserted a packet in a its tree, and before qc_pkt_insert()
have incremented the reference counter to this packet. As qc_conn_io_cb()
decrement this counter, the packet could be released before qc_pkt_insert()
might increment the counter, leading to possible crashes when trying to do so.
So, let's make qc_pkt_insert() increment this counter before inserting the packet
it is tree. No need to lock anything for that.

3 years agoMINOR: quic: Do not forget STREAM frames received in disorder
Frédéric Lécaille [Mon, 20 Dec 2021 11:02:13 +0000 (12:02 +0100)] 
MINOR: quic: Do not forget STREAM frames received in disorder

Add a function to process all STREAM frames received and ordered
by their offset (qc_treat_rx_strm_frms()) and modify
qc_handle_bidi_strm_frm() consequently.

3 years agoMINOR: quic: Do not expect to receive only one O-RTT packet
Frédéric Lécaille [Fri, 17 Dec 2021 17:24:16 +0000 (18:24 +0100)] 
MINOR: quic: Do not expect to receive only one O-RTT packet

There is nothing about this in the RFC. We must support to receive
several 0-RTT packets before the handshake has completed.

3 years agoMINOR: quic: Stop emptying the RX buffer asap.
Frédéric Lécaille [Mon, 20 Dec 2021 16:12:42 +0000 (17:12 +0100)] 
MINOR: quic: Stop emptying the RX buffer asap.

When a packet is present in the RX buffer at the first place
but without a null reference counter, there is no need to continue
to try to empty the buffer, it is sure the next packet will not
be at the first place!

3 years agoMINOR: quic: Add a function to list remaining RX packets by encryption level
Frédéric Lécaille [Fri, 17 Dec 2021 15:11:54 +0000 (16:11 +0100)] 
MINOR: quic: Add a function to list remaining RX packets by encryption level

This is only to debug some issues which cause the RX buffer saturation
with "Too big packet" traces.

3 years agoMINOR: quic: Increase the RX buffer for each connection
Frédéric Lécaille [Fri, 17 Dec 2021 13:11:00 +0000 (14:11 +0100)] 
MINOR: quic: Increase the RX buffer for each connection

Double this buffer size which reaches 16ko for now on.

3 years agoMINOR: ssl: Remove empty lines from "show ssl ocsp-response" output
Remi Tricot-Le Breton [Fri, 17 Dec 2021 17:53:23 +0000 (18:53 +0100)] 
MINOR: ssl: Remove empty lines from "show ssl ocsp-response" output

There were empty lines in the output of the CLI's "show ssl
ocsp-response" command (after the certificate ID and between two
certificates). This patch removes them since an empty line should mark
the end of the output.

Must be backported in 2.5.

3 years agoREGTESTS: vars: Remove useless ssl tunes from conditional set-var test
Remi Tricot-Le Breton [Mon, 20 Dec 2021 09:52:58 +0000 (10:52 +0100)] 
REGTESTS: vars: Remove useless ssl tunes from conditional set-var test

The global section of the cond_set_var.vtc test used some useless SSL
tunes which made the test fail on builds without SSL.

3 years agoMINOR: quic: simplify the removal from ODCID tree
Amaury Denoyelle [Thu, 16 Dec 2021 15:15:18 +0000 (16:15 +0100)] 
MINOR: quic: simplify the removal from ODCID tree

With the DCID refactoring, the locking is more centralized. It is
possible to simplify the code for removal of a quic_conn from the ODCID
tree.

This operation can be conducted as soon as the connection has been
retrieved from the DCID tree, meaning that the peer now uses the final
DCID. Remove the bit to flag a connection for removal and just uses
ebmb_delete() on each sucessful lookup on the DCID tree. If the
quic_conn has already been removed, it is just a noop thanks to
eb_delete() implementation.

3 years agoMINOR: quic: refactor DCID lookup
Amaury Denoyelle [Wed, 15 Dec 2021 15:32:56 +0000 (16:32 +0100)] 
MINOR: quic: refactor DCID lookup

A new function named qc_retrieve_conn_from_cid() now contains all the
code to retrieve a connection from a DCID. It handle all type of packets
and centralize the locking on the ODCID/DCID trees.

This simplify the qc_lstnr_pkt_rcv() function.

3 years agoMINOR: quic: compare coalesced packets by DCID
Amaury Denoyelle [Tue, 14 Dec 2021 14:04:14 +0000 (15:04 +0100)] 
MINOR: quic: compare coalesced packets by DCID

If an UDP datagram contains multiple QUIC packets, they must all use the
same DCID. The datagram context is used partly for this.

To ensure this, a comparison was made on the dcid_node of DCID tree. As
this is a comparison based on pointer address, it can be faulty when
nodes are removed/readded on the same pointer address.

Replace this comparison by a proper comparison on the DCID data itself.
To this end, the dgram_ctx structure contains now a quic_cid member.

3 years agoMINOR: quic: refactor concat DCID with address for Initial packets
Amaury Denoyelle [Tue, 14 Dec 2021 16:20:59 +0000 (17:20 +0100)] 
MINOR: quic: refactor concat DCID with address for Initial packets

For first Initial packets, the socket source dest address is
concatenated to the DCID. This is used to be able to differentiate
possible collision between several clients which used the same ODCID.

Refactor the code to manage DCID and the concatenation with the address.
Before this, the concatenation was done on the quic_cid struct and its
<len> field incremented. In the code it is difficult to differentiate a
normal DCID with a DCID + address concatenated.

A new field <addrlen> has been added in the quic_cid struct. The <len>
field now only contains the size of the QUIC DCID. the <addrlen> is
first initialized to 0. If the address is concatenated, it will be
updated with the size of the concatenated address. This now means we
have to explicitely used either cid.len or cid.len + cid.addrlen to
access the DCID or the DCID + the address. The code should be clearer
thanks to this.

The field <odcid_len> in quic_rx_packet struct is now useless and has
been removed. However, a new parameter must be added to the
qc_new_conn() function to specify the size of the ODCID addrlen.

3 years agoMINOR: quic: rename constant for haproxy CIDs length
Amaury Denoyelle [Tue, 14 Dec 2021 16:17:28 +0000 (17:17 +0100)] 
MINOR: quic: rename constant for haproxy CIDs length

On haproxy implementation, generated DCID are on 8 bytes, the minimal
value allowed by the specification. Rename the constant representing
this size to inform that this is haproxy specific.

3 years agoMINOR: quic: add missing lock on cid tree
Amaury Denoyelle [Mon, 13 Dec 2021 16:07:55 +0000 (17:07 +0100)] 
MINOR: quic: add missing lock on cid tree

All operation on the ODCID/DCID trees must be conducted under a
read-write lock. Add a missing read-lock on the lookup operation inside
listener handler.

3 years agoCLEANUP: quic: rename quic_conn conn to qc in quic_conn_free
Amaury Denoyelle [Mon, 13 Dec 2021 16:07:03 +0000 (17:07 +0100)] 
CLEANUP: quic: rename quic_conn conn to qc in quic_conn_free

Rename quic_conn from conn to qc to differentiate it from a struct
connection instance. This convention is already used in the majority of
the code.

3 years agoCLEANUP: quic: fix spelling mistake in a trace
Amaury Denoyelle [Fri, 17 Dec 2021 09:58:05 +0000 (10:58 +0100)] 
CLEANUP: quic: fix spelling mistake in a trace

Initiial -> Initial

3 years agoMINOR: mux-quic: fix trace on stream creation
Amaury Denoyelle [Thu, 16 Dec 2021 14:22:30 +0000 (15:22 +0100)] 
MINOR: mux-quic: fix trace on stream creation

Replace non-initialized qcs.by_id.key by the id to report the proper
stream ID on stream creation.

3 years agoCLEANUP: quic: Shorten a litte bit the traces in lstnr_rcv_pkt()
Frédéric Lécaille [Thu, 16 Dec 2021 17:03:52 +0000 (18:03 +0100)] 
CLEANUP: quic: Shorten a litte bit the traces in lstnr_rcv_pkt()

Some traces were too long and confusing when displaying 0 for a non-already
parsed packet number.

3 years agoMINOR: quic: Do not mix packet number space and connection flags
Frédéric Lécaille [Thu, 16 Dec 2021 10:21:52 +0000 (11:21 +0100)] 
MINOR: quic: Do not mix packet number space and connection flags

The packet number space flags were mixed with the connection level flags.
This leaded to ACK to be sent at the connection level without regard to
the underlying packet number space. But we want to be able to acknowleged
packets for a specific packet number space.

3 years agoMINOR: hq_interop: Stop BUG_ON() truncated streams
Frédéric Lécaille [Wed, 15 Dec 2021 21:38:48 +0000 (22:38 +0100)] 
MINOR: hq_interop: Stop BUG_ON() truncated streams

This is required if we do not want to make haproxy crash during zerortt
interop runner test which makes a client open multiple streams with
long request paths.

3 years agoCLEANUP: quic: Comment fix for qc_strm_cpy()
Frédéric Lécaille [Wed, 15 Dec 2021 14:32:55 +0000 (15:32 +0100)] 
CLEANUP: quic: Comment fix for qc_strm_cpy()

This function never returns a negative value... hopefully because it returns
a size_t!!!

3 years agoMINOR: qpack: Missing check for truncated QPACK fields
Frédéric Lécaille [Wed, 15 Dec 2021 13:16:16 +0000 (14:16 +0100)] 
MINOR: qpack: Missing check for truncated QPACK fields

Decrementing <len> variable without checking could make haproxy crash (on abort)
when printing a huge buffer (with negative length).

3 years agoMINOR: quic: Make xprt support 0-RTT.
Frédéric Lécaille [Tue, 14 Dec 2021 18:44:14 +0000 (19:44 +0100)] 
MINOR: quic: Make xprt support 0-RTT.

A client sends a 0-RTT data packet after an Initial one in the same datagram.
We must be able to parse such packets just after having parsed the Initial packets.

3 years agoMINOR: ssl_sock: Set the QUIC application from ssl_sock_advertise_alpn_protos.
Frédéric Lécaille [Tue, 14 Dec 2021 18:40:04 +0000 (19:40 +0100)] 
MINOR: ssl_sock: Set the QUIC application from ssl_sock_advertise_alpn_protos.

Make this function call quic_set_app_ops() if the protocol could be negotiated
by the TLS stack.

3 years agoMINOR: quic: Add quic_set_app_ops() function
Frédéric Lécaille [Tue, 14 Dec 2021 18:34:08 +0000 (19:34 +0100)] 
MINOR: quic: Add quic_set_app_ops() function

Export the code responsible which set the ->app_ops structure into
quic_set_app_ops() function. It must be called by  the TLS callback which
selects the application (ssl_sock_advertise_alpn_protos) so that
to be able to build application packets after having received 0-RTT data.

3 years agoMINOR: quic: No TX secret at EARLY_DATA encryption level
Frédéric Lécaille [Tue, 14 Dec 2021 18:29:34 +0000 (19:29 +0100)] 
MINOR: quic: No TX secret at EARLY_DATA encryption level

The TLS does not provide us with TX secrets after we have provided it
with 0-RTT data. This is logic: the server does not need to send 0-RTT
data. We must skip the section where such secrets are derived if we do not
want to close the connection with a TLS alert.

3 years agoMINOR: quic: Enable TLS 0-RTT if needed
Frédéric Lécaille [Tue, 14 Dec 2021 18:23:43 +0000 (19:23 +0100)] 
MINOR: quic: Enable TLS 0-RTT if needed

Enable 0-RTT at the TLS context level:
    RFC 9001 4.6.1. Enabling 0-RTT
    Accordingly, the max_early_data_size parameter is repurposed to hold a
    sentinel value 0xffffffff to indicate that the server is willing to accept
    QUIC 0-RTT data.
At the SSL connection level, we must call SSL_set_quic_early_data_enabled().

3 years agoCLEANUP: quic: Remove cdata_len from quic_tx_packet struct
Frédéric Lécaille [Mon, 13 Dec 2021 11:30:54 +0000 (12:30 +0100)] 
CLEANUP: quic: Remove cdata_len from quic_tx_packet struct

This field is no more useful. Modify the traces consequently.
Also initialize ->pn_node.key value to -1, which is an illegal value
for QUIC packet number, and display it in traces if different from -1.

3 years agoMINOR: quic: Add traces for STOP_SENDING frame and modify others
Frédéric Lécaille [Fri, 10 Dec 2021 14:18:36 +0000 (15:18 +0100)] 
MINOR: quic: Add traces for STOP_SENDING frame and modify others

If not handled by qc_parse_pkt_frms(), the packet which contains it is dropped.
Add only a trace when parsing this frame at this time.
Also modify others to reduce the traces size and have more information about streams.

3 years agoCLEANUP: quic_frame: Remove a useless suffix to STOP_SENDING
Frédéric Lécaille [Fri, 10 Dec 2021 13:42:02 +0000 (14:42 +0100)] 
CLEANUP: quic_frame: Remove a useless suffix to STOP_SENDING

This is to be consistent with the other frame names. Adding a _frame
suffixe to STOP_SENDING is useless. We know this is a frame.

3 years agoMINOR: quic: Attach timer task to thread for the connection.
Frédéric Lécaille [Thu, 9 Dec 2021 09:06:21 +0000 (10:06 +0100)] 
MINOR: quic: Attach timer task to thread for the connection.

This is to avoid races between the connection I/O handler and this task
which share too much variables.

3 years agoREGTESTS: vars: Add new test for conditional set-var
Remi Tricot-Le Breton [Thu, 16 Dec 2021 16:14:41 +0000 (17:14 +0100)] 
REGTESTS: vars: Add new test for conditional set-var

This regtest uses the newly created conditions that can be added to
set-var converters or actions.

3 years agoDOC: vars: Add documentation about the set-var conditions
Remi Tricot-Le Breton [Thu, 16 Dec 2021 16:14:40 +0000 (17:14 +0100)] 
DOC: vars: Add documentation about the set-var conditions

The set-var converter as well as the http and tcp set-var actions can
now be given multiple conditions that need to all be true for the
variable's contents to actually be changed. Those conditions can concern
the variable as well as the input contents and can also work by
comparing the variable and the input values.

3 years agoMEDIUM: vars: Enable optional conditions to set-var converter and actions
Remi Tricot-Le Breton [Thu, 16 Dec 2021 16:14:39 +0000 (17:14 +0100)] 
MEDIUM: vars: Enable optional conditions to set-var converter and actions

This patch adds the possibility to add a set of conditions to a set-var
call, be it a converter or an action (http-request or http-response
action for instance). The conditions must all be true for the given
set-var call for the variable to actually be set. If any of the
conditions is false, the variable is left untouched.
The managed conditions are the following : "ifexists", "ifnotexists",
"ifempty", "ifnotempty", "ifset", "ifnotset", "ifgt", "iflt".  It is
possible to combine multiple conditions in a single set-var call since
some of them apply to the variable itself, and some others to the input.

This patch does not change the fact that variables of scope proc are
still created during configuration parsing, regardless of the conditions
that might be added to the set-var calls in which they are mentioned.
For instance, such a line :
    http-request set-var(proc.foo,ifexists) int(5)
would not prevent the creation of the variable during init, and when
actually reaching this line during runtime, the proc.foo variable would
already exist. This is specific to the proc scope.

These new conditions mean that a set-var could "fail" for other reasons
than memory allocation failures but without clearing the contents of the
variable.

3 years agoMINOR: vars: Parse optional conditions passed to the set-var actions
Remi Tricot-Le Breton [Thu, 16 Dec 2021 16:14:38 +0000 (17:14 +0100)] 
MINOR: vars: Parse optional conditions passed to the set-var actions

This patch adds the parsing of the optional condition parameters that
can be passed to the set-var and set-var-fmt actions (http as well as
tcp). Those conditions will not be taken into account yet in the var_set
function so conditions passed as parameters will not have any effect.
Since actions do not benefit from the parameter preparsing that
converters have, parsing conditions needed to be done by hand.

3 years agoMINOR: vars: Parse optional conditions passed to the set-var converter
Remi Tricot-Le Breton [Thu, 16 Dec 2021 16:14:37 +0000 (17:14 +0100)] 
MINOR: vars: Parse optional conditions passed to the set-var converter

This patch adds the parsing of the optional condition parameters that
can be passed to the set-var converter. Those conditions will not be
taken into account yet in the var_set function so conditions passed as
parameters will not have any effect. This is true for any condition
apart from the "ifexists" one that is also used to replace the
VF_UPDATEONLY flag that was used to prevent proc scope variable creation
from a LUA module.

3 years agoMINOR: vars: Delay variable content freeing in var_set function
Remi Tricot-Le Breton [Thu, 16 Dec 2021 16:14:36 +0000 (17:14 +0100)] 
MINOR: vars: Delay variable content freeing in var_set function

When calling var_set on a variable of type string (SMP_T_STR, SMP_T_BIN
or SMP_T_METH), the contents of the variable were freed directly. When
adding conditions to set-var calls we might have cases in which the
contents of an existing variable should be kept unchanged so the freeing
of the internal buffers is delayed in the var_set function (so that we
can bypass it later).

3 years agoMINOR: vars: Set variable type to ANY upon creation
Remi Tricot-Le Breton [Thu, 16 Dec 2021 16:14:35 +0000 (17:14 +0100)] 
MINOR: vars: Set variable type to ANY upon creation

The type of a newly created variable was not initialized. This patch
sets it to SMP_T_ANY by default. This will be required when conditions
can be added to a set-var call because we might end up creating a
variable without setting it yet.

3 years agoMINOR: vars: Move UPDATEONLY flag test to vars_set_ifexist
Remi Tricot-Le Breton [Thu, 16 Dec 2021 16:14:34 +0000 (17:14 +0100)] 
MINOR: vars: Move UPDATEONLY flag test to vars_set_ifexist

The vars_set_by_name_ifexist function was created to avoid creating too
many variables from a LUA module. This was made thanks to the
VF_UPDATEONLY flags which prevented variable creation in the var_set
function. Since commit 3a4bedccc ("MEDIUM: vars: replace the global name
index with a hash") this limitation was restricted to 'proc' scope
variables only.
This patch simply moves the scope test to the vars_set_by_name_ifexist
function instead of the var_set function.

3 years agoBUILD: ssl: unbreak the build with newer libressl
Daniel Jakots [Wed, 8 Dec 2021 01:34:39 +0000 (20:34 -0500)] 
BUILD: ssl: unbreak the build with newer libressl

In LibreSSL 3.5.0, BIO is going to become opaque, so haproxy's
compat macros will no longer work. The functions they substitute
have been available since LibreSSL 2.7.0.

3 years agoMEDIUM: cfgparse: numa detect topology on FreeBSD.
David CARLIER [Mon, 6 Dec 2021 11:00:10 +0000 (11:00 +0000)] 
MEDIUM: cfgparse: numa detect topology on FreeBSD.

allowing for all platforms supporting cpu affinity to have a chance
 to detect the cpu topology from a given valid node (e.g.
 DragonflyBSD seems to be NUMA aware from a kernel's perspective
 and seems to be willing start to provide userland means to get
 proper info).

3 years agoCLEANUP: cfgparse: modify preprocessor guards around numa detection code
Amaury Denoyelle [Wed, 15 Dec 2021 08:48:39 +0000 (09:48 +0100)] 
CLEANUP: cfgparse: modify preprocessor guards around numa detection code

numa_detect_topology() is always define now if USE_CPU_AFFINITY is
activated. For the moment, only on Linux an actual implementation is
provided. For other platforms, it always return 0.

This change has been made to easily add implementation of NUMA detection
for other platforms. The phrasing of the documentation has also been
edited to removed the mention of Linux-only on numa-cpu-mapping
configuration option.

3 years agoMINOR: cli: "show version" displays the current process version
William Lallemand [Tue, 14 Dec 2021 14:22:29 +0000 (15:22 +0100)] 
MINOR: cli: "show version" displays the current process version

This patch implements a simple "show version" command which returns
the version of the current process.

It's available from the master and the worker processes, so it is easy
to check if the master and the workers have the same version.

This is a minor patch that really improve compatibility checks
for scripts.

Could be backported in haproxy version as far as 2.0.

3 years agoREGTESTS: ssl: use X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY for cert check
Ilya Shipitsin [Sat, 4 Dec 2021 09:32:23 +0000 (14:32 +0500)] 
REGTESTS: ssl: use X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY for cert check

LibreSSL-3.4.2 introduced cert revocation check behaviour change, for some
checks now X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY (20) is returned.

https://github.com/libressl-portable/portable/issues/697

let us modify vtc accordingly

3 years agoMINOR: hq-interop: refix tx buffering
Amaury Denoyelle [Thu, 9 Dec 2021 09:07:23 +0000 (10:07 +0100)] 
MINOR: hq-interop: refix tx buffering

Incorrect usage of the buffer API : b_room() replaces b_size() to ensure
that we have enough size for http data copy.

3 years agoBUG/MEDIUM: mworker/cli: crash when trying to access an old PID in prompt mode
William Lallemand [Fri, 10 Dec 2021 13:14:53 +0000 (14:14 +0100)] 
BUG/MEDIUM: mworker/cli: crash when trying to access an old PID in prompt mode

The master process encounter a crash when trying to access an old
process which left from the master CLI.

To reproduce the problem, you need a prompt to a previous worker, then
wait for this worker to leave, once it left launch a command from this
prompt. The s->target is then filled with a NULL which is dereferenced
when trying to connect().

This patch fixes the problem by checking if s->target is NULL.

Must be backported as far as 2.0.

3 years agoDOC: config: fix error-log-format example
Lukas Tribus [Thu, 9 Dec 2021 00:27:14 +0000 (01:27 +0100)] 
DOC: config: fix error-log-format example

In commit 6f7497616 ("MEDIUM: connection: rename fc_conn_err and
bc_conn_err to fc_err and bc_err"), fc_conn_err became fc_err, so
update this example.

3 years agoDOC: config: retry-on list is space-delimited
Lukas Tribus [Wed, 8 Dec 2021 10:33:01 +0000 (11:33 +0100)] 
DOC: config: retry-on list is space-delimited

We are using comma-delimited list for init-addr for example, let's
document that this is space-delimited to avoid the guessing game.

3 years agoMINOR: h3: fix possible invalid dereference on htx parsing
Amaury Denoyelle [Wed, 8 Dec 2021 14:51:04 +0000 (15:51 +0100)] 
MINOR: h3: fix possible invalid dereference on htx parsing

The htx variable is only initialized if we have received a HTTP/3
HEADERS frame. Else it must not be dereferenced.

This should fix the compilation on CI with gcc.
  src/h3.c: In function ‘h3_decode_qcs’:
  src/h3.c:224:14: error: ‘htx’ may be used uninitialized in this function
  [-Werror=maybe-uninitialized]
    224 |   htx->flags |= HTX_FL_EOM

3 years agoMINOR: quic: Compilation fix for quic_rx_packet_refinc()
Frédéric Lécaille [Wed, 8 Dec 2021 14:24:15 +0000 (15:24 +0100)] 
MINOR: quic: Compilation fix for quic_rx_packet_refinc()

This was reported by the CI wich clang as compilator.

    In file included from src/ssl_sock.c:80:
    include/haproxy/xprt_quic.h:1100:50: error: passing 'int *' to parameter of
    type 'unsigned int *' converts between pointers to integer types with
    different sign [-Werror,-Wpointer-sign]
        } while (refcnt && !HA_ATOMIC_CAS(&pkt->refcnt, &refcnt, refcnt - 1));
                                                        ^~~~~~~

3 years agoBUG/MINOR: mux-quic: properly initialize flow control
Amaury Denoyelle [Wed, 8 Dec 2021 14:12:01 +0000 (15:12 +0100)] 
BUG/MINOR: mux-quic: properly initialize flow control

Initialize all flow control members on the qcc instance. Without this,
the value are undefined and it may be possible to have errors about
reached streams limit.

3 years agoMINOR: quic: notify the mux on CONNECTION_CLOSE
Amaury Denoyelle [Wed, 8 Dec 2021 13:51:04 +0000 (14:51 +0100)] 
MINOR: quic: notify the mux on CONNECTION_CLOSE

The xprt layer is reponsible to notify the mux of a CONNECTION_CLOSE
reception. In this case the flag QC_CF_CC_RECV is positionned on the
qcc and the mux tasklet is waken up.

One of the notable effect of the QC_CF_CC_RECV is that each qcs will be
released even if they have remaining data in their send buffers.

3 years agoMINOR: mux-quic: do not release qcs if there is remaining data to send
Amaury Denoyelle [Wed, 8 Dec 2021 13:42:55 +0000 (14:42 +0100)] 
MINOR: mux-quic: do not release qcs if there is remaining data to send

A qcs is not freed if there is remaining data in its buffer. In this
case, the flag QC_SF_DETACH is positionned.

The qcc io handler is responsible to remove the qcs if the QC_SF_DETACH
is set and their buffers are empty.

3 years agoBUG/MINOR: cli/server: Don't crash when a server is added with a custom id
Christopher Faulet [Tue, 7 Dec 2021 17:49:44 +0000 (18:49 +0100)] 
BUG/MINOR: cli/server: Don't crash when a server is added with a custom id

When a server is dynamically added via the CLI with a custom id, the key
used to insert it in the backend's tree of used names is not initialized.
The server id must be used but it is only used when no custom id is
provided. Thus, with a custom id, HAProxy crashes.

Now, the server id is always used to init this key, to be able to insert the
server in the corresponding tree.

This patch should fix the issue #1481. It must be backported as far as 2.4.

3 years agoMINOR: http-rules: Add capture action to http-after-response ruleset
Christopher Faulet [Mon, 6 Dec 2021 07:43:22 +0000 (08:43 +0100)] 
MINOR: http-rules: Add capture action to http-after-response ruleset

It is now possible to perform captures on the response when
http-after-response rules are evaluated. It may be handy to capture headers
from responses generated by HAProxy.

This patch is trivial, it may be backported if necessary.

3 years agoBUILD: mux-quic: fix compilation with DEBUG_MEM_STATS
Amaury Denoyelle [Tue, 7 Dec 2021 16:27:47 +0000 (17:27 +0100)] 
BUILD: mux-quic: fix compilation with DEBUG_MEM_STATS

Replace bug.h by api.h in mux_quic header.
This is required because bug.h uses atomic operations when compiled with
DEBUG_MEM_STATS. api.h takes care of including atomic.h before bug.h.

3 years agoMINOR: quic: add HTX EOM on request end
Amaury Denoyelle [Tue, 30 Nov 2021 10:23:29 +0000 (11:23 +0100)] 
MINOR: quic: add HTX EOM on request end

Set the HTX EOM flag on RX the app layer. This is required to notify
about the end of the request for the stream analyzers, else the request
channel never goes to MSG_DONE state.

3 years agoMINOR: mux-quic: remove uneeded code to check fin on TX
Amaury Denoyelle [Tue, 7 Dec 2021 15:50:14 +0000 (16:50 +0100)] 
MINOR: mux-quic: remove uneeded code to check fin on TX

Remove a wrong comparaison with the same buffer on both sides. In any
cases, the FIN is properly set by qcs_push_frame only when the payload
has been totally emptied.

3 years agoMINOR: hq-interop: fix tx buffering
Amaury Denoyelle [Tue, 7 Dec 2021 15:19:03 +0000 (16:19 +0100)] 
MINOR: hq-interop: fix tx buffering

On h09 app layer, if there is not enought size in the tx buffer, the
transfer is interrupted and the flag QC_SF_BLK_MROOM is positionned.
The transfer is woken up by the mux when new buffer size becomes
available.

This ensure that no data is silently discarded during transfer. Without
this, once the buffer is full the data were removed and thus not send to
the client resulting in a truncating payload.

3 years agoMINOR: quic: Remove QUIC TX packet length evaluation function
Frédéric Lécaille [Tue, 7 Dec 2021 14:27:44 +0000 (15:27 +0100)] 
MINOR: quic: Remove QUIC TX packet length evaluation function

Remove qc_eval_pkt() which has come with the multithreading support. It
was there to evaluate the length of a TX packet before building. We could
build from several thread TX packets without consuming a packet number for nothing (when
the building failed). But as the TX packet building functions are always
executed by the same thread, the one attached to the connection, this does
not make sense to continue to use such a function. Furthermore it is buggy
since we had to recently pad the TX packet under certain circumstances.

3 years agoMINOR: quic: Delete remaining RX handshake packets
Frédéric Lécaille [Mon, 6 Dec 2021 11:09:08 +0000 (12:09 +0100)] 
MINOR: quic: Delete remaining RX handshake packets

After the handshake has succeeded, we must delete any remaining
Initial or Handshake packets from the RX buffer. This cannot be
done depending on the state the connection (->st quic_conn struct
member value) as the packet are not received/treated in order.

3 years agoMINOR: quic: QUIC encryption level RX packets race issue
Frédéric Lécaille [Mon, 6 Dec 2021 07:56:38 +0000 (08:56 +0100)] 
MINOR: quic: QUIC encryption level RX packets race issue

The tree containing RX packets must be protected from concurrent accesses.

3 years agoMINOR: quic: Race issue when consuming RX packets buffer
Frédéric Lécaille [Thu, 2 Dec 2021 13:46:19 +0000 (14:46 +0100)] 
MINOR: quic: Race issue when consuming RX packets buffer

Add a null byte to the end of the RX buffer to notify the consumer there is no
more data to treat.
Modify quic_rx_packet_pool_purge() which is the function which remove the
RX packet from the buffer.
Also rename this function to quic_rx_pkts_del().
As the RX packets may be accessed by the QUIC connection handler (quic_conn_io_cb())
the function responsible of decrementing their reference counters must not
access other information than these reference counters! It was a very bad idea
to try to purge the RX buffer asap when executing this function.

3 years agoMINOR: quic: RX buffer full due to wrong CRYPTO data handling
Frédéric Lécaille [Thu, 2 Dec 2021 10:25:58 +0000 (11:25 +0100)] 
MINOR: quic: RX buffer full due to wrong CRYPTO data handling

Do not leave in the RX buffer packets with CRYPTO data which were
already received. We do this when parsing CRYPTO frame. If already
received we must not consider such frames as if they were not received
in order! This had as side effect to interrupt the transfer of long streams
(ACK frames not parsed).