]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
3 years agoMINOR: quic: Make use of the last cbuf API when initializing TX ring buffers
Frédéric Lécaille [Wed, 4 Aug 2021 13:10:32 +0000 (15:10 +0200)] 
MINOR: quic: Make use of the last cbuf API when initializing TX ring buffers

Initialize the circular buffer internal buffer from a specific pool for TX ring
buffers named "pool_head_quic_tx_ring".

3 years agoMINOR: quic: Add a pool for TX ring buffer internal buffer
Frédéric Lécaille [Wed, 4 Aug 2021 13:27:37 +0000 (15:27 +0200)] 
MINOR: quic: Add a pool for TX ring buffer internal buffer

We want to allocate the internal buffer of TX ring buffer from a pool.
This patch add "quic_tx_ring_pool" to do so.

3 years agoMINOR: quic: Make circular buffer internal buffers be variable-sized.
Frédéric Lécaille [Wed, 4 Aug 2021 12:53:06 +0000 (14:53 +0200)] 
MINOR: quic: Make circular buffer internal buffers be variable-sized.

For now on thanks to this simple patch we can use circular buffers with
a variable-sized internal buffer.

3 years agoMINOR: quic: Rename functions which do not build only Handshake packets
Frédéric Lécaille [Wed, 4 Aug 2021 08:49:51 +0000 (10:49 +0200)] 
MINOR: quic: Rename functions which do not build only Handshake packets

Rename qc_build_hdshk_pkt() to qc_build_pkt() and qc_do_build_hdshk_pkt()
to qc_do_build_pkt().
Update their comments consequently.
Make qc_do_build_hdshk_pkt() BUG_ON() when it does not manage to build
a packet. This is a bug!

3 years agoMINOR: quic: Remove Application level related functions
Frédéric Lécaille [Tue, 3 Aug 2021 15:07:23 +0000 (17:07 +0200)] 
MINOR: quic: Remove Application level related functions

Remove the functions which were specific to the Application level.
This is the same function which build any packet for any encryption
level: quic_prep_hdshk_pkts() directly called from the quic_conn_io_cb().

3 years agoMINOR: quic: qc_do_build_hdshk_pkt() does not need to pass a copy of CRYPTO frame
Frédéric Lécaille [Tue, 3 Aug 2021 15:01:25 +0000 (17:01 +0200)] 
MINOR: quic: qc_do_build_hdshk_pkt() does not  need to pass a copy of CRYPTO frame

There is no need to pass a copy of CRYPTO frames to qc_build_frm() from
qc_do_build_hdshk_pkt(). Furthermore, after the previous modifications,
qc_do_build_hdshk_pkt() do not build only CRYPTO frame from ->pktns.tx.frms
MT_LIST but any type of frame.

3 years agoMINOR: quic: Make qc_build_hdshk_pkt() atomically consume a packet number
Frédéric Lécaille [Tue, 3 Aug 2021 14:50:14 +0000 (16:50 +0200)] 
MINOR: quic: Make qc_build_hdshk_pkt() atomically consume a packet number

Atomically increase the "next packet variable" before building a new packet.
Make the code bug on a packet building failure. This should never happen
if we do not want to consume a packet number for nothing. There are remaining
modifications to come to ensure this is the case.

3 years agoMINOR: quic: quic_conn_io_cb() task rework
Frédéric Lécaille [Tue, 3 Aug 2021 14:45:39 +0000 (16:45 +0200)] 
MINOR: quic: quic_conn_io_cb() task rework

Modify this task which is called at least each a packet is received by a listener
so that to make it behave almost as qc_do_hdshk(). This latter is no more useful
and removed.

3 years agoMINOR: quic: Modify qc_build_cfrms() to support any frame
Frédéric Lécaille [Tue, 3 Aug 2021 14:38:49 +0000 (16:38 +0200)] 
MINOR: quic: Modify qc_build_cfrms() to support any frame

This function was responsible of building CRYPTO frames to fill as much as
possible a packet passed as argument. This patch makes it support any frame
except STREAM frames whose lengths are highly variable.

3 years agoMINOR: quic: Atomically handle packet number space ->largest_acked_pn variable
Frédéric Lécaille [Tue, 3 Aug 2021 14:06:01 +0000 (16:06 +0200)] 
MINOR: quic: Atomically handle packet number space ->largest_acked_pn variable

Protect this variable (largest acked packet number) from any concurrent access.

3 years agoMINOR: quic: Modify qc_do_build_hdshk_pkt() to accept any packet type
Frédéric Lécaille [Tue, 3 Aug 2021 14:03:09 +0000 (16:03 +0200)] 
MINOR: quic: Modify qc_do_build_hdshk_pkt() to accept any packet type

With this patch qc_do_build_hdshk_pkt() is also able to build Application level
packet type. Its name should be consequently renamed (to come).

3 years agoMINOR: quic: Add the packet type to quic_tx_packet struct
Frédéric Lécaille [Tue, 3 Aug 2021 13:03:35 +0000 (15:03 +0200)] 
MINOR: quic: Add the packet type to quic_tx_packet struct

This is required to build packets from the same function.

3 years agoMINOR: quic: Store post handshake frame in ->pktns.tx.frms MT_LIST
Frédéric Lécaille [Tue, 3 Aug 2021 12:29:03 +0000 (14:29 +0200)] 
MINOR: quic: Store post handshake frame in ->pktns.tx.frms MT_LIST

