summaryrefslogtreecommitdiffhomepage
path: root/src/event (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-09-01Merged with the default branch.Sergey Kandaurov2-38/+61
2021-10-21SSL: SSL_sendfile() support with kernel TLS.Maxim Dounin2-5/+205
Requires OpenSSL 3.0 compiled with "enable-ktls" option. Further, KTLS needs to be enabled in kernel, and in OpenSSL, either via OpenSSL configuration file or with "ssl_conf_command Options KTLS;" in nginx configuration. On FreeBSD, kernel TLS is available starting with FreeBSD 13.0, and can be enabled with "sysctl kern.ipc.tls.enable=1" and "kldload ktls_ocf" to load a software backend, see man ktls(4) for details. On Linux, kernel TLS is available starting with kernel 4.13 (at least 5.2 is recommended), and needs kernel compiled with CONFIG_TLS=y (with CONFIG_TLS=m, which is used at least on Ubuntu 21.04 by default, the tls module needs to be loaded with "modprobe tls").
2021-10-21Style: added missing "static" specifiers.Maxim Dounin1-1/+1
Mostly found by gcc -Wtraditional, per "non-static declaration of ... follows static declaration [-Wtraditional]" warnings.
2021-10-19Stream: the "ssl_alpn" directive.Vladimir Homutov1-0/+3
The directive sets the server list of supported application protocols and requires one of this protocols to be negotiated if client is using ALPN.
2021-10-14SSL: added $ssl_alpn_protocol variable.Vladimir Homutov2-0/+32
The variable contains protocol selected by ALPN during handshake and is empty otherwise.
2021-08-10SSL: removed use of the SSL_OP_MSIE_SSLV2_RSA_PADDING option.Sergey Kandaurov1-5/+0
It has no effect since OpenSSL 0.9.7h and 0.9.8a.
2021-08-10SSL: removed export ciphers support.Sergey Kandaurov2-36/+0
Export ciphers are forbidden to negotiate in TLS 1.1 and later protocol modes. They are disabled since OpenSSL 1.0.2g by default unless explicitly configured with "enable-weak-ssl-ciphers", and completely removed in OpenSSL 1.1.0.
2021-08-10SSL: use of the SSL_OP_IGNORE_UNEXPECTED_EOF option.Sergey Kandaurov1-0/+4
A new behaviour was introduced in OpenSSL 1.1.1e, when a peer does not send close_notify before closing the connection. Previously, it was to return SSL_ERROR_SYSCALL with errno 0, known since at least OpenSSL 0.9.7, and is handled gracefully in nginx. Now it returns SSL_ERROR_SSL with a distinct reason SSL_R_UNEXPECTED_EOF_WHILE_READING ("unexpected eof while reading"). This leads to critical errors seen in nginx within various routines such as SSL_do_handshake(), SSL_read(), SSL_shutdown(). The behaviour was restored in OpenSSL 1.1.1f, but presents in OpenSSL 3.0 by default. Use of the SSL_OP_IGNORE_UNEXPECTED_EOF option added in OpenSSL 3.0 allows to set a compatible behaviour to return SSL_ERROR_ZERO_RETURN: https://git.openssl.org/?p=openssl.git;a=commitdiff;h=09b90e0 See for additional details: https://github.com/openssl/openssl/issues/11381
2021-08-10SSL: silenced warnings when building with OpenSSL 3.0.Sergey Kandaurov1-0/+2
The OPENSSL_SUPPRESS_DEPRECATED macro is used to suppress deprecation warnings. This covers Session Tickets keys, SSL Engine, DH low level API for DHE ciphers. Unlike OPENSSL_API_COMPAT, it works well with OpenSSL built with no-deprecated. In particular, it doesn't unhide various macros in OpenSSL includes, which are meant to be hidden under OPENSSL_NO_DEPRECATED.
2021-08-10SSL: ERR_peek_error_line_data() compatibility with OpenSSL 3.0.Sergey Kandaurov2-1/+6
ERR_peek_error_line_data() was deprecated in favour of ERR_peek_error_all(). Here we use the ERR_peek_error_data() helper to pass only used arguments.
2021-08-10SSL: using SSL_CTX_set0_tmp_dh_pkey() with OpenSSL 3.0 in dhparam.Sergey Kandaurov1-1/+31
Using PEM_read_bio_DHparams() and SSL_CTX_set_tmp_dh() is deprecated as part of deprecating the low level DH functions in favor of EVP_PKEY: https://git.openssl.org/?p=openssl.git;a=commitdiff;h=163f6dc
2021-08-10SSL: SSL_get_peer_certificate() is deprecated in OpenSSL 3.0.Sergey Kandaurov1-0/+5
Switch to SSL_get1_peer_certificate() when building with OpenSSL 3.0 and OPENSSL_NO_DEPRECATED defined.
2021-08-10SSL: RSA data type is deprecated in OpenSSL 3.0.Sergey Kandaurov2-1/+7
The only consumer is a callback function for SSL_CTX_set_tmp_rsa_callback() deprecated in OpenSSL 1.1.0. Now the function is conditionally compiled too.
2021-08-04SSL: SSL_CTX_set_tmp_dh() error handling.Sergey Kandaurov1-1/+7
For example, it can fail due to weak DH parameters.
2021-08-03SSL: set events ready flags after handshake.Maxim Dounin1-0/+6
The c->read->ready and c->write->ready flags might be reset during the handshake, and not set again if the handshake was finished on the other event. At the same time, some data might be read from the socket during the handshake, so missing c->read->ready flag might result in a connection hang, for example, when waiting for an SMTP greeting (which was already received during the handshake). Found by Sergey Kandaurov.
2021-08-24QUIC: Stateless Reset Token debug logging cleanup.Sergey Kandaurov1-2/+0
2021-08-24QUIC: removed duplicate logging of Stateless Reset Token.Sergey Kandaurov1-4/+0
2021-08-24QUIC: fixed dead store assignment.Sergey Kandaurov1-1/+0
Found by Clang Static Analyzer.
2021-08-17QUIC: fixed format specifiers in ngx_quic_bpf module.Sergey Kandaurov1-6/+6
2021-08-05QUIC: asynchronous shutdown.Roman Arutyunyan2-1/+5
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 Kandaurov6-14/+109
2021-07-29QUIC: limit in-flight bytes by congestion window.Roman Arutyunyan2-10/+27
Previously, in-flight byte counter and congestion window were properly maintained, but the limit was not properly implemented. Now a new datagram is sent only if in-flight byte counter is less than window. The limit is datagram-based, which means that a single datagram may lead to exceeding the limit, but the next one will not be sent.
2021-07-28QUIC: handle EAGAIN properly on UDP sockets.Vladimir Homutov5-55/+135
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 Arutyunyan6-77/+50
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-07-20QUIC: the "quic_gso" directive.Vladimir Homutov2-2/+7
The directive enables usage of UDP segmentation offloading by quic. By default, gso is disabled since it is not always operational when detected (depends on interface configuration).
2021-07-15Merged with the default branch.Sergey Kandaurov4-33/+42
2021-07-15Core: added separate function for local source address cmsg.Vladimir Homutov2-82/+12
2021-07-15QUIC: added support for segmentation offloading.Vladimir Homutov1-10/+236
To improve output performance, UDP segmentation offloading is used if available. If there is a significant amount of data in an output queue and path is verified, QUIC packets are not sent one-by-one, but instead are collected in a buffer, which is then passed to kernel in a single sendmsg call, using UDP GSO. Such method greatly decreases number of system calls and thus system load.
2021-07-15Core: made the ngx_sendmsg() function non-static.Vladimir Homutov1-0/+31
Additionally, the ngx_init_srcaddr_cmsg() function is introduced which initializes control message with connection local address. The NGX_HAVE_ADDRINFO_CMSG macro is defined when at least one of methods to deal with corresponding control message is available.
2021-07-12Core: the ngx_event_udp.h header file.Vladimir Homutov2-27/+44
2021-07-05QUIC: fixed padding calculation.Vladimir Homutov1-0/+3
Sometimes, QUIC packets need to be of certain (or minimal) size. This is achieved by adding PADDING frames. It is possible, that adding padding will affect header size, thus forcing us to recalculate padding size once more.
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-21QUIC: fixed double memzero of new frames in ngx_quic_alloc_frame().Sergey Kandaurov1-1/+1
2021-06-21Core: added the ngx_rbtree_data() macro.Vladimir Homutov1-2/+2
2021-06-17QUIC: compact initial secrets table.Sergey Kandaurov1-32/+6
2021-06-16QUIC: using compile time block/iv length for tokens.Sergey Kandaurov1-4/+8
Reference values can be found in RFC 3602, 2.1, 2.4.
2021-06-16QUIC: optimized initial secrets key length computation.Sergey Kandaurov1-6/+6
AES-128 key length is known in compile time.
2021-06-16QUIC: consistent use of 12-byte buffers in nonce computation.Sergey Kandaurov1-9/+9
All supported cipher suites produce 96-bit IV (RFC 5116, 5.1, RFC 8439, 2.3). This eliminates a few magic numbers and run-time overhead.
2021-06-16QUIC: consistent use of 5-byte buffers for header protection.Sergey Kandaurov1-8/+11
The output buffer is now also of 5 bytes. Header protection uses stream ciphers, which don't produce extra output nor PKCS padding.
2021-06-16QUIC: updated specification references.Sergey Kandaurov11-70/+128
This includes updating citations and further clarification.
2021-06-10QUIC: improved errors readability.Vladimir Homutov2-1/+3
2021-06-09QUIC: persistent congestion calculation.Vladimir Homutov3-13/+112
According to RFC 9002 (quic-recovery) 7.6.
2021-06-07QUIC: stream flow control refactored.Roman Arutyunyan4-64/+179
- 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-06-01Fixed SSL logging with lingering close.Maxim Dounin2-0/+7
Recent fixes to SSL shutdown with lingering close (554c6ae25ffc, 1.19.5) broke logging of SSL variables. To make sure logging of SSL variables works properly, avoid freeing c->ssl when doing an SSL shutdown before lingering close. Reported by Reinis Rozitis (http://mailman.nginx.org/pipermail/nginx/2021-May/060670.html).
2021-06-01SSL: ngx_ssl_shutdown() rework.Maxim Dounin1-22/+21
Instead of calling SSL_free() with each return point, introduced a single place where cleanup happens. As a positive side effect, this fixes two potential memory leaks on ngx_handle_read_event() and ngx_handle_write_event() errors where there were no SSL_free() calls (though unlikely practical, as errors there are only expected to happen due to bugs or kernel issues).
2021-05-31HTTP/3: removed $http3 that served its purpose.Sergey Kandaurov1-4/+0
To specify final protocol version by hand: add_header Alt-Svc h3=":443";
2021-05-31Core: disabled cloning sockets when testing config (ticket #2188).Maxim Dounin1-10/+13
Since we anyway do not set SO_REUSEPORT when testing configuration (see ecb5cd305b06), trying to open additional sockets does not make much sense, as all these additional sockets are expected to result in EADDRINUSE errors from bind(). On the other hand, there are reports that trying to open these sockets takes significant time under load: total configuration testing time greater than 15s was observed in ticket #2188, compared to less than 1s without load. With this change, no additional sockets are opened during testing configuration.
2021-05-26QUIC: call stream read handler on new data arrival.Roman Arutyunyan1-6/+19
This was broken in b3f6ad181df4.
2021-05-25QUIC: make sure stream data size is lower than final size.Roman Arutyunyan2-0/+17
As per quic-transport 34, FINAL_SIZE_ERROR is generated if an endpoint received a STREAM frame or a RESET_STREAM frame containing a final size that was lower than the size of stream data that was already received.