summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
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-05QUIC: stream lingering.Roman Arutyunyan6-190/+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 Kandaurov11-7/+29
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-08QUIC: fixed the "quic_stream_buffer_size" directive.Vladimir Homutov1-0/+4
The default value is now correctly set and the configuration is properly merged.
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-03HTTP/2: fixed closed_nodes overflow (ticket #1708).Maxim Dounin1-1/+1
With large http2_max_concurrent_streams or http2_max_concurrent_pushes, more than 255 ngx_http_v2_node_t structures might be allocated, eventually leading to h2c->closed_nodes overflow when closing corresponding streams. This will in turn result in additional allocations in ngx_http_v2_get_node_by_id(). While mostly harmless, it can result in excessive memory usage by a HTTP/2 connection, notably in configurations with many keepalive_requests allowed. Fix is to use ngx_uint_t for h2c->closed_nodes instead of unsigned:8.
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 Dounin6-3/+14
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-01Cache: fixed race in ngx_http_file_cache_forced_expire().Maxim Dounin1-0/+5
During configuration reload two cache managers might exist for a short time. If both tried to delete the same cache node, the "ignore long locked inactive cache entry" alert appeared in logs. Additionally, ngx_http_file_cache_forced_expire() might be also called by worker processes, with similar results. Fix is to ignore cache nodes being deleted, similarly to how it is done in ngx_http_file_cache_expire() since 3755:76e3a93821b1. This was somehow missed in 7002:ab199f0eb8e8, when ignoring long locked cache entries was introduced in ngx_http_file_cache_forced_expire().
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-26Core: added autotest for UDP segmentation offloading.Vladimir Homutov1-0/+4
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-25Core: added function for local source address cmsg.Vladimir Homutov3-82/+77
2022-01-25Core: made the ngx_sendmsg() function non-static.Vladimir Homutov2-70/+127
The NGX_HAVE_ADDRINFO_CMSG macro is defined when at least one of methods to deal with corresponding control message is available.
2022-01-25Core: the ngx_event_udp.h header file.Vladimir Homutov2-6/+25
2022-01-27Version bump.Vladimir Homutov1-2/+2
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: 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-21QUIC: removed stale declaration.Vladimir Homutov1-1/+0
The ngx_quic_get_unconnected_socket() was removed in 1e2f4e9c8195.