We want to treat all the frames to be built the same way as frames
built during handshake (CRYPTO frames). So, let't store them at the same
place which is an MT_LIST.

3 years agoMINOR: quic: Add the QUIC connection state to traces
Frédéric Lécaille [Tue, 3 Aug 2021 12:25:36 +0000 (14:25 +0200)] 
MINOR: quic: Add the QUIC connection state to traces

This connection variable was missing. It is useful to debug issues.

3 years agoMINOR: quic: Add a useful function to compute any frame length.
Frédéric Lécaille [Mon, 2 Aug 2021 14:41:28 +0000 (16:41 +0200)] 
MINOR: quic: Add a useful function to compute any frame length.

This should be used by the function which build packets to prevent
it from failing. This is important when the packet numbers are consumed
by several threads. The packet number is used to build and encrypt packets
and must be incremented only and only if the packet it refers to has been
successfully built.

3 years agoMINOR: quic: Add a mask for TX frame builders and their authorized packet types
Frédéric Lécaille [Fri, 30 Jul 2021 12:42:33 +0000 (14:42 +0200)] 
MINOR: quic: Add a mask for TX frame builders and their authorized packet types

As this has been done for RX frame parsers, we add a mask for each TX frame
builder to denote the packet types which are authorized to embed such frames.
Each time a TX frame builder is called, we check that its mask matches the
packet type the frame is built for.

3 years agoMINOR: quic: Replace quic_tx_frm struct by quic_frame struct
Frédéric Lécaille [Tue, 27 Jul 2021 12:51:54 +0000 (14:51 +0200)] 
MINOR: quic: Replace quic_tx_frm struct by quic_frame struct

These structures are similar. quic_tx_frm was there to try to reduce the
size of such objects which embed a union for all the QUIC frames.
Furtheremore this patch fixes the issue where quic_tx_frm objects were freed
from the pool for quic_frame.

3 years agoMINOR: quic: Make ->tx.frms quic_pktns struct member be thread safe
Frédéric Lécaille [Tue, 27 Jul 2021 09:43:11 +0000 (11:43 +0200)] 
MINOR: quic: Make ->tx.frms quic_pktns struct member be thread safe

Replace this member which is a list struct by an mt_list struct.

3 years agoMINOR: quic: Make qc_treat_rx_pkts() be thread safe.
Frédéric Lécaille [Mon, 26 Jul 2021 14:42:56 +0000 (16:42 +0200)] 
MINOR: quic: Make qc_treat_rx_pkts() be thread safe.

Make quic_rx_packet_ref(inc|dec)() functions be thread safe.
Make use of ->rx.crypto.frms_rwlock RW lock when manipulating RX frames
from qc_treat_rx_crypto_frms().
Modify atomically several variables attached to RX part of quic_enc_level struct.

3 years agoMINOR: quic: Rename ->rx.rwlock of quic_enc_level struct to ->rx.pkts_rwlock
Frédéric Lécaille [Mon, 26 Jul 2021 14:38:14 +0000 (16:38 +0200)] 
MINOR: quic: Rename ->rx.rwlock of quic_enc_level struct to ->rx.pkts_rwlock

As there are at two RW lock in this structure, let's the name of this lock
be more explicit.

3 years agoMINOR: quic: Missing encryption level rx.crypto member initialization and lock.
Frédéric Lécaille [Mon, 26 Jul 2021 14:23:53 +0000 (16:23 +0200)] 
MINOR: quic: Missing encryption level rx.crypto member initialization and lock.

->rx.crypto member of quic_enc_level struct was not initialized as
this was done for all other members of this structure. This patch
fixes this.
Also adds a RW lock for the frame of this member.

3 years agoMINOR: quic: Unitialized mux context upon Client Hello message receipt.
Frédéric Lécaille [Wed, 21 Jul 2021 07:34:27 +0000 (09:34 +0200)] 
MINOR: quic: Unitialized mux context upon Client Hello message receipt.

If we let the connection packet handler task (quic_conn_io_cb) process the first
client Initial packet which contain the TLS Client Hello message before the mux
context is initialized, quic_mux_transport_params_update() makes haproxy crash.
->start xprt callback already wakes up this task and is called after all the
connection contexts are initialized. So, this patch do not wakes up quic_conn_io_cb()
if the mux context is not initialized (this was already the case for the connection
context (conn_ctx)).

3 years agoMINOR: quic: Add TX packets at the very last time to their tree.
Frédéric Lécaille [Mon, 19 Jul 2021 12:48:36 +0000 (14:48 +0200)] 
MINOR: quic: Add TX packets at the very last time to their tree.

If we add TX packets to their trees before sending them, they may
be detected as lost before being sent. This may make haproxy crash
when it retreives the prepared packets from TX ring buffers, dereferencing
them after they have been freed.

3 years agoMINOR: Add function for TX packets reference counting
Frédéric Lécaille [Fri, 16 Jul 2021 09:42:44 +0000 (11:42 +0200)] 
MINOR: Add function for TX packets reference counting

Add two functions to encrement or decrement a referenc counter
attached to TX packet structure (struct quic_tx_packet). The packet are freed
when their counters reach the null value.

3 years agoMINOR: quic: Remove old TX buffer implementation
Frédéric Lécaille [Tue, 6 Jul 2021 15:19:44 +0000 (17:19 +0200)] 
MINOR: quic: Remove old TX buffer implementation

