]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
3 years agoMINOR: buf: Add b_force_xfer() function
Frédéric Lécaille [Thu, 9 Sep 2021 14:53:33 +0000 (16:53 +0200)] 
MINOR: buf: Add b_force_xfer() function

This function does exactly the same thing as b_xfer() which transfers
data from a struct buffer to another one but without zero copy when
the destination buffer is empty. This is at least useful to transfer
h3 data to the QUIC mux from buffer with garbage medata which have
been used to build h3 frames without too much memcopy()/memmove().

3 years agoMINOR: quic_sock: Do not flag QUIC connections as being set
Frédéric Lécaille [Wed, 8 Sep 2021 15:08:17 +0000 (17:08 +0200)] 
MINOR: quic_sock: Do not flag QUIC connections as being set

This is to let conn_get_src() or conn_get_src() set the source
or destination addresses for the connection.

3 years agoMINOR: quic: Missing active_connection_id_limit default value
Frédéric Lécaille [Fri, 3 Sep 2021 14:42:19 +0000 (16:42 +0200)] 
MINOR: quic: Missing active_connection_id_limit default value

The peer transport parameter values were not initialized with
the default ones (when absent), especially the
"active_connection_id_limit" parameter with 2 as default value
when absent from received remote transport parameters. This
had as side effect to send too much NEW_CONNECTION_ID frames.
This was the case for curl which does not announce any
"active_connection_id_limit" parameter.
Also rename ->idle_timeout to ->max_idle_timeout to reflect the RFC9000.

3 years agoMINOR: quic: Attach the QUIC connection to a thread.
Frédéric Lécaille [Fri, 3 Sep 2021 13:56:18 +0000 (15:56 +0200)] 
MINOR: quic: Attach the QUIC connection to a thread.

Compute a thread ID from a QUIC CID and attach the I/O handler to this
thread.

3 years agoMINOR: quic: Make QUIC-TLS support at least two initial salts
Frédéric Lécaille [Tue, 31 Aug 2021 17:10:40 +0000 (19:10 +0200)] 
MINOR: quic: Make QUIC-TLS support at least two initial salts

These salts are used to derive initial secrets to decrypt the first Initial packet.
We support draft-29 and v1 QUIC version initial salts.
Add parameters to our QUIC-TLS API functions used to derive these secret for
these salts.
Make our xprt_quic use the correct initial salt upon QUIC version field found in
the first paquet. Useful to support connections with curl which use draft-29
QUIC version.

3 years agoMINOR: quic: Shorten some handshakes
Frédéric Lécaille [Mon, 30 Aug 2021 15:16:07 +0000 (17:16 +0200)] 
MINOR: quic: Shorten some handshakes

Move the "ACK required" bit from the packet number space to the connection level.
Force the "ACK required" option when acknowlegding Handshake or Initial packet.
A client may send three packets with a different encryption level for each. So,
this patch modifies qc_treat_rx_pkts() to consider two encryption level passed
as parameters, in place of only one.
Make qc_conn_io_cb() restart its process after the handshake has succeeded
so that to process any Application level packets which have already been received
in the same datagram as the last CRYPTO frames in Handshake packets.

3 years agoMINOR: h3/mux: detect fin on last h3 frame of the stream
Amaury Denoyelle [Tue, 24 Aug 2021 14:28:47 +0000 (16:28 +0200)] 
MINOR: h3/mux: detect fin on last h3 frame of the stream

3 years agoMINOR: h3: send htx data
Amaury Denoyelle [Tue, 24 Aug 2021 14:24:37 +0000 (16:24 +0200)] 
MINOR: h3: send htx data

3 years agoMINOR: h3: encode htx headers to QPACK
Amaury Denoyelle [Tue, 24 Aug 2021 14:20:27 +0000 (16:20 +0200)] 
MINOR: h3: encode htx headers to QPACK

3 years agoMINOR: qpack: encode headers functions
Amaury Denoyelle [Tue, 24 Aug 2021 14:17:38 +0000 (16:17 +0200)] 
MINOR: qpack: encode headers functions

3 years agoMINOR: qpack: create qpack-enc module
Amaury Denoyelle [Tue, 24 Aug 2021 13:50:32 +0000 (15:50 +0200)] 
MINOR: qpack: create qpack-enc module

3 years agoMINOR: mux-quic: define FIN stream flag
Amaury Denoyelle [Fri, 27 Aug 2021 12:55:39 +0000 (14:55 +0200)] 
MINOR: mux-quic: define FIN stream flag

