summaryrefslogtreecommitdiffhomepage
path: root/src/event/quic/ngx_event_quic.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-12-13QUIC: decoupled path state and limitation status.Vladimir Homutov1-0/+1
The path validation status and anti-amplification limit status is actually two different variables. It is possible that validating path should not be limited (for example, when re-validating former path).
2021-12-06QUIC: simplified configuration.Vladimir Homutov1-1/+4
Directives that set transport parameters are removed from the configuration. Corresponding values are derived from the quic configuration or initialized to default. Whenever possible, quic configuration parameters are taken from higher-level protocol settings, i.e. HTTP/3.
2021-11-29QUIC: fixed migration during NAT rebinding.Vladimir Homutov1-5/+12
The RFC 9000 allows a packet from known CID arrive from unknown path: These requirements regarding connection ID reuse apply only to the sending of packets, as unintentional changes in path without a change in connection ID are possible. For example, after a period of network inactivity, NAT rebinding might cause packets to be sent on a new path when the client resumes sending. Before the patch, such packets were rejected with an error in the ngx_quic_check_migration() function. Removing the check makes the separate function excessive - remaining checks are early migration check and "disable_active_migration" check. The latter is a transport parameter sent to client and it should not be used by server. The server should send "disable_active_migration" "if the endpoint does not support active connection migration" (18.2). The support status depends on nginx configuration: to have migration working with multiple workers, you need bpf helper, available on recent Linux systems. The patch does not set "disable_active_migration" automatically and leaves it for the administrator. By default, active migration is enabled. RFC 900 says that it is ok to migrate if the peer violates "disable_active_migration" flag requirements: If the peer violates this requirement, the endpoint MUST either drop the incoming packets on that path without generating a Stateless Reset OR proceed with path validation and allow the peer to migrate. Generating a Stateless Reset or closing the connection would allow third parties in the network to cause connections to close by spoofing or otherwise manipulating observed traffic. So, nginx adheres to the second option and proceeds to path validation. Note: The ngtcp2 may be used for testing both active migration and NAT rebinding: ngtcp2/client --change-local-addr=200ms --delay-stream=500ms <ip> <port> <url> ngtcp2/client --change-local-addr=200ms --delay-stream=500ms --nat-rebinding \ <ip> <port> <url>
2021-11-29QUIC: refactored multiple QUIC packets handling.Vladimir Homutov1-5/+8
Single UDP datagram may contain multiple QUIC datagrams. In order to facilitate handling of such cases, 'first' flag in the ngx_quic_header_t structure is introduced.
2021-11-17QUIC: handle DATA_BLOCKED frame from client.Roman Arutyunyan1-0/+11
Previously the frame was not handled and connection was closed with an error. Now, after receiving this frame, global flow control is updated and new flow control credit is sent to client.
2021-10-13QUIC: traffic-based flood detection.Roman Arutyunyan1-5/+29
With this patch, all traffic over a QUIC connection is compared to traffic over QUIC streams. As long as total traffic is many times larger than stream traffic, we consider this to be a flood.
2021-10-12QUIC: attempt decrypt before checking for stateless reset.Martin Duke1-2/+5
Checking the reset after encryption avoids false positives. More importantly, it avoids the check entirely in the usual case where decryption succeeds. RFC 9000, 10.3.1 Detecting a Stateless Reset Endpoints MAY skip this check if any packet from a datagram is successfully processed.
2021-10-12QUIC: Check if CID has been used in stateless reset checkMartin Duke1-2/+5
Section 10.3.1 of RFC9000 requires this check.
2021-09-09QUIC: removed Firefox workaround for trailing zeroes in datagrams.Sergey Kandaurov1-5/+0
This became unnecessary after discarding invalid packets since a6784cf32c13.
2021-08-05QUIC: asynchronous shutdown.Roman Arutyunyan1-0/+4
Previously, when cleaning up a QUIC stream in shutdown mode, ngx_quic_shutdown_quic() was called, which could close the QUIC connection right away. This could be a problem if the connection was referenced up the stack. For example, this could happen in ngx_quic_init_streams(), ngx_quic_close_streams(), ngx_quic_create_client_stream() etc. With a typical HTTP/3 client the issue is unlikely because of HTTP/3 uni streams which need a posted event to close. In this case QUIC connection cannot be closed right away. Now QUIC connection read event is posted and it will shut down the connection asynchronously.
2021-08-04QUIC: client certificate validation with OCSP.Sergey Kandaurov1-0/+2
2021-07-28QUIC: handle EAGAIN properly on UDP sockets.Vladimir Homutov1-0/+1
Previously, the error was ignored leading to unnecessary retransmits. Now, unsent frames are returned into output queue, state is reset, and timer is started for the next send attempt.
2021-07-28QUIC: eliminated stream type from ngx_quic_stream_frame_t.Roman Arutyunyan1-8/+1
The information about the type is contained in off/len/fin bits. Also, where possible, only the first stream type (0x08) is used for simplicity.
2021-07-22QUIC: avoid processing 1-RTT with incomplete handshake in OpenSSL.Sergey Kandaurov1-0/+14
OpenSSL is known to provide read keys for an encryption level before the level is active in TLS, following the old BoringSSL API. In BoringSSL, it was then fixed to defer releasing read keys until QUIC may use them.
2021-06-30QUIC: consider max_ack_delay=16384 invalid.Roman Arutyunyan1-1/+1
As per RFC 9000: Values of 2^14 or greater are invalid.
2021-06-16QUIC: updated specification references.Sergey Kandaurov1-12/+18
This includes updating citations and further clarification.
2021-06-10QUIC: improved errors readability.Vladimir Homutov1-1/+2
2021-06-09QUIC: persistent congestion calculation.Vladimir Homutov1-0/+1
According to RFC 9002 (quic-recovery) 7.6.
2021-06-07QUIC: stream flow control refactored.Roman Arutyunyan1-0/+1
- Function ngx_quic_control_flow() is introduced. This functions does both MAX_DATA and MAX_STREAM_DATA flow controls. The function is called from STREAM and RESET_STREAM frame handlers. Previously, flow control was only accounted for STREAM. Also, MAX_DATA flow control was not accounted at all. - Function ngx_quic_update_flow() is introduced. This function advances flow control windows and sends MAX_DATA/MAX_STREAM_DATA. The function is called from RESET_STREAM frame handler, stream cleanup handler and stream recv() handler.
2021-05-25QUIC: refactored CRYPTO and STREAM buffer ordering.Roman Arutyunyan1-4/+2
Generic function ngx_quic_order_bufs() is introduced. This function creates and maintains a chain of buffers with holes. Holes are marked with b->sync flag. Several buffers and holes in this chain may share the same underlying memory buffer. When processing STREAM frames with this function, frame data is copied only once to the right place in the stream input chain. Previously data could be copied twice. First when buffering an out-of-order frame data, and then when filling stream buffer from ordered frame queue. Now there's only one data chain for both tasks.
2021-05-05QUIC: simplified sending 1-RTT only frames.Sergey Kandaurov1-6/+4
2021-05-06QUIC: consider NEW_CONNECTION_ID a probing frame.Vladimir Homutov1-0/+1
According to quic-transport, 9.1: PATH_CHALLENGE, PATH_RESPONSE, NEW_CONNECTION_ID, and PADDING frames are "probing frames", and all other frames are "non-probing frames".
2021-04-29QUIC: connection migration.Vladimir Homutov1-43/+75
The patch adds proper transitions between multiple networking addresses that can be used by a single quic connection. New networking paths are validated using PATH_CHALLENGE/PATH_RESPONSE frames.
2021-04-14QUIC: separate files for SSL library interfaces.Vladimir Homutov1-503/+2
2021-04-13QUIC: separate files for tokens related processing.Vladimir Homutov1-278/+0
2021-04-13QUIC: separate files for output and ack related processing.Vladimir Homutov1-1927/+3
2021-04-13QUIC: separate files for stream related processing.Vladimir Homutov1-1285/+2
2021-04-13QUIC: separate files for frames related processing.Vladimir Homutov1-909/+2
2021-04-13QUIC: separate files for connection id related processing.Vladimir Homutov1-528/+1
2021-04-14QUIC: headers cleanup.Vladimir Homutov1-4/+1
The "ngx_event_quic.h" header file now contains only public definitions, used by modules. All internal definitions are moved into the "ngx_event_quic_connection.h" header file.
2021-04-09QUIC: separate function for connection ids initialization.Vladimir Homutov1-40/+62
The function correctly cleans up resources in case of failure to create initial server id: it removes previously created udp node for odcid from listening rbtree.
2021-04-07QUIC: fixed ngx_quic_send_ack_range() function.Vladimir Homutov1-1/+6
Created frame was not added to the output queue.
2021-04-05QUIC: fixed debug message macro.Vladimir Homutov1-2/+2
2021-03-31QUIC: distinct files for connection migration.Vladimir Homutov1-48/+13
The connection migration-related code from quic.c with dependencies is moved into separate file.
2021-03-31QUIC: separate header for ngx_quic_connection_t.Vladimir Homutov1-161/+4
2021-04-02QUIC: simplified quic connection dispatching.Vladimir Homutov1-14/+15
Currently listener contains rbtree with multiple nodes for single QUIC connection: each corresponding to specific server id. Each udp node points to same ngx_connection_t, which points to QUIC connection via c->udp field. Thus when an event handler is called, it only gets ngx_connection_t with c->udp pointing to QUIC connection. This makes it hard to obtain actual node which was used to dispatch packet (it requires to repeat DCID lookup). Additionally, ngx_quic_connection_t->udp field is only needed to keep a pointer in c->udp. The node is not added into the tree and does not carry useful information.
2021-04-02UDP: extended datagram context.Vladimir Homutov1-1/+1
Sometimes it is required to process datagram properties at higher level (i.e. QUIC is interested in source address which may change and IP options). The patch adds ngx_udp_dgram_t structure used to pass packet-related information in c->udp.
2021-03-11QUIC: do not copy input data.Roman Arutyunyan1-21/+6
Previously, when a new datagram arrived, data were copied from the UDP layer to the QUIC layer via c->recv() interface. Now UDP buffer is accessed directly.
2021-03-15QUIC: connection shutdown.Roman Arutyunyan1-6/+72
The function ngx_quic_shutdown_connection() waits until all non-cancelable streams are closed, and then closes the connection. In HTTP/3 cancelable streams are all unidirectional streams except push streams. The function is called from HTTP/3 when client reaches keepalive_requests.
2021-03-16QUIC: fixed expected TLS codepoint with final draft and BoringSSL.Sergey Kandaurov1-0/+4
A reasonable codepoint is always set[1] explicitly so that it doesn't depend on the default library value that may change[2] in the future. [1] https://boringssl.googlesource.com/boringssl/+/3d8b8c3d [2] https://boringssl.googlesource.com/boringssl/+/c47bfce0
2021-02-19QUIC: multiple versions support.Sergey Kandaurov1-2/+4
Draft-29 and beyond are now supported simultaneously, no need to recompile.
2021-02-18QUIC: removed support prior to draft-29.Sergey Kandaurov1-4/+0
2021-02-18QUIC: set idle timer when sending an ack-eliciting packet.Roman Arutyunyan1-5/+9
As per quic-transport-34: An endpoint also restarts its idle timer when sending an ack-eliciting packet if no other ack-eliciting packets have been sent since last receiving and processing a packet. Previously, the timer was set for any packet.
2021-02-17QUIC: added ability to reset a stream.Sergey Kandaurov1-0/+40
2021-02-15QUIC: fixed indentation.Sergey Kandaurov1-15/+14
2021-02-15QUIC: added check of client transport parameters.Vladimir Homutov1-36/+86
Parameters sent by client are verified and defaults are set for parameters omitted by client.
2021-02-12QUIC: send PING frames on PTO expiration.Roman Arutyunyan1-10/+72
Two PING frames are sent per level that generate two UDP datagrams.
2021-02-12QUIC: improved setting the lost timer.Roman Arutyunyan1-25/+85
Setting the timer is brought into compliance with quic-recovery-34. Now it's set from a single function ngx_quic_set_lost_timer() that takes into account both loss detection and PTO. The following issues are fixed with this change: - when in loss detection mode, discarding a context could turn off the timer forever after switching to the PTO mode - when in loss detection mode, sending a packet resulted in rescheduling the timer as if it's always in the PTO mode
2021-02-04QUIC: disabled non-immediate ACKs for Initial and Handshake.Roman Arutyunyan1-2/+5
As per quic-transport-33: An endpoint MUST acknowledge all ack-eliciting Initial and Handshake packets immediately If a packet carrying Initial or Handshake ACK was lost, a non-immediate ACK should not be sent later. Instead, client is expected to send a new packet to acknowledge. Sending non-immediate ACKs for Initial packets can cause the client to generate an inflated RTT sample.
2021-02-09QUIC: fixed logging ACK frames.Roman Arutyunyan1-1/+1
Previously, the wrong end pointer was used, which could lead to errors "quic failed to parse ack frame gap".