We use only ring buffers (struct qring) to prepare and send QUIC datagrams.
We can safely remove the old buffering implementation which was not thread safe.

3 years agoMINOR: quic_tls: Make use of the QUIC V1 salt.
Frédéric Lécaille [Tue, 6 Jul 2021 15:08:04 +0000 (17:08 +0200)] 
MINOR: quic_tls: Make use of the QUIC V1 salt.

This salt is used to derive the Initial secrets.

3 years agoMINOR: quic: Make use of TX ring buffers to send QUIC packets
Frédéric Lécaille [Tue, 6 Jul 2021 14:35:52 +0000 (16:35 +0200)] 
MINOR: quic: Make use of TX ring buffers to send QUIC packets

We modify the functions responsible of building packets to put these latters
in ring buffers (qc_build_hdshk_pkt() during the handshake step, and
qc_build_phdshk_apkt() during the post-handshake step). These functions
remove a ring buffer from its list to build as much as possible datagrams.
Eache datagram is prepended of two field: the datagram length and the
first packet in the datagram. We chain the packets belonging to the same datagram
in a singly linked list to reach them from the first one: indeed we must
modify some members of each packet when we really send them from send_ppkts().
This function is also modified to retrieved the datagram from ring buffers.

3 years agoMINOR: quic: Initialize pointers to TX ring buffer list
Frédéric Lécaille [Tue, 6 Jul 2021 14:25:08 +0000 (16:25 +0200)] 
MINOR: quic: Initialize pointers to TX ring buffer list

We initialize the pointer to the listener TX ring buffer list.
Note that this is not done for QUIC clients  as we do not fully support them:
we only have to allocate the list and attach it to server struct I guess.

3 years agoMINOR: proto_quic: Allocate TX ring buffers for listeners
Frédéric Lécaille [Tue, 6 Jul 2021 13:39:26 +0000 (15:39 +0200)] 
MINOR: proto_quic: Allocate TX ring buffers for listeners

We allocate an array of QUIC ring buffer, one by thread, and arranges them in a
MT_LIST. Everything is allocated or nothing: we do not want to usse an incomplete
array of ring buffers to ensure that each thread may safely acquire one of these
buffers.

3 years agoMINOR: quic: Add ring buffer definition (struct qring) for QUIC
Frédéric Lécaille [Tue, 6 Jul 2021 13:34:37 +0000 (15:34 +0200)] 
MINOR: quic: Add ring buffer definition (struct qring) for QUIC

A ring buffer is made of a circular buffer (->cbuf) and must be arrange
in a MT_LIST (->mt_list).

3 years agoMINOR: net_helper: add functions for pointers
Frédéric Lécaille [Tue, 6 Jul 2021 12:34:46 +0000 (14:34 +0200)] 
MINOR: net_helper: add functions for pointers

Add two functions to read/write pointer values to/from vectors.

3 years agoBUG/MINOR: quic: Too much reduced computed space to build handshake packets
Frédéric Lécaille [Fri, 2 Jul 2021 15:20:04 +0000 (17:20 +0200)] 
BUG/MINOR: quic: Too much reduced computed space to build handshake packets

Before this patch we reserved 16 bytes (QUIC_TLS_TAG_LEN) before building the
handshake packet to be sure to be able to add the tag which comes with the
the packet encryption, decreasing the end offset of the building buffer by 16 bytes.
But this tag length was taken into an account when calling qc_build_frms() which
computes and build crypto frames for the remaining available room thanks to <*len>
parameter which is the length of the already present bytes in the building buffer
before adding CRYPTO frames. This leaded us to waste the 16 last bytes of the buffer
which were not used.

3 years agoMINOR: quic: Add the QUIC v1 initial salt.
Frédéric Lécaille [Thu, 1 Jul 2021 15:48:46 +0000 (17:48 +0200)] 
MINOR: quic: Add the QUIC v1 initial salt.

See initial_salt value for QUIC-TLS RFC 9001 at
https://www.rfc-editor.org/rfc/rfc9001.html#name-initial-secrets

3 years agoMINOR: quic: Prefer x25519 as ECDH preferred parametes.
Frédéric Lécaille [Thu, 1 Jul 2021 15:09:05 +0000 (17:09 +0200)] 
MINOR: quic: Prefer x25519 as ECDH preferred parametes.

This make at least our listeners answer to ngtcp2 clients without
HelloRetryRequest message. It seems the server choses the first
group in the group list ordered by preference and set by
SSL_CTX_set1_curves_list() which match the client ones.

3 years agoMINOR: quic: Add a ring buffer implementation for QUIC
Frédéric Lécaille [Wed, 30 Jun 2021 12:25:10 +0000 (14:25 +0200)] 
MINOR: quic: Add a ring buffer implementation for QUIC

This implementation is inspired from Linux kernel circular buffer implementation
(see include/linux/circ-buf.h). Such buffers may be used at the same time both
by writer and reader (lock-free).

3 years agoMINOR: quic: Make qc_lstnr_pkt_rcv() be thread safe.
Frédéric Lécaille [Mon, 14 Jun 2021 12:18:10 +0000 (14:18 +0200)] 
MINOR: quic: Make qc_lstnr_pkt_rcv() be thread safe.

Modify the I/O dgram handler principal function used to parse QUIC packets
be thread safe. Its role is at least to create new incoming connections
add to two trees protected by the same RW lock. The packets are for now on
fully parsed before possibly creating new connections.

