summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)AuthorFilesLines
2020-09-08QUIC: eliminated idle timeout restart for dropped packets.Roman Arutyunyan1-3/+27
2020-09-08QUIC: removed check for packet size beyond MAX_UDP_PAYLOAD_SIZE.Sergey Kandaurov1-5/+0
The check tested the total size of a packet header and unprotected packet payload, which doesn't include the packet number length and expansion of the packet protection AEAD. If the packet was corrupted, it could cause false triggering of the condition due to unsigned type underflow leading to a connection error. Existing checks for the QUIC header and protected packet payload lengths should be enough.
2020-09-08QUIC: check that the packet length is of at least sample size.Sergey Kandaurov1-0/+4
From quic-tls draft, section 5.4.2: An endpoint MUST discard packets that are not long enough to contain a complete sample. The check includes the Packet Number field assumed to be 4 bytes long.
2020-09-08QUIC: update packet length for short packets too.Sergey Kandaurov2-2/+2
During long packet header parsing, pkt->len is updated with the Length field value that is used to find next coalesced packets in a datagram. For short packets it still contained the whole QUIC packet size. This change uniforms packet length handling to always contain the total length of the packet number and protected packet payload in pkt->len.
2020-09-07QUIC: added logging output stream frame offset.Roman Arutyunyan1-4/+4
2020-09-04QUIC: refactored ngx_quic_retry_input().Vladimir Homutov1-15/+9
The function now returns NGX_DECLINED for packets that need to be ignored and integrates nicely into ngx_quic_input().
2020-09-06QUIC: do not send STOP_SENDING after STREAM fin.Roman Arutyunyan1-1/+1
Previously STOP_SENDING was sent to client upon stream closure if rev->eof and rev->error were not set. This was an indirect indication that no RESET_STREAM or STREAM fin has arrived. But it is indeed possible that rev->eof is not set, but STREAM fin has already been received, just not read out by the application. In this case sending STOP_SENDING does not make sense and can be misleading for some clients.
2020-09-03QUIC: added support for multiple connection IDs.Vladimir Homutov3-14/+301
The peer may issue additional connection IDs up to the limit defined by transport parameter "active_connection_id_limit", using NEW_CONNECTION_ID frames, and retire such IDs using RETIRE_CONNECTION_ID frame.
2020-08-27QUIC: style.Vladimir Homutov1-13/+13
Moved processing of RETIRE_CONNECTION_ID right after the NEW_CONNECTION_ID.
2020-09-02QUIC: pass return code from ngx_quic_decrypt() to the caller.Vladimir Homutov2-24/+39
It is required to distinguish internal errors from corrupted packets and perform actions accordingly: drop the packet or close the connection. While there, made processing of ngx_quic_decrypt() erorrs similar and removed couple of protocol violation errors.
2020-09-02QUIC: discard unrecognized long packes.Vladimir Homutov1-1/+4
While there, updated comment about discarded packets.
2020-08-31HTTP/3: do not set the never-indexed literal bit by default.Roman Arutyunyan1-3/+3
The "Literal Header Field Never Indexed" header field representation is not used in HTTP/2, and it makes little sense to make a distinction in HTTP/3.
2020-09-01QUIC: discard incorrect packets instead of closing the connection.Vladimir Homutov2-35/+29
quic-transport 5.2: Packets that are matched to an existing connection are discarded if the packets are inconsistent with the state of that connection. 5.2.2: Servers MUST drop incoming packets under all other circumstances.
2020-09-01QUIC: do not update largest packet number from a bad packet.Roman Arutyunyan1-2/+6
The removal of QUIC packet protection depends on the largest packet number received. When a garbage packet was received, the decoder still updated the largest packet number from that packet. This could affect removing protection from subsequent QUIC packets.
2020-08-28QUIC: handle PATH_CHALLENGE frame.Roman Arutyunyan2-15/+69
A PATH_RESPONSE frame with the same data is sent in response.
2020-08-25QUIC: enforce flow control on incoming STREAM and CRYPTO frames.Roman Arutyunyan1-13/+41
2020-08-25HTTP/3: drop the unwanted remainder of the request.Roman Arutyunyan2-0/+13
As per HTTP/3 draft 29, section 4.1: When the server does not need to receive the remainder of the request, it MAY abort reading the request stream, send a complete response, and cleanly close the sending part of the stream.
2020-08-25QUIC: send STOP_SENDING on stream closure.Roman Arutyunyan2-0/+49
The frame is sent for a read-enabled stream which has not received a FIN or RESET_STREAM.
2020-08-21QUIC: updated README.Vladimir Homutov1-3/+3
- version negotiation is implemented - quic recovery implementation is greatly improved
2020-08-21QUIC: disabled bidirectional SSL shutdown after 09fb2135a589.Sergey Kandaurov1-0/+1
On QUIC connections, SSL_shutdown() is used to call the send_alert callback to send a CONNECTION_CLOSE frame. The reverse side is handled by other means. At least BoringSSL doesn't differentiate whether this is a QUIC SSL method, so waiting for the peer's close_notify alert should be explicitly disabled.
2020-08-21QUIC: stripped down debug traces that have served its purpose.Sergey Kandaurov3-63/+4
The most observable remainers are incoming packet and stream payload that could still be useful to debug various QUIC and HTTP/3 frames.
2020-08-21QUIC: dead code removed.Vladimir Homutov1-8/+0
This case was already handled in c70446e3d771.
2020-08-20QUIC: removed outdated TODOs.Vladimir Homutov1-3/+0
The logical quic connection state is tested by handler functions that process corresponding types of packets (initial/handshake/application). The packet is declined if state is incorrect. No timeout is required for the input queue.
2020-08-20QUIC: added version negotiation support.Vladimir Homutov3-8/+102
If a client attemtps to start a new connection with unsupported version, a version negotiation packet is sent that contains a list of supported versions (currently this is a single version, selected at compile time).
2020-08-20HTTP/3: special handling of client errors in the upstream module.Roman Arutyunyan1-0/+13
The function ngx_http_upstream_check_broken_connection() terminates the HTTP/1 request if client sends eof. For QUIC (including HTTP/3) the c->write->error flag is now checked instead. This flag is set when the entire QUIC connection is closed or STOP_SENDING was received from client.
2020-08-18HTTP/3: request more client body bytes.Roman Arutyunyan1-6/+0
Previously the request body DATA frame header was read by one byte because filters were called only when the requested number of bytes were read. Now, after 08ff2e10ae92 (1.19.2), filters are called after each read. More bytes can be read at once, which simplifies and optimizes the code. This also reduces diff with the default branch.
2020-08-19QUIC: fixed format specifiers.Sergey Kandaurov1-2/+2
2020-08-19QUIC: changed c->quic->pto_count type to ngx_uint_t.Sergey Kandaurov1-1/+1
This field is served as a simple counter for PTO backoff.
2020-08-19QUIC: do not artificially delay sending queued frames.Sergey Kandaurov2-19/+1
This interacts badly with retransmissions of lost packets and can provoke spurious client retransmits.
2020-08-19QUIC: do not arm loss detection timer on packet threshold.Sergey Kandaurov1-4/+4
2020-08-19QUIC: do not arm loss detection timer for succeeding packets.Sergey Kandaurov1-4/+9
2020-08-19QUIC: handling packets with send time equal to lost send time.Sergey Kandaurov1-1/+1
Previously, such packets weren't handled as the resulting zero remaining time prevented setting the loss detection timer, which, instead, could be disarmed. For implementation details, see quic-recovery draft 29, appendix A.10.
2020-08-19QUIC: sending probe packets on PTO timer expiration.Sergey Kandaurov1-59/+109
The PTO handler is split into separate PTO and loss detection handlers that operate interchangeably depending on which timer should be set. The present ngx_quic_lost_handler is now only used for packet loss detection. It replaces ngx_quic_pto_handler if there are packets preceeding largest_ack. Once there is no more such packets, ngx_quic_pto_handler is installed again. Probes carry unacknowledged data previously sent in the oldest packet number, one per each packet number space. That is, it could be up to two probes. PTO backoff is now increased before scheduling next probes.
2020-08-18QUIC: changed ctx->largest_ack initial value to type maximum.Sergey Kandaurov1-1/+2
In particular, this prevents declaring packet number 0 as lost if there aren't yet any acknowledgements in this packet number space. For example, only Initial packets were acknowledged in handshake.
2020-08-18HTTP/3: fixed context storage in request body parser.Sergey Kandaurov1-1/+1
2020-08-18Merged with the default branch.Roman Arutyunyan15-111/+385
2020-08-18QUIC: coalesce neighbouring stream send buffers.Roman Arutyunyan1-110/+166
Previously a single STREAM frame was created for each buffer in stream output chain which is wasteful with respect to memory. The following changes were made in the stream send code: - ngx_quic_stream_send_chain() no longer calls ngx_quic_stream_send() and got a separate implementation that coalesces neighbouring buffers into a single frame - the new ngx_quic_stream_send_chain() respects the limit argument, which fixes sendfile_max_chunk and limit_rate - ngx_quic_stream_send() is reimplemented to call ngx_quic_stream_send_chain() - stream frame size limit is moved out to a separate function ngx_quic_max_stream_frame() - flow control is moved out to a separate function ngx_quic_max_stream_flow() - ngx_quic_stream_send_chain() is relocated next to ngx_quic_stream_send()
2020-08-14QUIC: packet based bytes_in_flight accounting.Sergey Kandaurov2-9/+30
A packet size is kept in one of the frames belonging to the packet.
2020-08-14QUIC: fixed leak of bytes_in_flight on keys discard.Sergey Kandaurov1-2/+21
This applies to discarding Initial and Handshake keys.
2020-08-14QUIC: fixed leak of bytes_in_flight attributed to lost packets.Sergey Kandaurov1-0/+1
2020-08-11release-1.19.2 tagMaxim Dounin1-0/+1
2020-08-11nginx-1.19.2-RELEASErelease-1.19.2Maxim Dounin1-0/+102
2020-08-10Core: reusing connections in advance.Maxim Dounin1-6/+5
Reworked connections reuse, so closing connections is attempted in advance, as long as number of free connections is less than 1/16 of worker connections configured. This ensures that new connections can be handled even if closing a reusable connection requires some time, for example, for a lingering close (ticket #2017). The 1/16 ratio is selected to be smaller than 1/8 used for disabling accept when working with accept mutex, so nginx will try to balance new connections to different workers first, and will start reusing connections only if this won't help.
2020-08-10Core: added a warning about reusing connections.Maxim Dounin2-0/+14
Previously, reusing connections happened silently and was only visible in monitoring systems. This was shown to be not very user-friendly, and administrators often didn't realize there were too few connections available to withstand the load, and configured timeouts (keepalive_timeout and http2_idle_timeout) were effectively reduced to keep things running. To provide at least some information about this, a warning is now logged (at most once per second, to avoid flooding the logs).
2020-08-10SSL: disabled sending shutdown after ngx_http_test_reading().Maxim Dounin1-0/+6
Sending shutdown when ngx_http_test_reading() detects the connection is closed can result in "SSL_shutdown() failed (SSL: ... bad write retry)" critical log messages if there are blocked writes. Fix is to avoid sending shutdown via the c->ssl->no_send_shutdown flag, similarly to how it is done in ngx_http_keepalive_handler() for kqueue when pending EOF is detected. Reported by Jan Prachaƙ (http://mailman.nginx.org/pipermail/nginx-devel/2018-December/011702.html).
2020-08-10HTTP/2: fixed c->timedout flag on timed out connections.Maxim Dounin1-0/+1
Without the flag, SSL shutdown is attempted on such connections, resulting in useless work and/or bogus "SSL_shutdown() failed (SSL: ... bad write retry)" critical log messages if there are blocked writes.
2020-08-10SSL: fixed shutdown handling.Maxim Dounin1-31/+48
Previously, bidirectional shutdown never worked, due to two issues in the code: 1. The code only tested SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE when there was an error in the error queue, which cannot happen. The bug was introduced in an attempt to fix unexpected error logging as reported with OpenSSL 0.9.8g (http://mailman.nginx.org/pipermail/nginx/2008-January/003084.html). 2. The code never called SSL_shutdown() for the second time to wait for the peer's close_notify alert. This change fixes both issues. Note that after this change bidirectional shutdown is expected to work for the first time, so c->ssl->no_wait_shutdown now makes a difference. This is not a problem for HTTP code which always uses c->ssl->no_wait_shutdown, but might be a problem for stream and mail code, as well as 3rd party modules. To minimize the effect of the change, the timeout, which was used to be 30 seconds and not configurable, though never actually used, is now set to 3 seconds. It is also expanded to apply to both SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE, so timeout is properly set if writing to the socket buffer is not possible.
2020-08-06Request body: optimized handling of small chunks.Maxim Dounin1-0/+25
If there is a previous buffer, copy small chunks into it instead of allocating additional buffer.
2020-08-06Request body: allowed large reads on chunk boundaries.Maxim Dounin1-8/+113
If some additional data from a pipelined request happens to be read into the body buffer, we copy it to r->header_in or allocate an additional large client header buffer for it.
2020-08-06Request body: all read data are now sent to filters.Maxim Dounin1-43/+10
This is a prerequisite for the next change to allow large reads on chunk boundaries.