summaryrefslogtreecommitdiffhomepage
path: root/src/event/quic (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-05-11QUIC: removed "quic_mtu" directive.Roman Arutyunyan2-2/+1
The directive used to set the value of the "max_udp_payload_size" transport parameter. According to RFC 9000, Section 18.2, the value specifies the size of buffer for reading incoming datagrams: This limit does act as an additional constraint on datagram size in the same way as the path MTU, but it is a property of the endpoint and not the path; see Section 14. It is expected that this is the space an endpoint dedicates to holding incoming packets. Current QUIC implementation uses the maximum possible buffer size (65527) for reading datagrams.
2023-05-11QUIC: resized input datagram buffer from 65535 to 65527.Roman Arutyunyan1-1/+1
The value of 65527 is the maximum permitted UDP payload size.
2023-05-11QUIC: keep stream sockaddr and addr_text constant.Roman Arutyunyan1-2/+29
HTTP and Stream variables $remote_addr and $binary_remote_addr rely on constant client address, particularly because they are cacheable. However, QUIC client may migrate to a new address. While there's no perfect way to handle this, the proposed solution is to copy client address to QUIC stream at stream creation. The change also fixes truncated $remote_addr if migration happened while the stream was active. The reason is addr_text string was copied to stream by value.
2023-04-27QUIC: set c->socklen for streams.Roman Arutyunyan1-0/+1
Previously, the value was not set and remained zero. While in nginx code the value of c->sockaddr is accessed without taking c->socklen into account, invalid c->socklen could lead to unexpected results in third-party modules.
2023-04-27QUIC: fixed addr_text after migration (ticket #2488).Roman Arutyunyan1-6/+3
Previously, the post-migration value of addr_text could be truncated, if it was longer than the previous one. Also, the new value always included port, which should not be there.
2023-05-09QUIC: reschedule path validation on path insertion/removal.Sergey Kandaurov1-3/+45
Two issues fixed: - new path validation could be scheduled late - a validated path could leave a spurious timer
2023-05-09QUIC: lower bound path validation PTO.Sergey Kandaurov1-2/+2
According to RFC 9000, 8.2.4. Failed Path Validation, the following value is recommended as a validation timeout: A value of three times the larger of the current PTO or the PTO for the new path (using kInitialRtt, as defined in [QUIC-RECOVERY]) is RECOMMENDED. The change adds PTO of the new path to the equation as the lower bound.
2023-05-09QUIC: separated path validation retransmit backoff.Sergey Kandaurov2-7/+10
Path validation packets containing PATH_CHALLENGE frames are sent separately from regular frame queue, because of the need to use a decicated path and pad the packets. The packets are sent periodically, separately from the regular probe/lost detection mechanism. A path validation packet is resent up to 3 times, each time after PTO expiration, with increasing per-path PTO backoff.
2023-05-09QUIC: removed check for in-flight packets in computing PTO.Sergey Kandaurov1-5/+1
The check is needed for clients in order to unblock a server due to anti-amplification limits, and it seems to make no sense for servers. See RFC 9002, A.6 and A.8 for a further explanation. This makes max_ack_delay to now always account, notably including PATH_CHALLENGE timers as noted in the last paragraph of 9000, 9.4, unlike when it was only used when there are packets in flight. While here, fixed nearby style.
2023-05-04QUIC: fixed encryption level in ngx_quic_frame_sendto().Roman Arutyunyan1-1/+1
Previously, ssl_encryption_application was hardcoded. Before 9553eea74f2a, ngx_quic_frame_sendto() was used only for PATH_CHALLENGE/PATH_RESPONSE sent at the application level only. Since 9553eea74f2a, ngx_quic_frame_sendto() is also used for CONNECTION_CLOSE, which can be sent at initial level after SSL handshake error or rejection. This resulted in packet encryption error. Now level is copied from frame, which fixes the error.
2023-05-02QUIC: optimized immediate close.Roman Arutyunyan2-15/+11
Previously, before sending CONNECTION_CLOSE to client, all pending frames were sent. This is redundant and could prevent CONNECTION_CLOSE from being sent due to congestion control. Now pending frames are freed and CONNECTION_CLOSE is sent without congestion control, as advised by RFC 9002: Packets containing frames besides ACK or CONNECTION_CLOSE frames count toward congestion control limits and are considered to be in flight.
2023-05-04QUIC: fixed split frames error handling.Sergey Kandaurov1-2/+5
Do not corrupt frame data chain pointer on ngx_quic_read_buffer() error. The error leads to closing a QUIC connection where the frame may be used as part of the QUIC connection tear down, which envolves writing pending frames, including this one.
2023-04-03QUIC: optimized sending stream response.Roman Arutyunyan1-0/+11
When a stream is created by client, it's often the case that nginx will send immediate response on that stream. An example is HTTP/3 request stream, which in most cases quickly replies with at least HTTP headers. QUIC stream init handlers are called from a posted event. Output QUIC frames are also sent to client from a posted event, called the push event. If the push event is posted before the stream init event, then output produced by stream may trigger sending an extra UDP datagram. To address this, push event is now re-posted when a new stream init event is posted. An example is handling 0-RTT packets. Client typically sends an init packet coalesced with a 0-RTT packet. Previously, nginx replied with a padded CRYPTO datagram, followed by a 1-RTT stream reply datagram. Now CRYPTO and STREAM packets are coalesced in one reply datagram, which saves bandwidth. Other examples include coalescing 1-RTT first stream response, and MAX_STREAMS/STREAM sent in response to ACK/STREAM.
2023-03-15QUIC: style.Roman Arutyunyan1-1/+1
2023-02-22QUIC: OpenSSL compatibility layer.Roman Arutyunyan6-46/+766
The change allows to compile QUIC with OpenSSL which lacks BoringSSL QUIC API. This implementation does not support 0-RTT.
2023-02-23QUIC: improved ssl_reject_handshake error logging.Sergey Kandaurov1-0/+8
The check follows the ngx_ssl_handshake() change in 59e1c73fe02b.
2023-02-23QUIC: using ngx_ssl_handshake_log().Sergey Kandaurov1-5/+3
2023-02-23QUIC: moved "handshake failed" reason to send_alert.Sergey Kandaurov1-1/+1
A QUIC handshake failure breaks down into several cases: - a handshake error which leads to a send_alert call - an error triggered by the add_handshake_data callback - internal errors (allocation etc) Previously, in the first case, only error code was set in the send_alert callback. Now the "handshake failed" reason phrase is set there as well. In the second case, both code and reason are set by add_handshake_data. In the last case, setting reason phrase is removed: returning NGX_ERROR now leads to closing the connection with just INTERNAL_ERROR. Reported by Jiuzhou Cui.
2023-02-23QUIC: using NGX_QUIC_ERR_CRYPTO macro in ALPN checks.Sergey Kandaurov1-1/+1
Patch by Jiuzhou Cui.
2023-02-13QUIC: fixed indentation.Sergey Kandaurov2-3/+3
2023-01-31QUIC: fixed broken token in NEW_TOKEN (ticket #2446).Roman Arutyunyan4-8/+34
Previously, since 3550b00d9dc8, the token was allocated on stack, to get rid of pool usage. Now the token is allocated by ngx_quic_copy_buffer() in QUIC buffers, also used for STREAM, CRYPTO and ACK frames.
2023-01-31QUIC: ngx_quic_copy_buffer() function.Roman Arutyunyan3-21/+37
The function copies passed data to QUIC buffer chain and returns it. The chain can be used in ngx_quic_frame_t data field.
2023-01-18QUIC: defer setting the active flag for client stream events.Sergey Kandaurov1-18/+21
Specifically, now it is kept unset until streams are initialized. Notably, this unbreaks OCSP with client certificates after 35e27117b593. Previously, the read event could be posted prematurely via ngx_quic_set_event() e.g., as part of handling a STREAM frame.
2023-01-10QUIC: relocated ngx_quic_init_streams() for 0-RTT.Roman Arutyunyan1-13/+9
Previously, streams were initialized in early keys handler. However, client transport parameters may not be available by then. This happens, for example, when using QuicTLS. Now streams are initialized in ngx_quic_crypto_input() after calling SSL_do_handshake() for both 0-RTT and 1-RTT.
2023-01-10QUIC: set stream error flag on reset.Roman Arutyunyan1-2/+12
Now, when RESET_STREAM is sent or received, or when streams are closed, stream connection error flag is set. Previously, only stream state was changed, which resulted in setting the error flag only after calling recv()/send()/send_chain(). However, there are cases when none of these functions is called, but it's still important to know if the stream is being closed. For example, when an HTTP/3 request stream is blocked on insert count, receiving RESET_STREAM should trigger stream closure, which was not the case. The change also fixes ngx_http_upstream_check_broken_connection() and ngx_http_test_reading() with QUIC streams.
2023-01-10QUIC: automatically add and never delete stream events.Roman Arutyunyan2-30/+7
Previously, stream events were added and deleted by ngx_handle_read_event() and ngx_handle_write_event() in a way similar to level-triggered events. However, QUIC stream events are effectively edge-triggered and can stay active all time. Moreover, the events are now active since the moment a stream is created.
2023-01-10HTTP/3: fixed $connection_time.Sergey Kandaurov1-0/+1
Previously, start_time wasn't set for a new stream. The fix is to derive it from the parent connection. Also it's used to simplify tracking keepalive_time.
2023-01-02Merged with the default branch.Sergey Kandaurov1-1/+1
2022-11-30QUIC: application init() callback.Roman Arutyunyan2-3/+21
It's called after handshake completion or prior to the first early data stream creation. The callback should initialize application-level data before creating streams. HTTP/3 callback implementation sets keepalive timer and sends SETTINGS. Also, this allows to limit max handshake time in ngx_http_v3_init_stream().
2022-11-30QUIC: removed cancelable flag from QUIC and HTTP/3 events.Roman Arutyunyan1-4/+0
All these events are created in context of a client connection and are deleted when the connection is closed. Setting ev->cancelable could trigger premature connection closure and a socket leak alert.
2022-10-19QUIC: idle mode for main connection.Roman Arutyunyan2-3/+19
Now main QUIC connection for HTTP/3 always has c->idle flag set. This allows the connection to receive worker shutdown notification. It is passed to application level via a new conf->shutdown() callback. The HTTP/3 shutdown callback sends GOAWAY to client and gracefully shuts down the QUIC connection.
2022-09-07QUIC: do not send MAX_STREAMS in shutdown state.Roman Arutyunyan1-8/+9
No more streams are expected from client.
2022-08-22QUIC: defer stream removal until all its data is acked.Roman Arutyunyan3-23/+64
Previously, stream was kept alive until all its data is sent. This resulted in disabling retransmission of final part of stream when QUIC connection was closed right after closing stream connection.
2022-11-29QUIC: reusable mode for main connection.Roman Arutyunyan3-52/+98
The connection is automatically switched to this mode by transport layer when there are no non-cancelable streams. Currently, cancelable streams are HTTP/3 encoder/decoder/control streams.
2022-09-07QUIC: post close event for connection close.Roman Arutyunyan2-23/+26
Previously, close event was used only for close timeout, while read event was used for posting connection close.
2022-08-22QUIC: made ngx_quic_finalize_connecion() more graceful.Roman Arutyunyan1-18/+14
Previously, ngx_quic_finalize_connection() closed the connection with NGX_ERROR code, which resulted in immediate connection closure. Now the code is NGX_OK, which provides a more graceful shutdown with a timeout.
2022-09-07QUIC: treat qc->error == -1 as a missing error.Roman Arutyunyan1-3/+3
Previously, zero was used for this purpose. However, NGX_QUIC_ERR_NO_ERROR is zero too. As a result, NGX_QUIC_ERR_NO_ERROR was changed to NGX_QUIC_ERR_INTERNAL_ERROR when closing a QUIC connection.
2022-11-25QUIC: fixed computation of nonce with packet numbers beyond 2^32.Sergey Kandaurov1-4/+8
Prodded by Yu Zhu.
2022-11-23QUIC: fixed triggering stream read event (ticket #2409).Roman Arutyunyan1-1/+1
If a client packet carrying a stream data frame is not acked due to packet loss, the stream data is retransmitted later by client. It's also possible that the retransmitted range is bigger than before due to more stream data being available by then. If the original data was read out by the application, there would be no read event triggered by the retransmitted frame, even though it contains new data.
2022-11-22QUIC: fixed C4334 MSVC warning about 32 to 64 bits conversion.Sergey Kandaurov1-1/+1
2022-11-22QUIC: plug MSVC warning about potentially uninitialized variable.Sergey Kandaurov1-0/+4
2022-11-22QUIC: fixed C4389 MSVC warning about signed/unsigned mismatch.Sergey Kandaurov1-1/+2
2022-11-22QUIC: avoid using C99 designated initializers.Sergey Kandaurov2-24/+23
They are not supported by MSVC till 2012. SSL_QUIC_METHOD initialization is moved to run-time to preserve portability among SSL library implementations, which allows to reduce its visibility. Note using of a static storage to keep SSL_set_quic_method() reference valid.
2022-11-22QUIC: moved variable declaration to fix build with MSVC 2010.Sergey Kandaurov1-36/+32
Previously, ngx_quic_hkdf_t variables used declaration with assignment in the middle of a function, which is not supported by MSVC 2010. Fixing this also required to rewrite the ngx_quic_hkdf_set macro and to switch to an explicit array size.
2022-11-22QUIC: fixed C4706 warnings with MSVC 2010.Sergey Kandaurov1-16/+44
The fix is to avoid assignments within conditional expression.
2022-10-20QUIC: removed compatibility with older BoringSSL API.Sergey Kandaurov1-8/+4
SSL_CIPHER_get_protocol_id() appeared in BoringSSL somewhere between BORINGSSL_API_VERSION 12 and 13 for compatibility with OpenSSL 1.1.1. It was adopted without a proper macro test, which remained unnoticed. This justifies that such old BoringSSL API isn't widely used and its support can be dropped. While here, removed SSL_set_quic_use_legacy_codepoint() that became useless after the default was flipped in BoringSSL over a year ago.
2022-10-20QUIC: support for setting QUIC methods with LibreSSL.Sergey Kandaurov1-9/+9
Setting QUIC methods is converted to use C99 designated initializers for simplicity, as LibreSSL 3.6.0 has different SSL_QUIC_METHOD layout. Additionally, only set_read_secret/set_write_secret callbacks are set. Although they are preferred in LibreSSL over set_encryption_secrets, better be on a safe side as LibreSSL has unexpectedly incompatible set_encryption_secrets calling convention expressed in passing read and write secrets split in separate calls, unlike this is documented in old BoringSSL sources. To avoid introducing further changes for the old API, it is simply disabled.
2022-10-20QUIC: using SSL_set_quic_early_data_enabled() only with QuicTLS.Sergey Kandaurov1-1/+1
This function is present in QuicTLS only. After SSL_READ_EARLY_DATA_SUCCESS became visible in LibreSSL together with experimental QUIC API, this required to revise the conditional compilation test to use more narrow macros.
2022-10-20QUIC: using native TLSv1.3 cipher suite constants.Sergey Kandaurov1-8/+11
After BoringSSL aligned[1] with OpenSSL on TLS1_3_CK_* macros, and LibreSSL uses OpenSSL naming, our own variants can be dropped now. Compatibility is preserved with libraries that lack these macros. Additionally, transition to SSL_CIPHER_get_id() fixes build error with LibreSSL that doesn't implement SSL_CIPHER_get_protocol_id(). [1] https://boringssl.googlesource.com/boringssl/+/dfddbc4ded
2022-09-30QUIC: "info" logging level on insufficient client connection ids.Sergey Kandaurov1-1/+1
Apparently, this error is reported on NAT rebinding if client didn't previously send NEW_CONNECTION_ID to supply additional connection ids.