3 years agoMINOR: quic: Move conn_prepare() to ->accept_conn() callback
Frédéric Lécaille [Mon, 14 Jun 2021 08:31:43 +0000 (10:31 +0200)] 
MINOR: quic: Move conn_prepare() to ->accept_conn() callback

The xprt context must be initialized before receiving further packets from
the I/O dgram handler.

3 years agoMINOR: quic: Connection allocations rework
Frédéric Lécaille [Fri, 11 Jun 2021 13:44:24 +0000 (15:44 +0200)] 
MINOR: quic: Connection allocations rework

Allocate everything needed for a connection (struct quic_conn) from the same
function.
Rename qc_new_conn_init() to qc_new_conn() to reflect these modifications.
Insert these connection objects in their tree after returning from this function.

3 years agoMINOR: quic: Do not wakeup the xprt task on ACK receipt
Frédéric Lécaille [Fri, 11 Jun 2021 07:39:20 +0000 (09:39 +0200)] 
MINOR: quic: Do not wakeup the xprt task on ACK receipt

This is an old statement which was there before implemeting the PTO and
packet loss detection. There is no reason to keep for now on.

3 years agoMINOR: quic: Add useful traces for I/O dgram handler
Frédéric Lécaille [Thu, 10 Jun 2021 06:18:45 +0000 (08:18 +0200)] 
MINOR: quic: Add useful traces for I/O dgram handler

This traces have already help in diagnosing multithreading issues.

3 years agoMINOR: quic: Replace the RX unprotected packet list by a thread safety one.
Frédéric Lécaille [Mon, 7 Jun 2021 12:38:18 +0000 (14:38 +0200)] 
MINOR: quic: Replace the RX unprotected packet list by a thread safety one.

This list is shared between the I/O dgram handler and the task responsible
for processing the QUIC packets inside.

3 years agoMINOR: quic: Replace the RX list of packet by a thread safety one.
Frédéric Lécaille [Mon, 7 Jun 2021 08:28:10 +0000 (10:28 +0200)] 
MINOR: quic: Replace the RX list of packet by a thread safety one.

This list is shared between the I/O dgram handler and the task responsible
for processing the QUIC packets.

3 years agoMINOR: quic: Replace quic_conn_ctx struct by ssl_sock_ctx struct
Frédéric Lécaille [Fri, 4 Jun 2021 12:59:59 +0000 (14:59 +0200)] 
MINOR: quic: Replace quic_conn_ctx struct by ssl_sock_ctx struct

Some SSL call may be called with pointer to ssl_sock_ctx struct as parameter
which does not match the quic_conn_ctx struct type (see ssl_sock_infocb()).
I am not sure we have to keep such callbacks for QUIC but we must ensure
the SSL and QUIC xprts use the same data structure as context.

3 years agoMINOR: quic: Move the connection state
Frédéric Lécaille [Fri, 4 Jun 2021 09:52:35 +0000 (11:52 +0200)] 
MINOR: quic: Move the connection state

Move the connection state from quic_conn_ctx struct to quic_conn struct which
is the structure which is used to store the QUIC connection part information.
This structure is initialized by the I/O dgram handler for each new connection
to QUIC listeners. This is needed for the multithread support so that to not
to have to depend on the connection context potentially initialized by another
thread.

3 years agoMINOR: quic: Add a lock for RX packets
Frédéric Lécaille [Fri, 4 Jun 2021 08:33:32 +0000 (10:33 +0200)] 
MINOR: quic: Add a lock for RX packets

We must protect from concurrent the tree which stores the QUIC packets received
by the dgram I/O handler, these packets being also parsed by the xprt task.

3 years agoMINOR: quic: Do not stop the packet parsing too early in qc_treat_rx_packets()
Frédéric Lécaille [Fri, 4 Jun 2021 08:27:23 +0000 (10:27 +0200)] 
MINOR: quic: Do not stop the packet parsing too early in qc_treat_rx_packets()

Continue to parse the packets even if we will not be able to acknowledge them.

3 years agoBUG/MINOR: quic: Wrong RX packet reference counter usage
Frédéric Lécaille [Fri, 4 Jun 2021 08:23:11 +0000 (10:23 +0200)] 
BUG/MINOR: quic: Wrong RX packet reference counter usage

No need to call free_quic_rx_packet() after calling quic_rx_packet_eb64_delete()
as this latter already calls quic_rx_packet_refdec() also called by
free_quic_rx_packet().

3 years agoCLEAUNUP: quic: Usage of a useless variable in qc_treat_rx_pkts()
Frédéric Lécaille [Fri, 4 Jun 2021 08:12:43 +0000 (10:12 +0200)] 
CLEAUNUP: quic: Usage of a useless variable in qc_treat_rx_pkts()

The usage of a <drop> variable is unnecessary here.

3 years agoBUG/MINOR: quic: Missing cases treatement when updating ACK ranges
Frédéric Lécaille [Wed, 2 Jun 2021 15:40:09 +0000 (17:40 +0200)] 
BUG/MINOR: quic: Missing cases treatement when updating ACK ranges

Let's say that we have to insert a range R between to others A and B
with A->first <= R->first <= B->first. We have to remove the ranges
which are overlapsed by R during. This was correctly done when
the intersection between A and R was not empty, but not when the
intersection between R and B was not empty. If this latter case
after having inserting a new range R we set <new> variable as the
node to consider to check the overlaping between R and its following
ranges.

