summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
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-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 Kandaurov7-18/+91
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-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-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.
2022-01-13QUIC: fixed handling stream input buffers.Roman Arutyunyan2-6/+12
Previously, ngx_quic_write_chain() treated each input buffer as a memory buffer, which is not always the case. Special buffers were not skipped, which is especially important when hitting the input byte limit. The issue manifested itself with ngx_quic_write_chain() returning a non-empty chain consisting of a special last_buf buffer when called from QUIC stream send_chain(). In order for this to happen, input byte limit should be equal to the chain length, and the input chain should end with an empty last_buf buffer. An easy way to achieve this is the following: location /empty { return 200; } When this non-empty chain was returned from send_chain(), it signalled to the caller that input was blocked, while in fact it wasn't. This prevented HTTP request from finalization, which prevented QUIC from sending STREAM FIN to the client. The QUIC stream was then reset after a timeout. Now special buffers are skipped and send_chain() returns NULL in the case above, which signals to the caller a successful operation. Also, original byte limit is now passed to ngx_quic_write_chain() from send_chain() instead of actual chain length to make sure it's never zero.
2022-01-11QUIC: fixed handling STREAM FIN.Roman Arutyunyan1-1/+1
Previously, when a STREAM FIN frame with no data bytes was received after all prior stream data were already read by the application layer, the frame was ignored and eof was not reported to the application.
2022-01-12HTTP/3: set c->error on read error in ngx_http_test_reading().Roman Arutyunyan1-0/+1
Similar to other error/eof cases.
2022-01-12HTTP/3: simplified code.Roman Arutyunyan1-1/+1
2022-01-12QUIC: modified HTTP version test.Roman Arutyunyan1-1/+8
The new condition produces smaller diff to the default branch and is similar to HTTP/2 case.
2022-01-11Avoid sending "Connection: keep-alive" when shutting down.Maxim Dounin1-0/+4
When a worker process is shutting down, keepalive is not used: this is checked before the ngx_http_set_keepalive() call in ngx_http_finalize_connection(). Yet the "Connection: keep-alive" header was still sent, even if we know that the worker process is shutting down, potentially resulting in additional requests being sent to the connection which is going to be closed anyway. While clients are expected to be able to handle asynchronous close events (see ticket #1022), it is certainly possible to send the "Connection: close" header instead, informing the client that the connection is going to be closed and potentially saving some unneeded work. With this change, we additionally check for worker process shutdown just before sending response headers, and disable keepalive accordingly.
2021-12-30HTTP/3: improved processing of multiple Cookie field lines.Sergey Kandaurov2-14/+152
As per draft-ietf-quic-http, 4.1.1.2, and similar to HTTP/2 specification, they ought to be concatenated. This closely follows ngx_http_v2_module.
2021-12-30Events: fixed balancing between workers with EPOLLEXCLUSIVE.Maxim Dounin3-0/+64
Linux with EPOLLEXCLUSIVE usually notifies only the process which was first to add the listening socket to the epoll instance. As a result most of the connections are handled by the first worker process (ticket #2285). To fix this, we re-add the socket periodically, so other workers will get a chance to accept connections.
2021-12-29Version bump.Maxim Dounin1-2/+2
2021-12-29Style.Roman Arutyunyan1-1/+1
2021-12-29Merged with the default branch.Sergey Kandaurov11-249/+531
2021-12-27Support for sendfile(SF_NOCACHE).Maxim Dounin3-4/+25
The SF_NOCACHE flag, introduced in FreeBSD 11 along with the new non-blocking sendfile() implementation by glebius@, makes it possible to use sendfile() along with the "directio" directive.
2021-12-27SSL: SSL_sendfile(SF_NODISKIO) support.Maxim Dounin1-2/+29
2021-12-27Simplified sendfile(SF_NODISKIO) usage.Maxim Dounin7-169/+30
Starting with FreeBSD 11, there is no need to use AIO operations to preload data into cache for sendfile(SF_NODISKIO) to work. Instead, sendfile() handles non-blocking loading data from disk by itself. It still can, however, return EBUSY if a page is already being loaded (for example, by a different process). If this happens, we now post an event for the next event loop iteration, so sendfile() is retried "after a short period", as manpage recommends. The limit of the number of EBUSY tolerated without any progress is preserved, but now it does not result in an alert, since on an idle system event loop iteration might be very short and EBUSY can happen many times in a row. Instead, SF_NODISKIO is simply disabled for one call once the limit is reached. With this change, sendfile(SF_NODISKIO) is now used automatically as long as sendfile() is enabled, and no longer requires "aio on;".
2021-12-27Removed "aio sendfile", deprecated since 1.7.11.Maxim Dounin1-13/+0
2021-12-27QUIC: got rid of ngx_quic_create_temp_socket().Vladimir Homutov3-63/+29
It was mostly copy of the ngx_quic_listen(). Now ngx_quic_listen() no longer generates server id and increments seqnum. Instead, the server id is generated when the socket is created. The ngx_quic_alloc_socket() function is renamed to ngx_quic_create_socket().
2021-12-28Fixed a mismerge in 5c86189a1c1b.Ruslan Ermilov1-0/+2
2021-12-27QUIC: renamed input handling functions.Roman Arutyunyan1-14/+15
Now these functions have names ngx_quic_handle_XXX(): - ngx_quic_process_stateless_reset() -> ngx_quic_handle_stateless_reset() - ngx_quic_input() -> ngx_quic_handle_datagram() - ngx_quic_process_packet() -> ngx_quic_handle_packet() - ngx_quic_process_payload() -> ngx_quic_handle_payload()
2021-12-28QUIC: fixed format specifier after 6ccf3867959a.Roman Arutyunyan1-1/+1
2021-12-28QUIC: fixed config test with bpf (ticket #2292).Vladimir Homutov1-0/+8
The SO_REUSEPORT socket option is not set during configuration testing, thus making the further module initialization impossible and meaningless.