summaryrefslogtreecommitdiffhomepage
path: root/src/event (follow)
AgeCommit message (Collapse)AuthorFilesLines
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-20Merged with the default branch.Sergey Kandaurov3-135/+354
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.
2022-08-09SSL: logging level of "bad record type" errors.Murilo Andrade1-0/+3
The SSL_R_BAD_RECORD_TYPE ("bad record type") errors are reported by OpenSSL 1.1.1 or newer when using TLSv1.3 if the client sends a record with unknown or unexpected type. These errors are now logged at the "info" level.
2022-07-12SSL: logging levels of various errors added in OpenSSL 1.1.1.Maxim Dounin1-0/+12
Starting with OpenSSL 1.1.1, various additional errors can be reported by OpenSSL in case of client-related issues, most notably during TLSv1.3 handshakes. In particular, SSL_R_BAD_KEY_SHARE ("bad key share"), SSL_R_BAD_EXTENSION ("bad extension"), SSL_R_BAD_CIPHER ("bad cipher"), SSL_R_BAD_ECPOINT ("bad ecpoint"). These are now logged at the "info" level.
2022-05-31QUIC: avoided pool usage in token calculation.Vladimir Homutov4-20/+32
2022-07-27QUIC: removed ngx_quic_keys_new().Vladimir Homutov4-51/+44
The ngx_quic_keys_t structure is now exposed.
2022-07-27QUIC: avoided pool usage in ngx_quic_protection.c.Vladimir Homutov5-24/+24
2022-07-27QUIC: fixed-length buffers for secrets.Vladimir Homutov1-98/+89
2022-07-26Merged with the default branch.Sergey Kandaurov1-0/+12
2022-04-20QUIC: separate UDP framework for QUIC.Roman Arutyunyan9-138/+562
Previously, QUIC used the existing UDP framework, which was created for UDP in Stream. However the way QUIC connections are created and looked up is different from the way UDP connections in Stream are created and looked up. Now these two implementations are decoupled.
2022-02-17QUIC: fixed insertion at the end of buffer.Roman Arutyunyan2-3/+3
Previously, last buffer was tracked by keeping a pointer to the previous chain link "next" field. When the previous buffer was split and then removed, the pointer was no longer valid. Writing at this pointer resulted in broken data chains. Now last buffer is tracked by keeping a direct pointer to it.
2022-02-16QUIC: fixed indentation.Sergey Kandaurov8-22/+22
2022-02-14QUIC: optimize insertion at the end of QUIC buffer.Roman Arutyunyan2-2/+21
2022-02-14QUIC: eliminated ngx_quic_copy_buf().Roman Arutyunyan3-40/+25
Its only call is substituted with QUIC buffer write/read pair.
2022-02-14QUIC: trim input chain in ngx_quic_buffer_write().Roman Arutyunyan3-26/+16
This allows to eliminate explicit trimming when handling input STREAM frame. As a result, ngx_quic_trim_chain() is eliminated as well.
2022-02-14QUIC: ngx_quic_buffer_t object.Roman Arutyunyan7-102/+128
The object is used instead of ngx_chain_t pointer for buffer operations like ngx_quic_write_chain() and ngx_quic_read_chain(). These functions are renamed to ngx_quic_write_buffer() and ngx_quic_read_buffer().
2022-02-08SSL: logging level of "application data after close notify".Sergey Kandaurov1-0/+6
Such fatal errors are reported by OpenSSL 1.1.1, and similarly by BoringSSL, if application data is encountered during SSL shutdown, which started to be observed on the second SSL_shutdown() call after SSL shutdown fixes made in 09fb2135a589 (1.19.2). The error means that the client continues to send application data after receiving the "close_notify" alert (ticket #2318). Previously it was reported as SSL_shutdown() error of SSL_ERROR_SYSCALL.
2022-02-05QUIC: stream lingering.Roman Arutyunyan5-188/+269
Now ngx_quic_stream_t is decoupled from ngx_connection_t in a way that it can persist after connection is closed by application. During this period, server is expecting stream final size from client for correct flow control. Also, buffered output is sent to client as more flow control credit is granted.
2022-02-15QUIC: optimized datagram expansion with half-RTT tickets.Sergey Kandaurov1-4/+7
As shown in RFC 8446, section 2.2, Figure 3, and further specified in section 4.6.1, BoringSSL releases session tickets in Application Data (along with Finished) early, based on a precalculated client Finished transcript, once client signalled early data in extensions.
2022-02-14Merged with the default branch.Sergey Kandaurov4-1/+11
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-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-03HTTP/2: made it possible to flush response headers (ticket #1743).Maxim Dounin2-0/+4
Response headers can be buffered in the SSL buffer. But stream's fake connection buffered flag did not reflect this, so any attempts to flush the buffer without sending additional data were stopped by the write filter. It does not seem to be possible to reflect this in fc->buffered though, as we never known if main connection's c->buffered corresponds to the particular stream or not. As such, fc->buffered might prevent request finalization due to sending data on some other stream. Fix is to implement handling of flush buffers when the c->need_flush_buf flag is set, similarly to the existing last buffer handling. The same flag is now used for UDP sockets in the stream module instead of explicit checking of c->type.
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-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-31QUIC: allowed main QUIC connection for some operations.Roman Arutyunyan1-4/+5
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