3 years agoMINOR: quic: Remove a useless variable in quic_update_ack_ranges_list()
Frédéric Lécaille [Wed, 2 Jun 2021 15:38:13 +0000 (17:38 +0200)] 
MINOR: quic: Remove a useless variable in quic_update_ack_ranges_list()

This very minor modification is there to ease the readibilyt of this function.

3 years agoMINOR: quic: Useless test in quic_update_ack_ranges_list()
Frédéric Lécaille [Wed, 2 Jun 2021 13:36:12 +0000 (15:36 +0200)] 
MINOR: quic: Useless test in quic_update_ack_ranges_list()

At this place, the condition "le_ar->first.key <= ar->first" is true because
<le_ar> is the ack-range just below <ar> ack range.

3 years agoMINOR: quic: quic_update_ack_ranges_list() code factorization
Frédéric Lécaille [Wed, 2 Jun 2021 13:27:34 +0000 (15:27 +0200)] 
MINOR: quic: quic_update_ack_ranges_list() code factorization

Very minor modification to avoid repeating the same code section in this function
when allocation new ack range.

3 years agoBUG/MINOR: quic: Wrong memory free in quic_update_ack_ranges_list()
Frédéric Lécaille [Wed, 2 Jun 2021 13:04:03 +0000 (15:04 +0200)] 
BUG/MINOR: quic: Wrong memory free in quic_update_ack_ranges_list()

Wrong call to free() in place of pool_free() for an object allocated from a pool
memory.

3 years agoMINOR: quic: Remove header protection also for Initial packets
Frédéric Lécaille [Mon, 31 May 2021 16:04:07 +0000 (18:04 +0200)] 
MINOR: quic: Remove header protection also for Initial packets

Make qc_try_rm_hp() be able to remove the header protection of Initial packets
which are the first incoming packets of a connection without context.

3 years agoMINOR: quic: Derive the initial secrets asap
Frédéric Lécaille [Mon, 31 May 2021 13:16:13 +0000 (15:16 +0200)] 
MINOR: quic: Derive the initial secrets asap

Make depends qc_new_isecs() only on quic_conn struct initialization only (no more
dependency on connection struct initialization) to be able to run it as soon as
the quic_conn struct is initialized (from the I/O handler) before running ->accept()
quic proto callback.

3 years agoMINOR: quic: Remove header protection for conn with context
Frédéric Lécaille [Mon, 31 May 2021 08:24:49 +0000 (10:24 +0200)] 
MINOR: quic: Remove header protection for conn with context

We remove the header protection of packet only for connection with already
initialized context. This latter keep traces of the connection state.
Furthermore, we enqueue the first Initial packet for a new connection
after having completely parsed the packet so that to not start the accept
process for nothing.

3 years agoMINOR: quic: QUIC conn initialization from I/O handler
Frédéric Lécaille [Mon, 31 May 2021 07:30:14 +0000 (09:30 +0200)] 
MINOR: quic: QUIC conn initialization from I/O handler

Move the QUIC conn (struct quic_conn) initialization from quic_sock_accept_conn()
to qc_lstnr_pkt_rcv() as this is done for the server part.
Move the timer initialization to ->start xprt callback to ensure the connection
context is done : it is initialized by the ->accept callback which may be run
by another thread than the one for the I/O handler which also run ->start.

3 years agoBUG/MINOR: quic: Do not check the acception of a new conn from I/O handler.
Frédéric Lécaille [Fri, 28 May 2021 08:25:07 +0000 (10:25 +0200)] 
BUG/MINOR: quic: Do not check the acception of a new conn from I/O handler.

As the ->conn member of quic_conn struct is reset to NULL value by the ->accept
callback potentially run by another thread, this check is irrelevant.

3 years agoMINOR: quic: Initialize the session before starting the xprt.
Frédéric Lécaille [Thu, 27 May 2021 15:12:36 +0000 (17:12 +0200)] 
MINOR: quic: Initialize the session before starting the xprt.

We must ensure the session and the mux are initialized before starting the xprt.

3 years agoMINOR: quic: Move an SSL func call from QUIC I/O handler to the xprt init.
Frédéric Lécaille [Thu, 27 May 2021 12:57:09 +0000 (14:57 +0200)] 
MINOR: quic: Move an SSL func call from QUIC I/O handler to the xprt init.

Move the call to SSL_set_quic_transport_params() from the listener I/O dgram
handler to the ->init() callback of the xprt (qc_conn_init()) which initializes
its context where is stored the SSL context itself, needed by
SSL_set_quic_transport_params(). Furthermore this is already what is done for the
server counterpart of ->init() QUIC xprt callback. As the ->init() may be run
by another thread than the one for the I/O handler, the xprt context could
not be potentially already initialized before calling SSL_set_quic_transport_params()
from the I/O handler.

3 years agoMINOR: quic: Enable some quic, h3 and qpack modules compilation.
Frédéric Lécaille [Tue, 25 May 2021 07:12:35 +0000 (09:12 +0200)] 
MINOR: quic: Enable some quic, h3 and qpack modules compilation.

Enable src/h3.c compilation for h3, src/qpack-dec.c and sr/qpack-tbl.c
compilation for qpack, and src/mux_quic.c for the QUIC mux.

3 years agoMINOR: quic: Replace max_packet_size by max_udp_payload size.
Frédéric Lécaille [Mon, 17 May 2021 14:42:21 +0000 (16:42 +0200)] 
MINOR: quic: Replace max_packet_size by max_udp_payload size.