3 years agoMINOR: h3: define snd_buf callback and divert mux ops
Amaury Denoyelle [Tue, 24 Aug 2021 14:33:53 +0000 (16:33 +0200)] 
MINOR: h3: define snd_buf callback and divert mux ops

3 years agoMINOR: mux-quic: send SETTINGS on uni stream
Amaury Denoyelle [Fri, 27 Aug 2021 13:05:29 +0000 (15:05 +0200)] 
MINOR: mux-quic: send SETTINGS on uni stream

3 years agoMEDIUM: mux-quic: implement ring buffer on stream tx
Amaury Denoyelle [Tue, 24 Aug 2021 14:11:18 +0000 (16:11 +0200)] 
MEDIUM: mux-quic: implement ring buffer on stream tx

3 years agoMINOR: h3: allocate stream on headers
Amaury Denoyelle [Tue, 24 Aug 2021 13:36:02 +0000 (15:36 +0200)] 
MINOR: h3: allocate stream on headers

3 years agoMINOR: h3: parse headers to htx
Amaury Denoyelle [Tue, 24 Aug 2021 13:30:12 +0000 (15:30 +0200)] 
MINOR: h3: parse headers to htx

3 years agoMINOR: qpack: generate headers list on decoder
Amaury Denoyelle [Tue, 24 Aug 2021 13:13:20 +0000 (15:13 +0200)] 
MINOR: qpack: generate headers list on decoder

TMP -> non-free strdup
TMP -> currently only support indexed field line or literal field line
with name reference

3 years agoMINOR: qpack: fix wrong comment
Amaury Denoyelle [Tue, 24 Aug 2021 13:36:39 +0000 (15:36 +0200)] 
MINOR: qpack: fix wrong comment

3 years agoMINOR: quic-enc: fix varint encoding
Amaury Denoyelle [Tue, 24 Aug 2021 14:29:49 +0000 (16:29 +0200)] 
MINOR: quic-enc: fix varint encoding

3 years agoMINOR: h3: change default settings
Amaury Denoyelle [Tue, 24 Aug 2021 13:16:58 +0000 (15:16 +0200)] 
MINOR: h3: change default settings

In particular, advertise a 0-length dynamic table for QPACK.

3 years agoMINOR: quic: Prepare STREAM frames to fill QUIC packets
Frédéric Lécaille [Wed, 25 Aug 2021 15:56:22 +0000 (17:56 +0200)] 
MINOR: quic: Prepare STREAM frames to fill QUIC packets

We must take as most as possible data from STREAM frames to be encapsulated
in QUIC packets, almost as this is done for CRYPTO frames whose fields are
variable length fields. The difference is that STREAM frames are only accepted
for short packets without any "Length" field. So it is sufficient to call
max_available_room() for that in place of max_stream_data_size() as this
is done for CRYPTO data.

3 years agoMINOR: quic: Wrong short packet minimum length
Frédéric Lécaille [Wed, 25 Aug 2021 14:11:00 +0000 (16:11 +0200)] 
MINOR: quic: Wrong short packet minimum length

There is no destination connection ID length field in the short packet header.

3 years agoMINOR: quic: Wrong STREAM frame length computing
Frédéric Lécaille [Wed, 25 Aug 2021 14:08:47 +0000 (16:08 +0200)] 
MINOR: quic: Wrong STREAM frame length computing

The ->len and ->offset field of STREAM frame are optional.

3 years agoMINOR: h3: Send h3 settings asap
Frédéric Lécaille [Mon, 23 Aug 2021 07:50:29 +0000 (09:50 +0200)] 
MINOR: h3: Send h3 settings asap

As it is possible to send Application level packets during the handshake,
let's send the h3 settings asaps.

3 years agoMINOR: quic: Prepare Application level packet asap.
Frédéric Lécaille [Mon, 23 Aug 2021 06:54:28 +0000 (08:54 +0200)] 
MINOR: quic: Prepare Application level packet asap.

It is possible the TLS stack stack provides us with 1-RTT TX secrets
at the same time as Handshake secrets are provided. Thanks to this
simple patch we can build Application level packets during the handshake.

3 years agoMINOR: quic: Post handshake packet building improvements
Frédéric Lécaille [Thu, 19 Aug 2021 15:35:21 +0000 (17:35 +0200)] 
MINOR: quic: Post handshake packet building improvements

