summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
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.
2021-12-25Core: added NGX_REGEX_MULTILINE for 3rd party modules.Maxim Dounin2-2/+11
Notably, NAXSI is known to misuse ngx_regex_compile() with rc.options set to PCRE_CASELESS | PCRE_MULTILINE. With PCRE2 support, and notably binary compatibility changes, it is no longer possible to set PCRE[2]_MULTILINE option without using proper interface. To facilitate correct usage, this change adds the NGX_REGEX_MULTILINE option.
2021-12-25PCRE2 and PCRE binary compatibility.Maxim Dounin2-15/+48
With this change, dynamic modules using nginx regex interface can be used regardless of the variant of the PCRE library nginx was compiled with. If a module is compiled with different PCRE library variant, in case of ngx_regex_exec() errors it will report wrong function name in error messages. This is believed to be tolerable, given that fixing this will require interface changes.
2021-12-25PCRE2 library support.Maxim Dounin2-10/+351
The PCRE2 library is now used by default if found, instead of the original PCRE library. If needed for some reason, this can be disabled with the --without-pcre2 configure option. To make it possible to specify paths to the library and include files via --with-cc-opt / --with-ld-opt, the library is first tested without any additional paths and options. If this fails, the pcre2-config script is used. Similarly to the original PCRE library, it is now possible to build PCRE2 from sources with nginx configure, by using the --with-pcre= option. It automatically detects if PCRE or PCRE2 sources are provided. Note that compiling PCRE2 10.33 and later requires inttypes.h. When compiling on Windows with MSVC, inttypes.h is only available starting with MSVC 2013. In older versions some replacement needs to be provided ("echo '#include <stdint.h>' > pcre2-10.xx/src/inttypes.h" is good enough for MSVC 2010). The interface on nginx side remains unchanged.
2021-12-25Core: ngx_regex.c style cleanup.Maxim Dounin1-17/+17
Notably, ngx_pcre_pool and ngx_pcre_studies are renamed to ngx_regex_pool and ngx_regex_studies, respectively.
2021-12-25Core: fixed ngx_pcre_studies cleanup.Maxim Dounin1-40/+43
If a configuration parsing fails for some reason, ngx_regex_module_init() is not called, and ngx_pcre_studies remained set despite the fact that the pool it was allocated from is already freed. This might result in a segmentation fault during runtime regular expression compilation, such as in SSI, for example, in the single process mode, or if a worker process died and was respawned from a master process in such an inconsistent state. Fix is to clear ngx_pcre_studies from the pool cleanup handler (which is anyway used to free JIT-compiled patterns).
2021-12-24QUIC: refactored buffer allocation, spliting and freeing.Roman Arutyunyan2-120/+167
Previously, buffer lists was used to track used buffers. Now reference counter is used instead. The new implementation is simpler and faster with many buffer clones.
2021-12-21Moved Huffman coding out of HTTP/2.Ruslan Ermilov7-43/+45
ngx_http_v2_huff_decode.c and ngx_http_v2_huff_encode.c are renamed to ngx_http_huff_decode.c and ngx_http_huff_encode.c.
2021-12-16QUIC: removed ngx_quic_copy_chain().Roman Arutyunyan2-61/+0
The function is unused.
2021-12-16QUIC: renamed buffer-related functions.Roman Arutyunyan6-20/+20
ngx_quic_alloc_buf() -> ngx_quic_alloc_chain(), ngx_quic_free_bufs() -> ngx_quic_free_chain(), ngx_quic_trim_bufs() -> ngx_quic_trim_chain()
2021-12-24QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().Roman Arutyunyan4-96/+117
They are replaced with ngx_quic_write_chain() and ngx_quic_read_chain(). These functions represent the API to data buffering. The first function adds data of given size at given offset to the buffer. Now it returns the unwritten part of the chain similar to c->send_chain(). The second function returns data of given size from the beginning of the buffer. Its second argument and return value are swapped compared to ngx_quic_split_bufs() to better match ngx_quic_write_chain(). Added, returned and stored data are regular ngx_chain_t/ngx_buf_t chains. Missing data is marked with b->sync flag. The functions are now used in both send and recv data chains in QUIC streams.
2021-12-24QUIC: avoid excessive buffer allocations in stream output.Roman Arutyunyan5-15/+33
Previously, when a few bytes were send to a QUIC stream by the application, a 4K buffer was allocated for these bytes. Then a STREAM frame was created and that entire buffer was used as data for that frame. The frame with the buffer were in use up until the frame was acked by client. Meanwhile, when more bytes were send to the stream, more buffers were allocated and assigned as data to newer STREAM frames. In this scenario most buffer memory is unused. Now the unused part of the stream output buffer is available for further stream output while earlier parts of the buffer are waiting to be acked. This is achieved by splitting the output buffer.
2021-12-27QUIC: got rid of excessive "qsock" argument in ngx_quic_output.c.Vladimir Homutov1-47/+28
The output is always sent to the active path, which is stored in the quic connection. There is no need to pass it in arguments. When output has to be send to to a specific path (in rare cases, such as path probing), a separate method exists (ngx_quic_frame_sendto()).
2021-12-16QUIC: refactored ngx_quic_validate_path().Vladimir Homutov1-6/+3
The function now accepts path argument, as suggested by the name. Socket is not really needed inside.
2021-12-16QUIC: added missing check for backup path existence.Vladimir Homutov1-6/+15
2021-12-24Merged with the default branch.Ruslan Ermilov18-81/+214
2021-12-14QUIC: added path limiting function ngx_quic_path_limit().Roman Arutyunyan1-16/+24
2021-12-13QUIC: decoupled path state and limitation status.Vladimir Homutov5-6/+15
The path validation status and anti-amplification limit status is actually two different variables. It is possible that validating path should not be limited (for example, when re-validating former path).
2021-12-13QUIC: improved path validation.Vladimir Homutov4-28/+15
Previously, path was considered valid during arbitrary selected 10m timeout since validation. This is quite not what RFC 9000 says; the relevant part is: An endpoint MAY skip validation of a peer address if that address has been seen recently. The patch considers a path to be 'recently seen' if packets were received during idle timeout. If a packet is received from the path that was seen not so recently, such path is considered new, and anti-amplification restrictions apply.
2021-12-13QUIC: write and full stream shutdown support.Roman Arutyunyan2-56/+81
Full stream shutdown is now called from stream cleanup handler instead of explicitly sending frames.
2021-12-10QUIC: simplified stream initialization.Roman Arutyunyan1-172/+62
After creation, a client stream is added to qc->streams.uninitialized queue. After initialization it's removed from the queue. If a stream is never initialized, it is freed in ngx_quic_close_streams(). Stream initializer is now set as read event handler in stream connection. Previously qc->streams.uninitialized was used only for delayed stream initialization. The change makes it possible not to handle separately the case of a new stream in stream-related frame handlers. It makes these handlers simpler since new streams and existing streams are now handled by the same code.
2021-11-25HTTP/2: fixed sendfile() aio handling.Maxim Dounin3-10/+65
With sendfile() in threads ("aio threads; sendfile on;"), client connection can block on writing, waiting for sendfile() to complete. In HTTP/2 this might result in the request hang, since an attempt to continue processing in thread event handler will call request's write event handler, which is usually stopped by ngx_http_v2_send_chain(): it does nothing if there are no additional data and stream->queued is set. Further, HTTP/2 resets stream's c->write->ready to 0 if writing blocks, so just fixing ngx_http_v2_send_chain() is not enough. Can be reproduced with test suite on Linux with: TEST_NGINX_GLOBALS_HTTP="aio threads; sendfile on;" prove h2*.t The following tests currently fail: h2_keepalive.t, h2_priority.t, h2_proxy_max_temp_file_size.t, h2.t, h2_trailers.t. Similarly, sendfile() with AIO preloading on FreeBSD can block as well, with similar results. This is, however, harder to reproduce, especially on modern FreeBSD systems, since sendfile() usually does not return EBUSY. Fix is to modify ngx_http_v2_send_chain() so it actually tries to send data to the main connection when called, and to make sure that c->write->ready is set by the relevant event handlers.
2021-11-25HTTP/2: fixed "task already active" with sendfile in threads.Maxim Dounin4-24/+58
With sendfile in threads, "task already active" alerts might appear in logs if a write event happens on the main HTTP/2 connection, triggering a sendfile in threads while another thread operation is already running. Observed with "aio threads; aio_write on; sendfile on;" and with thread event handlers modified to post a write event to the main HTTP/2 connection (though can happen without any modifications). Similarly, sendfile() with AIO preloading on FreeBSD can trigger duplicate aio operation, resulting in "second aio post" alerts. This is, however, harder to reproduce, especially on modern FreeBSD systems, since sendfile() usually does not return EBUSY. Fix is to avoid starting a sendfile operation if other thread operation is active by checking r->aio in the thread handler (and, similarly, in aio preload handler). The added check also makes duplicate calls protection redundant, so it is removed.
2021-11-23QUIC: post stream events instead of calling their handlers.Roman Arutyunyan1-3/+3
This potentially reduces the number of handler calls.
2021-12-06QUIC: added missing frame initialization.Vladimir Homutov1-0/+4
Currently, all used fields are initialized, but usage may change in future.
2021-12-09QUIC: refactored ngx_quic_frame_sendto() function.Vladimir Homutov3-45/+29
The function now takes path as an argument to deal with associated restrictions and update sent counter.
2021-12-09QUIC: fixed e06283038ec8 mis-merge.Sergey Kandaurov1-1/+1
The NGX_HTTP_QUIC macro was removed in 33226ac61076.
2021-12-08HTTP/3: cleanup after "listen .. quic" removal in be08b858086a.Sergey Kandaurov1-1/+0
2021-12-07QUIC: clear SSL_OP_ENABLE_MIDDLEBOX_COMPAT on SSL context switch.Sergey Kandaurov1-0/+8
The SSL_OP_ENABLE_MIDDLEBOX_COMPAT option is provided by QuicTLS and enabled by default in the newly created SSL contexts. SSL_set_quic_method() is used to clear it, which is required for SSL handshake to work on QUIC connections. Switching context in the ngx_http_ssl_servername() SNI callback overrides SSL options from the new SSL context. This results in the option set again. Fix is to explicitly clear it when switching to another SSL context. Initially reported here (in Russian): http://mailman.nginx.org/pipermail/nginx-ru/2021-November/063989.html
2021-12-07HTTP/3: avoid sending stream cancellation for pushed streams.Sergey Kandaurov1-1/+3
2021-12-07QUIC: converted ngx_quic_keys_set_encryption_secret() to NGX codes.Sergey Kandaurov3-17/+27
While here, removed check for encryption level zero, redundant by its nature.
2021-12-07HTTP/3: renamed files.Roman Arutyunyan5-8/+8
ngx_http_v3_tables.h and ngx_http_v3_tables.c are renamed to ngx_http_v3_table.h and ngx_http_v3_table.c to better match HTTP/2 code. ngx_http_v3_streams.h and ngx_http_v3_streams.c are renamed to ngx_http_v3_uni.h and ngx_http_v3_uni.c to better match their content.
2021-12-06QUIC: simplified configuration.Vladimir Homutov10-395/+151
Directives that set transport parameters are removed from the configuration. Corresponding values are derived from the quic configuration or initialized to default. Whenever possible, quic configuration parameters are taken from higher-level protocol settings, i.e. HTTP/3.
2021-12-01HTTP/3: $http3 variable.Roman Arutyunyan1-7/+25
A new variable $http3 is added. The variable equals to "h3" for HTTP/3 connections, "hq" for hq connections and is an empty string otherwise. The variable $quic is eliminated. The new variable is similar to $http2 variable.
2021-12-04HTTP/3: http3_hq directive and NGX_HTTP_V3_HQ macro.Roman Arutyunyan8-64/+64
Listen quic parameter is no longer supported.
2021-12-06HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.Roman Arutyunyan11-653/+579
2021-12-02QUIC: fixed using of retired connection id (ticket #2289).Vladimir Homutov1-4/+6
RFC 9000 19.16 The sequence number specified in a RETIRE_CONNECTION_ID frame MUST NOT refer to the Destination Connection ID field of the packet in which the frame is contained. Before the patch, the RETIRE_CONNECTION_ID frame was sent before switching to the new client id. If retired client id was currently in use, this lead to violation of the spec.
2021-12-02QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.Sergey Kandaurov1-0/+14
2021-12-02HTTP/3: adjusted ALPN macro names to align with 61abb35bb8cf.Sergey Kandaurov3-6/+6
2021-12-01QUIC: removed excessive check.Vladimir Homutov1-1/+1
The c->udp->dgram may be NULL only if the quic connection was just created: the ngx_event_udp_recvmsg() passes information about datagrams to existing connections by providing information in c->udp. If case of a new connection, c->udp is allocated by the QUIC code during creation of quic connection (it uses c->sockaddr to initialize qsock->path). Thus the check for qsock->path is excessive and can be read wrong, assuming that other options possible, leading to warnings from clang static analyzer.
2021-11-30QUIC: ngx_quic_send_alert() callback moved to its place.Sergey Kandaurov3-29/+28