The name the maximum packet size transport parameter was ambiguous and replaced
by maximum UDP payload size. Our code would be also ambiguous if it does not
reflect this change.

3 years agoMINOR: quic: Avoid header collisions
Frédéric Lécaille [Tue, 23 Mar 2021 13:46:56 +0000 (14:46 +0100)] 
MINOR: quic: Avoid header collisions

Extract the QUIC varints encoding functions from xprt_quic.h to avoid
header collisions.

3 years agoMINOR: quic: Update the streams transport parameters.
Frédéric Lécaille [Thu, 18 Mar 2021 14:05:18 +0000 (15:05 +0100)] 
MINOR: quic: Update the streams transport parameters.

Set the streams transport parameters which could not be initialized because they
were not available during initializations. Indeed, the streams transport parameters
are provided by the peer during the handshake.

3 years agoMINOR: quic: Add a wrapper function to update transport parameters.
Frédéric Lécaille [Thu, 18 Mar 2021 14:01:27 +0000 (15:01 +0100)] 
MINOR: quic: Add a wrapper function to update transport parameters.

This function calls quic_mux_transport_params_update() to update the related
streams transport parameter of the mux. It is there only so that not to have
to include mux_quic.h to update these parameters.

3 years agoBUG/MINOR: quic: Wrong ->accept() error handling
Frédéric Lécaille [Thu, 11 Mar 2021 16:06:30 +0000 (17:06 +0100)] 
BUG/MINOR: quic: Wrong ->accept() error handling

Really signal the caller that ->accept() has failed if the session could not
be initialized because conn_complete_session() has failed. This is the case
if the mux could not be initialized too.
When it fails an ->accept() must returns -1 in case of resource shortage.

3 years agoMINOR: quic: Variable-length integer encoding/decoding into/from buffer struct.
Frédéric Lécaille [Thu, 4 Mar 2021 18:12:20 +0000 (19:12 +0100)] 
MINOR: quic: Variable-length integer encoding/decoding into/from buffer struct.

Add a function to encode a QUIC varint into a buffer struct. Samething for the
deconding part.

3 years agoMINOR: quic: Add callbacks for (un)scribing to QUIC xprt.
Frédéric Lécaille [Wed, 3 Mar 2021 16:28:34 +0000 (17:28 +0100)] 
MINOR: quic: Add callbacks for (un)scribing to QUIC xprt.

Add these callbacks so that the QUIC mux may (un)scribe to the read/write xprt
events.

3 years agoMINOR: quic: Disable the action of ->rcv_buf() xprt callback
Frédéric Lécaille [Wed, 3 Mar 2021 15:23:44 +0000 (16:23 +0100)] 
MINOR: quic: Disable the action of ->rcv_buf() xprt callback

Deactivate the action of this callback at this time. I am not sure
we will keep it for QUIC as it does not really make sense for QUIC:
the QUIC packet are already recvfrom()'ed by the low level I/O handler
used for all the connections.

3 years agoMINOR: quic_sock: Finalize the QUIC connections.
Frédéric Lécaille [Wed, 3 Mar 2021 15:21:00 +0000 (16:21 +0100)] 
MINOR: quic_sock: Finalize the QUIC connections.

Add a call to conn_connection_complete() so that to install the mux any
QUIC connection.

3 years agoMINOR: qpack: Add QPACK compression.
Frédéric Lécaille [Wed, 3 Mar 2021 15:13:10 +0000 (16:13 +0100)] 
MINOR: qpack: Add QPACK compression.

Implement QPACK used for HTTP header compression by h3.

3 years agoMINOR: h3: Add HTTP/3 definitions.
Frédéric Lécaille [Wed, 3 Mar 2021 15:09:02 +0000 (16:09 +0100)] 
MINOR: h3: Add HTTP/3 definitions.

Add all the definitions for HTTP/3 implementation.

3 years agoMINOR: quic: Add a new definition to store STREAM frames.
Frédéric Lécaille [Wed, 3 Mar 2021 15:04:28 +0000 (16:04 +0100)] 
MINOR: quic: Add a new definition to store STREAM frames.

Add a new structure to store enough information about STREAM frames which
must be stored before being delivered to the application layer, for any
reason.

3 years agoMINOR: quic: Attach QUIC mux connection objet to QUIC connection.
Frédéric Lécaille [Thu, 18 Feb 2021 09:16:06 +0000 (10:16 +0100)] 
MINOR: quic: Attach QUIC mux connection objet to QUIC connection.

This add a qcc struct for QUIC mux/demux connection layer to quic_conn struct
at low level connection layer.

3 years agoMINOR: connection: Add callbacks definitions for QUIC.
Frédéric Lécaille [Thu, 18 Feb 2021 09:04:27 +0000 (10:04 +0100)] 
MINOR: connection: Add callbacks definitions for QUIC.

The flow control at stream level is organized by types (client bidi, server bidi,
client uni, server uni). Adds at least callback to retrieve the number
of available streams by direction.

3 years agoMINOR: mux_quic: Add QUIC mux layer.
Frédéric Lécaille [Thu, 18 Feb 2021 08:59:01 +0000 (09:59 +0100)] 
MINOR: mux_quic: Add QUIC mux layer.

This file has been derived from mux_h2.c removing all h2 parts. At
QUIC mux layer, there must not be any reference to http. This will be the
responsability of the application layer (h3) to open streams handled by the mux.