Make qc_prep_hdshk_pkts() and qui_conn_io_cb() handle the case
where we enter them with QUIC_HS_ST_COMPLETE or QUIC_HS_ST_CONFIRMED
as connection state with QUIC_TLS_ENC_LEVEL_APP and QUIC_TLS_ENC_LEVEL_NONE
to consider to prepare packets.
quic_get_tls_enc_levels() is modified to return QUIC_TLS_ENC_LEVEL_APP
and QUIC_TLS_ENC_LEVEL_NONE as levels to consider when coalescing
packets in the same datagram.

3 years agoMINOR: quic: Missing case when discarding HANDSHAKE secrets
Frédéric Lécaille [Thu, 19 Aug 2021 13:35:59 +0000 (15:35 +0200)] 
MINOR: quic: Missing case when discarding HANDSHAKE secrets

With very few packets received by the listener, it is possible
that its state may move from QUIC_HS_ST_SERVER_INITIAL to
QUIC_HS_ST_COMPLETE without transition to QUIC_HS_ST_SERVER_HANDSHAKE state.
This latter state is not mandatory.

3 years agoMINOR: quic: Wrong flags handling for acks
Frédéric Lécaille [Thu, 19 Aug 2021 13:19:09 +0000 (15:19 +0200)] 
MINOR: quic: Wrong flags handling for acks

Fixes several concurrent accesses issue regarding QUIC_FL_PKTNS_ACK_RECEIVED and
QUIC_FL_PKTNS_ACK_REQUIRED flags.

3 years agoMINOR: quic: Coalesce Application level packets with Handshake packets.
Frédéric Lécaille [Thu, 19 Aug 2021 05:53:27 +0000 (07:53 +0200)] 
MINOR: quic: Coalesce Application level packets with Handshake packets.

This simple enable use to coalesce Application level packet with
Handshake ones at the end of the handshake. This is highly useful
if we do want to send a short Handshake packet followed by Application
level ones.

3 years agoMINOR: quic: Missing QUIC encryption level for qc_build_pkt()
Frédéric Lécaille [Thu, 19 Aug 2021 05:33:08 +0000 (07:33 +0200)] 
MINOR: quic: Missing QUIC encryption level for qc_build_pkt()

qc_build_pkt() has recently been modified to support any type of
supported frame at any encryption level (assuming that an encryption level does
not support any type of frame) but quic_tls_level_pkt_type()
prevented it from building application level packet type because it was written
only for the handshake.
This patch simply adds the remaining encryption level QUIC_TLS_ENC_LEVEL_APP
which must be supported by quic_tls_level_pkt_type().

3 years agoMINOR: quic: Atomically get/set the connection state
Frédéric Lécaille [Wed, 18 Aug 2021 07:16:01 +0000 (09:16 +0200)] 
MINOR: quic: Atomically get/set the connection state

As ->state quic_conn struct member field is shared between threads
we must atomically get and set its value.

3 years agoMINOR: quic: Fix handshake state debug strings
Frédéric Lécaille [Wed, 18 Aug 2021 07:10:48 +0000 (09:10 +0200)] 
MINOR: quic: Fix handshake state debug strings

There was a collision between QUIC_HS_ST_CLIENT_HANDSHAKE_FAILED
and QUIC_HS_ST_CONFIRMED states.

3 years agoMINOR: quic: Update the TLS extension for QUIC transport parameters
Frédéric Lécaille [Mon, 16 Aug 2021 15:08:26 +0000 (17:08 +0200)] 
MINOR: quic: Update the TLS extension for QUIC transport parameters

0xffa5 value was a draft one. Let's update this extension to the one
defined by the QUIC-TLS RFC 9001.
(See https://www.rfc-editor.org/rfc/rfc9001.html#name-quic-transport-parameters-e).

3 years agoMINOR: quic: Evaluate the packet lengths in advance
Frédéric Lécaille [Mon, 16 Aug 2021 10:06:46 +0000 (12:06 +0200)] 
MINOR: quic: Evaluate the packet lengths in advance

We must evaluate the packet lenghts in advance to be sure we do not
consume a packet number for nothing. The packet building must always
succeeds. This is the role of qc_eval_pkt() implemented by this patch
called before calling qc_do_build_pkt() which was previously modified to
always succeed.

3 years agoMINOR: quic: Missing acks encoded size updates.
Frédéric Lécaille [Tue, 10 Aug 2021 07:54:03 +0000 (09:54 +0200)] 
MINOR: quic: Missing acks encoded size updates.

There were cases where the encoded size of acks was not updated leading
to ACK frames building too big compared to the expected size. At this
time, this makes the code "BUG_ON()".

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.