summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)AuthorFilesLines
2022-02-09QUIC: fixed in-flight bytes accounting.Vladimir Homutov1-1/+0
Initially, frames are genereated and stored in ctx->frames. Next, ngx_quic_output() collects frames to be sent in in ctx->sending. On failure, ngx_quic_revert_sned() returns frames into ctx->frames. On success, the ngx_quic_commit_send() moves ack-eliciting frames into ctx->sent and frees non-ack-eliciting frames. This function also updates in-flight bytes counter, so only actually sent frames are accounted. The counter is decremented in the following cases: - acknowledgment is received - packet was declared lost - we are discarding context completely In each of this cases frame is removed from ctx->sent queue and in-flight counter is accordingly decremented. The patch fixes the case of discarding context - only removing frames from ctx->sent must be followed by in-flight bytes counter decrement, otherwise cg->in_flight could experience type underflow. The issue appeared in b1676cd64dc9.
2022-02-09QUIC: fixed output context restoring.Vladimir Homutov1-1/+1
The cd8018bc81a5 fixed unintended send of non-padded initial packets, but failed to restore context properly: only processed contexts need to be restored. As a consequence, a packet number could be restored from uninitialized value.
2022-02-09QUIC: fixed resetting stream wev->ready flag.Roman Arutyunyan1-1/+1
Previously, the flag could be reset after send_chain() with a limit, even though there was room for more data. The application then started waiting for a write event notification, which never happened. Now the wev->ready flag is only reset when flow control is exhausted.
2022-02-08QUIC: fixed the "quic_stream_buffer_size" directive.Vladimir Homutov1-0/+4
The default value is now correctly set and the configuration is properly merged.
2022-02-03QUIC: switch stream to DATA_RECVD state.Roman Arutyunyan2-2/+12
The switch happens when received byte counter reaches stream final size. Previously, this state was skipped. The stream went from SIZE_KNOWN to DATA_READ when all bytes were read by application. The change prevents STOP_SENDING frames from being sent when all data is received from client, but not yet fully read by application.
2022-02-03QUIC: improved size calculation in ngx_quic_write_chain().Roman Arutyunyan1-4/+4
Previously, size was calculated based on the number of input bytes processed by the function. Now only the copied bytes are considered. This prevents overlapping buffers from contributing twice to the overall written size.
2022-02-02QUIC: do not arm loss detection timer if nothing was sent.Sergey Kandaurov1-1/+6
Notably, this became quite practicable after the recent fix in cd8018bc81a5. Additionally, do not arm loss detection timer on connection termination.
2022-02-02QUIC: fixed padding of initial packets in case of limited path.Vladimir Homutov1-1/+8
Previously, non-padded initial packet could be sent as a result of the following situation: - initial queue is not empty (so padding to 1200 is required) - handshake queue is not empty (so padding is to be added after h/s packet) - path is limited If serializing handshake packet would violate path limit, such packet was omitted, and the non-padded initial packet was sent. The fix is to avoid sending the packet at all in such case. This follows the original intention introduced in c5155a0cb12f.
2022-02-01QUIC: do not declare SSL buffering, it's not used.Sergey Kandaurov1-1/+1
No functional changes.
2022-02-01QUIC: improved debug logging.Vladimir Homutov1-21/+22
- wording in log->action is adjusted to match function names. - connection close steps are made obvious and start with "quic close" prefix: *1 quic close initiated rc:-4 *1 quic close silent drain:0 timedout:1 *1 quic close resumed rc:-1 *1 quic close resumed rc:-1 *1 quic close resumed rc:-4 *1 quic close completed this makes it easy to understand if particular "close" record is an initial cause or lasting process, or the final one. - cases of close without quic connection now logged as "packet rejected": *14 quic run *14 quic packet rx long flags:ec version:1 *14 quic packet rx hs len:61 *14 quic packet rx dcid len:20 00000000000002c32f60e4aa2b90a64a39dc4228 *14 quic packet rx scid len:8 81190308612cd019 *14 quic expected initial, got handshake *14 quic packet done rc:-1 level:hs decr:0 pn:0 perr:0 *14 quic packet rejected rc:-1, cleanup connection *14 reusable connection: 0 this makes it easy to spot early packet rejection and avoid confuse with quic connection closing (which in fact was not even created). - packet processing summary now uses same prefix "quic packet done rc:" - added debug to places where packet was rejected without any reason logged
2022-01-28QUIC: got rid of hash symbol in backup and logging.Vladimir Homutov4-15/+15
Now all objectes with sequence number (i.e. sockets, connection ids and paths) are logged as "foo seq:N".
2022-02-01QUIC: dead code removed.Vladimir Homutov2-5/+5
The ngx_quic_parse_packet() now returns NGX_OK, NGX_ERROR (parsing failed) and NGX_ABORT (unsupported version).
2022-02-01QUIC: merged ngx_quic_close_quic() and ngx_quic_close_connection().Vladimir Homutov1-37/+26
The separate ngx_quic_close_quic() doesn't make much sense.
2022-02-01QUIC: revised ngx_quic_handle_datagram() error codes.Vladimir Homutov2-16/+7
The NGX_DECLINED is replaced with NGX_DONE to match closer to return code of ngx_quic_handle_packet() and ngx_quic_close_connection() rc argument. The ngx_quic_close_connection() rc code is used only when quic connection exists, thus anything goes if qc == NULL. The ngx_quic_handle_datagram() does not return NG_OK in cases when quic connection is not yet created.
2022-01-26QUIC: stream event setting function.Roman Arutyunyan1-52/+21
The function ngx_quic_set_event() is now called instead of posting events directly.
2022-01-31QUIC: style.Roman Arutyunyan1-35/+35
2022-01-31HTTP/3: proper uni stream closure detection.Roman Arutyunyan1-5/+34
Previously, closure detection for server-initiated uni streams was not properly implemented. Instead, HTTP/3 code relied on QUIC code posting the read event and setting rev->error when it needed to close the stream. Then, regular uni stream read handler called c->recv() and received error, which closed the stream. This was an ad-hoc solution. If, for whatever reason, the read handler was called earlier, c->recv() would return 0, which would also close the stream. Now server-initiated uni streams have a separate read event handler for tracking stream closure. The handler calls c->recv(), which normally returns 0, but may return error in case of closure.
2022-01-31QUIC: introduced explicit stream states.Roman Arutyunyan3-75/+117
This allows to eliminate the usage of stream connection event flags for tracking stream state.
2022-01-27HTTP/3: delayed Insert Count Increment instruction.Roman Arutyunyan4-4/+60
Sending the instruction is delayed until the end of the current event cycle. Delaying the instruction is allowed by quic-qpack-21, section 2.2.2.3. The goal is to reduce the amount of data sent back to client by accumulating several inserts in one instruction and sometimes not sending the instruction at all, if Section Acknowledgement was sent just before it.
2022-01-31QUIC: allowed main QUIC connection for some operations.Roman Arutyunyan3-9/+13
Operations like ngx_quic_open_stream(), ngx_http_quic_get_connection(), ngx_http_v3_finalize_connection(), ngx_http_v3_shutdown_connection() used to receive a QUIC stream connection. Now they can receive the main QUIC connection as well. This is useful when calling them from a stream context.
2022-01-27QUIC: limited SSL_set_quic_use_legacy_codepoint() API usage.Sergey Kandaurov1-1/+1
As advertised in BoringSSL a1d3bfb64fd7ef2cb178b5b515522ffd75d7b8c5, it may be dropped once callers implementing the draft versions cycle out.
2022-01-26QUIC: style.Roman Arutyunyan1-2/+0
2022-01-26QUIC: fixed handling of initial source connection id.Vladimir Homutov2-7/+3
This was broken in 1e2f4e9c8195. While there, adjusted formatting of debug message with socket seqnum.
2022-01-26README: updated link to nginx-devel mailman.Sergey Kandaurov1-1/+1
2022-01-26README: updated info about incomplete features.Sergey Kandaurov1-15/+0
2022-01-26README: updated to QUICv1.Sergey Kandaurov1-17/+4
While here, removed old browsers tips.
2022-01-26QUIC: set to standard TLS codepoint after draft versions removal.Sergey Kandaurov1-1/+1
This is to ease transition with oldish BoringSSL versions, the default for SSL_set_quic_use_legacy_codepoint() has been flipped in BoringSSL a1d3bfb64fd7ef2cb178b5b515522ffd75d7b8c5.
2022-01-26QUIC: removed draft versions support.Sergey Kandaurov5-24/+7
2022-01-26HTTP/3: removed draft versions support in ALPN.Sergey Kandaurov4-31/+0
2022-01-21QUIC: changed debug message.Roman Arutyunyan1-1/+1
2022-01-25Merged with the default branch.Sergey Kandaurov10-18/+136
2022-01-25release-1.21.6 tagMaxim Dounin1-0/+1
2022-01-25nginx-1.21.6-RELEASErelease-1.21.6Maxim Dounin1-0/+38
2022-01-25QUIC: fixed macro style.Vladimir Homutov2-7/+7
2022-01-25QUIC: fixed chain returned from ngx_quic_write_chain().Roman Arutyunyan1-2/+4
Previously, when input ended on a QUIC buffer boundary, input chain was not advanced to the next buffer. As a result, ngx_quic_write_chain() returned a chain with an empty buffer instead of NULL. This broke HTTP write filter, preventing it from closing the HTTP request and eventually timing out. Now input chain is always advanced to a buffer that has data, before checking QUIC buffer boundary condition.
2022-01-24SSL: always renewing tickets with TLSv1.3 (ticket #1892).Maxim Dounin1-1/+15
Chrome only uses TLS session tickets once with TLS 1.3, likely following RFC 8446 Appendix C.4 recommendation. With OpenSSL, this works fine with built-in session tickets, since these are explicitly renewed in case of TLS 1.3 on each session reuse, but results in only two connections being reused after an initial handshake when using ssl_session_ticket_key. Fix is to always renew TLS session tickets in case of TLS 1.3 when using ssl_session_ticket_key, similarly to how it is done by OpenSSL internally.
2022-01-22Contrib: vim syntax adjusted to save cpoptions (ticket #2276).Maxim Dounin1-0/+6
Line continuation as used in the syntax file might be broken if "compatible" is set or "C" is added to cpoptions. Fix is to set the "cpoptions" option to vim default value at script start and restore it later, see ":help use-cpo-save".
2022-01-21QUIC: removed stale declaration.Vladimir Homutov1-1/+0
The ngx_quic_get_unconnected_socket() was removed in 1e2f4e9c8195.
2022-01-23QUIC: avoid logging error in case of version negotiation.Vladimir Homutov1-1/+1
Previously, "early error" message was logged in this case.
2022-01-20QUIC: additional limit for probing packets.Vladimir Homutov1-0/+11
RFC 9000, 9.3. Responding to Connection Migration: An endpoint only changes the address to which it sends packets in response to the highest-numbered non-probing packet. The patch extends this requirement to probing packets. Although it may seem excessive, it helps with mitigation of reply attacks (when an off-path attacker has copied packet with PATH_CHALLENGE and uses different addresses to exhaust available connection ids).
2022-01-19Core: simplify reader lock release.Pavel Pautov1-15/+3
2022-01-19QUIC: reworked migration handling.Vladimir Homutov11-564/+351
The quic connection now holds active, backup and probe paths instead of sockets. The number of migration paths is now limited and cannot be inflated by a bad client or an attacker. The client id is now associated with path rather than socket. This allows to simplify processing of output and connection ids handling. New migration abandons any previously started migrations. This allows to free consumed client ids and request new for use in future migrations and make progress in case when connection id limit is hit during migration. A path now can be revalidated without losing its state. The patch also fixes various issues with NAT rebinding case handling: - paths are now validated (previously, there was no validation and paths were left in limited state) - attempt to reuse id on different path is now again verified (this was broken in 40445fc7c403) - former path is now validated in case of apparent migration
2022-01-18QUIC: the "quic_active_connection_id_limit" directive.Vladimir Homutov4-1/+27
The directive sets corresponding transport parameter and limits number of created client ids.
2022-01-17SSL: free pkey on SSL_CTX_set0_tmp_dh_pkey() failure.Sergey Kandaurov1-0/+3
The behaviour was changed in OpenSSL 3.0.1: https://git.openssl.org/?p=openssl.git;a=commitdiff;h=bf17b7b
2022-01-17QUIC: introduced function ngx_quic_split_chain().Roman Arutyunyan1-47/+44
The function splits a buffer at given offset. The function is now called from ngx_quic_read_chain() and ngx_quic_write_chain(), which simplifies both functions.
2022-01-16QUIC: fixed format specifier after 3789f4a56d65.Roman Arutyunyan1-1/+1
2022-01-13QUIC: return written size from ngx_quic_write_chain().Roman Arutyunyan4-17/+16
This allows to escape calculating it before calling the function.
2022-01-13README: documented QuicTLS support.Sergey Kandaurov1-3/+10
2022-01-13QUIC: removed ngx_send_lowat() check for QUIC connections.Sergey Kandaurov1-6/+0
After 9ae239d2547d, ngx_quic_handle_write_event() no longer runs into ngx_send_lowat() for QUIC connections, so the check became excessive. It is assumed that external modules operating with SO_SNDLOWAT (I'm not aware of any) should do this check on their own.
2022-01-13HTTP/3: removed useless warning regarding OpenSSL library.Sergey Kandaurov1-11/+0
After 0e6528551f26, it became impossible to run into this path.