3 years agoMINOR: quic: Move transport parmaters to anynomous struct.
Frédéric Lécaille [Thu, 28 Jan 2021 15:22:52 +0000 (16:22 +0100)] 
MINOR: quic: Move transport parmaters to anynomous struct.

We move ->params transport parameters to ->rx.params. They are the
transport parameters which will be sent to the peer, and used for
the endpoint flow control. So, they will be used to received packets
from the peer (RX part).
Also move ->rx_tps transport parameters to ->tx.params. They are the
transport parameter which are sent by the peer, and used to respect
its flow control limits. So, they will be used when sending packets
to the peer (TX part).

3 years agoBUG/MINOR: quic: Possible NULL pointer dereferencing when dumping streams.
Frédéric Lécaille [Mon, 11 Jan 2021 14:10:06 +0000 (15:10 +0100)] 
BUG/MINOR: quic: Possible NULL pointer dereferencing when dumping streams.

This bug may occur when displaying streams traces. It came with this commit:
242fb1b63 ("MINOR: quic: Drop packets with STREAM frames with wrong direction.").

3 years agoBUG/MEDIUM: leastconn: fix rare possibility of divide by zero
Willy Tarreau [Wed, 22 Sep 2021 05:15:57 +0000 (07:15 +0200)] 
BUG/MEDIUM: leastconn: fix rare possibility of divide by zero

