Commit Graph

15546 Commits

Author SHA1 Message Date
Frédéric Lécaille
b9c06fbe52 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
48fc74af64 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
d4d6aa7b5c 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
2fc76cffaf 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
2766e78f3b 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.
2021-09-23 15:27:25 +02:00
Amaury Denoyelle
42bb8aac65 MINOR: h3/mux: detect fin on last h3 frame of the stream 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
8e2a998b17 MINOR: h3: send htx data 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
15b096180d MINOR: h3: encode htx headers to QPACK 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
e0930fcb07 MINOR: qpack: encode headers functions 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
4652a59255 MINOR: qpack: create qpack-enc module 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
aeb36f0215 MINOR: mux-quic: define FIN stream flag 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
26dfd90eb0 MINOR: h3: define snd_buf callback and divert mux ops 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
7b1d3d6d3d MINOR: mux-quic: send SETTINGS on uni stream 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
f52151d83e MEDIUM: mux-quic: implement ring buffer on stream tx 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
990435561b MINOR: h3: allocate stream on headers 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
b49fa1aa6d MINOR: h3: parse headers to htx 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
fd7cdc3e70 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
2021-09-23 15:27:25 +02:00
Amaury Denoyelle
484317e5e8 MINOR: qpack: fix wrong comment 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
7a4f0d85be MINOR: quic-enc: fix varint encoding 2021-09-23 15:27:25 +02:00
Amaury Denoyelle
3394939475 MINOR: h3: change default settings
In particular, advertise a 0-length dynamic table for QPACK.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
a5b1b894c6 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
f4c5c7bdbb MINOR: quic: Wrong short packet minimum length
There is no destination connection ID length field in the short packet header.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
ca9d32c785 MINOR: quic: Wrong STREAM frame length computing
The ->len and ->offset field of STREAM frame are optional.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
e16f0bd1e3 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
4bade77bf9 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
f798096412 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
754f99e995 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
67f47d0125 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
d067088695 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
31550afe06 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().
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
eed7a7d73b 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
ee57444382 MINOR: quic: Fix handshake state debug strings
There was a collision between QUIC_HS_ST_CLIENT_HANDSHAKE_FAILED
and QUIC_HS_ST_CONFIRMED states.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
2e459a83d6 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).
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
4436cb6606 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
82b8652ac6 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()".
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
8b19a9f162 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".
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
dbe25afbe6 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
a2e954a817 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
9445abc013 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!
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
5d00b2d7b1 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().
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
f252adb368 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
a7348f6f85 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
91ae7aa7ec 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
0ac3851f14 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
59b07c737b MINOR: quic: Atomically handle packet number space ->largest_acked_pn variable
Protect this variable (largest acked packet number) from any concurrent access.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
e1aa0d347a 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).
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
0e50e1b0b5 MINOR: quic: Add the packet type to quic_tx_packet struct
This is required to build packets from the same function.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
522c65ce39 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.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
546186b1cf MINOR: quic: Add the QUIC connection state to traces
This connection variable was missing. It is useful to debug issues.
2021-09-23 15:27:25 +02:00
Frédéric Lécaille
db2a7649a9 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.
2021-09-23 15:27:25 +02:00