summaryrefslogtreecommitdiffhomepage
path: root/src/event/quic/ngx_event_quic_frames.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2025-04-15QUIC: optimized connection frame threshold.Roman Arutyunyan1-1/+1
Previosly the threshold was hardcoded at 10000. This value is too low for high BDP networks. For example, if all frames are STREAM frames, and MTU is 1500, the upper limit for congestion window would be roughly 15M (10000 * 1500). With 100ms RTT it's just a 1.2Gbps network (15M * 10 * 8). In reality, the limit is even lower because of other frame types. Also, the number of frames that could be used simultaneously depends on the total amount of data buffered in all server streams, and client flow control. The change sets frame threshold based on max concurrent streams and stream buffer size, the product of which is the maximum number of in-flight stream data in all server streams at any moment. The value is divided by 2000 to account for a typical MTU 1500 and the fact that not all frames are STREAM frames.
2024-05-28QUIC: ngx_quic_buffer_t use-after-free protection.Roman Arutyunyan1-0/+1
Previously the last chain field of ngx_quic_buffer_t could still reference freed chains and buffers after calling ngx_quic_free_buffer(). While normally an ngx_quic_buffer_t object should not be used after freeing, resetting last_chain field would prevent a potential use-after-free.
2023-10-26QUIC: improved packet and frames debug tracing.Vladimir Khomutov1-2/+2
Currently, packets generated by ngx_quic_frame_sendto() and ngx_quic_send_early_cc() are not logged, thus making it hard to read logs due to gaps appearing in packet numbers sequence. At frames level, it is handy to see immediately packet number in which they arrived or being sent.
2023-05-04QUIC: fixed split frames error handling.Sergey Kandaurov1-2/+5
Do not corrupt frame data chain pointer on ngx_quic_read_buffer() error. The error leads to closing a QUIC connection where the frame may be used as part of the QUIC connection tear down, which envolves writing pending frames, including this one.
2023-01-31QUIC: fixed broken token in NEW_TOKEN (ticket #2446).Roman Arutyunyan1-0/+14
Previously, since 3550b00d9dc8, the token was allocated on stack, to get rid of pool usage. Now the token is allocated by ngx_quic_copy_buffer() in QUIC buffers, also used for STREAM, CRYPTO and ACK frames.
2023-01-31QUIC: ngx_quic_copy_buffer() function.Roman Arutyunyan1-0/+33
The function copies passed data to QUIC buffer chain and returns it. The chain can be used in ngx_quic_frame_t data field.
2022-02-17QUIC: fixed insertion at the end of buffer.Roman Arutyunyan1-2/+2
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-14QUIC: optimize insertion at the end of QUIC buffer.Roman Arutyunyan1-2/+19
2022-02-14QUIC: eliminated ngx_quic_copy_buf().Roman Arutyunyan1-34/+0
Its only call is substituted with QUIC buffer write/read pair.
2022-02-14QUIC: trim input chain in ngx_quic_buffer_write().Roman Arutyunyan1-20/+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 Arutyunyan1-25/+73
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-05QUIC: stream lingering.Roman Arutyunyan1-0/+4
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-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-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-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-13QUIC: return written size from ngx_quic_write_chain().Roman Arutyunyan1-1/+9
This allows to escape calculating it before calling the function.
2022-01-13QUIC: fixed handling stream input buffers.Roman Arutyunyan1-5/+11
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.
2021-12-24QUIC: refactored buffer allocation, spliting and freeing.Roman Arutyunyan1-119/+165
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-16QUIC: removed ngx_quic_copy_chain().Roman Arutyunyan1-59/+0
The function is unused.
2021-12-16QUIC: renamed buffer-related functions.Roman Arutyunyan1-8/+8
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 Arutyunyan1-44/+72
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 Arutyunyan1-4/+6
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-02QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.Sergey Kandaurov1-0/+14
2021-10-13QUIC: limited the total number of frames.Roman Arutyunyan1-2/+6
Exceeding 10000 allocated frames is considered a flood.
2021-07-28QUIC: eliminated stream type from ngx_quic_stream_frame_t.Roman Arutyunyan1-17/+2
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-06-21QUIC: fixed double memzero of new frames in ngx_quic_alloc_frame().Sergey Kandaurov1-1/+1
2021-05-25QUIC: refactored CRYPTO and STREAM buffer ordering.Roman Arutyunyan1-194/+67
Generic function ngx_quic_order_bufs() is introduced. This function creates and maintains a chain of buffers with holes. Holes are marked with b->sync flag. Several buffers and holes in this chain may share the same underlying memory buffer. When processing STREAM frames with this function, frame data is copied only once to the right place in the stream input chain. Previously data could be copied twice. First when buffering an out-of-order frame data, and then when filling stream buffer from ordered frame queue. Now there's only one data chain for both tasks.
2021-05-05QUIC: generic buffering for stream input.Roman Arutyunyan1-2/+1
Previously each stream had an input buffer. Now memory is allocated as bytes arrive. Generic buffering mechanism is used for this.
2021-04-14QUIC: separate files for SSL library interfaces.Vladimir Homutov1-4/+0
2021-04-13QUIC: separate files for frames related processing.Vladimir Homutov1-0/+912