An optimization was brought in commit 5064ab6a9 ("OPTIM: lb-leastconn:
do not unlink the server if it did not change") to avoid locking the
server just to discover it did not move. However a mistake was made
because the operation involves a divide with a value that is read
outside of its usual lock, which makes it possible to be zero at the
exact moment we watch it if another thread takes the server down under
the lbprm lock, resulting in a divide by zero.

Therefore we must check that the value is not null there.

This must be backported to 2.4.

3 years agoMEDIUM: listener: deprecate "process" in favor of "thread" on bind lines
Willy Tarreau [Tue, 21 Sep 2021 12:31:29 +0000 (14:31 +0200)] 
MEDIUM: listener: deprecate "process" in favor of "thread" on bind lines

The "process" directive on "bind" lines becomes quite confusing considering
that the only allowed value is 1 for the process, and that threads are
optional and come after the mandatory "1/".

Let's introduce a new "thread" directive to directly configure thread
numbers, and mark "process" as deprecated. Now "process" will emit a
warning and will suggest how to be replaced with "thread" instead.
The doc was updated accordingly (mostly a copy-paste of the previous
description which was already up to date).

This is marked as MEDIUM as it will impact users having "zero-warning"
and "process" specified.

3 years agoMINOR: server: enable slowstart for dynamic server
Amaury Denoyelle [Tue, 21 Sep 2021 09:51:54 +0000 (11:51 +0200)] 
MINOR: server: enable slowstart for dynamic server

Enable the 'slowstart' keyword for dynamic servers. The slowstart task
is allocated in 'add server' handler if slowstart is used.

As the server is created in disabled state, there is no need to start
the task. The slowstart task will be automatically started on the first
'enable server' invocation.

3 years agoREORG: server: move slowstart init outside of checks
Amaury Denoyelle [Tue, 21 Sep 2021 09:51:29 +0000 (11:51 +0200)] 
REORG: server: move slowstart init outside of checks

'slowstart' can be used without check on a server, with the CLI handlers
'enable/disable server'. Move the code to initialize and start the
slowstart task outside of check.c.

This change will also be reused to enable slowstart for dynamic servers.

3 years agoMINOR: server: enable more check related keywords for dynamic servers
Amaury Denoyelle [Mon, 20 Sep 2021 13:16:12 +0000 (15:16 +0200)] 
MINOR: server: enable more check related keywords for dynamic servers

Allow to use the check related keywords defined in server.c. These
keywords can be enabled now that checks have been implemented for
dynamic servers.

Here is the list of the new keywords supported :
- error-limit
- observe
- on-error
- on-marked-down
- on-marked-up

3 years agoMINOR: server: enable more keywords for ssl checks for dynamic servers
Amaury Denoyelle [Mon, 20 Sep 2021 13:15:19 +0000 (15:15 +0200)] 
MINOR: server: enable more keywords for ssl checks for dynamic servers

Allow to configure ssl support for dynamic server checks independently
of the ssl server configuration. This is done via the keyword
"check-ssl". Also enable to configure the sni/alpn used for the check
via "check-sni/alpn".

3 years agoBUG/MINOR: server: alloc dynamic srv ssl ctx if proxy uses ssl chk rule
Amaury Denoyelle [Mon, 20 Sep 2021 13:31:42 +0000 (15:31 +0200)] 
BUG/MINOR: server: alloc dynamic srv ssl ctx if proxy uses ssl chk rule

The ssl context is not initialized for a dynamic server, even if there
is a tcpcheck rule which uses ssl on the related backed. This will cause
the check initialization to failed with the message :
  "Out of memory when initializing an SSL connection"

This can be reproduced by having the following config in the backend :
  option tcp-check
  tcp-check connect ssl
and create a dynamic server with check activated and a ca-file.

Fix this by calling the prepare_srv xprt callback when the proxy options
PR_O_TCPCKH_SSL is set.

Check support for dynamic servers has been merged in the current branch.
No backport needed.

3 years agoBUG/MINOR: server: allow 'enable health' only if check configured
Amaury Denoyelle [Tue, 21 Sep 2021 08:29:09 +0000 (10:29 +0200)] 
BUG/MINOR: server: allow 'enable health' only if check configured

Test that checks have been configured on the server before enabling via
the 'enable health' CLI. This mirrors the 'enable agent' command.

Without this, a user can use the command on the server without checks.
This leaves the server in an undefined state. Notably, the stat page
reports the server in check transition.

This condition was left on the following reorg commit.
  2c04eda8b58636ad2ae44e42b1f50f3b5a24a642
  REORG: cli: move "{enable|disable} health" to server.c

This should be backported up to 1.8.

3 years agoCLEANUP: Remove unreachable `break` from parse_time_err()
Tim Duesterhus [Thu, 16 Sep 2021 15:38:27 +0000 (17:38 +0200)] 
CLEANUP: Remove unreachable `break` from parse_time_err()

The `return` already leaves the function.

3 years agoCLEANUP: Include check.h in flt_spoe.c
Tim Duesterhus [Thu, 16 Sep 2021 15:38:26 +0000 (17:38 +0200)] 
CLEANUP: Include check.h in flt_spoe.c

This is required for the prototype of spoe_prepare_healthcheck_request().

3 years agoMINOR: httpclient: add the EOH when no headers where provided
William Lallemand [Mon, 20 Sep 2021 14:19:15 +0000 (16:19 +0200)] 
MINOR: httpclient: add the EOH when no headers where provided

httpclient_req_gen() now adds the end of headers block when no header
was provided, which avoid adding it manually.

3 years agoBUG/MINOR: flt-trace: fix an infinite loop when random-parsing is set
Dragan Dosen [Mon, 20 Sep 2021 07:29:19 +0000 (09:29 +0200)] 
BUG/MINOR: flt-trace: fix an infinite loop when random-parsing is set

The issue is introduced with the commit c41d8bd65 ("CLEANUP: flt-trace:
Remove unused random-parsing option").

This must be backported everywhere the above commit is.

3 years agoDEV: coccinelle: Add xalloc_cast.cocci
Tim Duesterhus [Wed, 15 Sep 2021 11:58:47 +0000 (13:58 +0200)] 
DEV: coccinelle: Add xalloc_cast.cocci

This remove's C++ style casts from the return value of malloc/calloc.

see 403fd722ace1d98d3cfe17bbee1382bf58040466

3 years agoCLEANUP: Apply xalloc_size.cocci
Tim Duesterhus [Wed, 15 Sep 2021 11:58:46 +0000 (13:58 +0200)] 
CLEANUP: Apply xalloc_size.cocci

This fixes a few locations with a hardcoded type within `sizeof()`.

3 years agoDEV: coccinelle: Add bug_on.cocci
Tim Duesterhus [Wed, 15 Sep 2021 11:58:48 +0000 (13:58 +0200)] 
DEV: coccinelle: Add bug_on.cocci

This replaces an if + ABORT_NOW() by BUG_ON(). It might change behavior,
because BUG_ON will result in a no-op if not enabled.

3 years agoDEV: coccinelle: Add xalloc_size.cocci
Tim Duesterhus [Wed, 15 Sep 2021 11:58:45 +0000 (13:58 +0200)] 
DEV: coccinelle: Add xalloc_size.cocci

This commits the Coccinelle patch to clean up sizeof handling for malloc/calloc.

3 years agoCLEANUP: Apply bug_on.cocci
Tim Duesterhus [Wed, 15 Sep 2021 11:58:49 +0000 (13:58 +0200)] 
CLEANUP: Apply bug_on.cocci

The changes look safe to me, even if `DEBUG_STRICT` is not enabled.

3 years agoDEV: coccinelle: Add ist.cocci
Tim Duesterhus [Wed, 15 Sep 2021 11:58:43 +0000 (13:58 +0200)] 
DEV: coccinelle: Add ist.cocci

This commits the Coccinelle patch to clean up ist handling.

3 years agoCLEANUP: Apply ist.cocci
Tim Duesterhus [Wed, 15 Sep 2021 11:58:44 +0000 (13:58 +0200)] 
CLEANUP: Apply ist.cocci

This cleans up ist handling.

3 years agoREORG: threads: move ha_get_pthread_id() to tinfo.h
Willy Tarreau [Mon, 13 Sep 2021 16:42:07 +0000 (18:42 +0200)] 
REORG: threads: move ha_get_pthread_id() to tinfo.h

This solely manipulates the thread_info struct, it ought to be in
tinfo.h, not in thread.h.

3 years agoMINOR: applet: remove the thread mask from appctx_new()
Willy Tarreau [Mon, 13 Sep 2021 08:07:38 +0000 (10:07 +0200)] 
MINOR: applet: remove the thread mask from appctx_new()

appctx_new() is exclusively called with tid_bit and it only uses the
mask to pass it to the accompanying task. There is no point requiring
the caller to know about a mask there, nor is there any point in
creating an applet outside of the context of its own thread anyway.
Let's drop this and pass tid_bit to task_new() directly.

3 years agoBUILD: fd: remove unused variable totlen in fd_write_frag_line()
Willy Tarreau [Fri, 17 Sep 2021 10:00:27 +0000 (12:00 +0200)] 
BUILD: fd: remove unused variable totlen in fd_write_frag_line()

Ilya reports in GH #1392 that clang 13 complains about totlen being
calculated and not used in fd_write_frag_line(), which is true. It's
a leftover of some older code.