summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)AuthorFilesLines
2020-09-15SSL: added the "ssl_keys_file" directive.Vladimir Homutov4-0/+72
2020-10-15QUIC: account packet header length in amplification limit.Vladimir Homutov2-2/+4
Header length calculation is adjusted to account real connection id lengths instead of worst case.
2020-10-12QUIC: fixed ngx_http_upstream_init() much like HTTP/2 connections.Sergey Kandaurov1-0/+7
2020-10-09QUIC: reset error and error_reason prior to processing packet.Vladimir Homutov1-0/+5
2020-10-07QUIC: fixed dead store assignment.Sergey Kandaurov1-1/+1
Found by Clang Static Analyzer.
2020-10-07QUIC: fixed format specifier in debug message.Vladimir Homutov1-1/+1
2020-10-02QUIC: added debug message with final packet processing status.Vladimir Homutov2-0/+30
2020-10-07QUIC: set local_socklen in stream connections.Roman Arutyunyan1-0/+1
Previously, this field was not set while creating a QUIC stream connection. As a result, calling ngx_connection_local_sockaddr() led to getsockname() bad descriptor error.
2020-10-02QUIC: enabled more key-related debug by default.Vladimir Homutov2-4/+13
2020-10-02QUIC: added connection id debug.Vladimir Homutov1-2/+0
2020-10-07QUIC: updated c->log->action strings to reflect proper state.Vladimir Homutov1-6/+13
2020-10-07QUIC: fixed memory leak in ngx_quic_send_frames().Vladimir Homutov1-0/+3
The function did not free passed frames in case of error.
2020-10-06QUIC: fixed measuring ACK Delay against 0-RTT packets.Sergey Kandaurov1-2/+6
2020-10-05QUIC: do not resend empty queue when speeding up handshake.Sergey Kandaurov1-1/+6
If client acknowledged an Initial packet with CRYPTO frame and then sent another Initial packet containing duplicate CRYPTO again, this could result in resending frames off the empty send queue.
2020-10-05QUIC: zero out packet length in frames prior to send.Sergey Kandaurov1-0/+1
It could be that a frame was previously sent and may have stale information. This was previously broken by merging frames on resend in b383120afca3.
2020-10-05QUIC: fixed build with clang and NGX_QUIC_DEBUG_CRYPTO enabled.Vladimir Homutov1-1/+4
The ngx_quic_hexdump() function is wrapped into macros to cast "data" argument to "* u_char".
2020-10-05QUIC: inline function instead of macro for hexdump.Vladimir Homutov1-12/+14
This prevents name clashes with local variables.
2020-10-01QUIC: fixed handling of incorrect packets.Vladimir Homutov1-3/+16
Instead of ignoring, connection was closed. This was broken in d0d3fc0697a0.
2020-10-01Merged with the default branch.Sergey Kandaurov16-100/+1116
2020-10-01QUIC: a bandaid for calculating ack_delay with non-monotonic time.Sergey Kandaurov1-0/+1
2020-10-01QUIC: speeding up handshake completion.Sergey Kandaurov1-3/+15
As per quic-recovery draft, section-6.2.3: resend CRYPTO frames when receiving an Initial packet containing duplicate CRYPTO data.
2020-10-01QUIC: fixed clang-ast asserts.Sergey Kandaurov2-2/+2
2020-10-01QUIC: fixed build with OpenSSL after bed310672f39.Sergey Kandaurov1-1/+1
2020-10-01QUIC: moved ssl configuration pointer to quic configuration.Vladimir Homutov6-31/+30
The ssl configuration is obtained at config time and saved for future use.
2020-09-30QUIC: added stateless reset support.Vladimir Homutov7-13/+237
The new "quic_stateless_reset_token_key" directive is added. It sets the endpoint key used to generate stateless reset tokens and enables feature. If the endpoint receives short-header packet that can't be matched to existing connection, a stateless reset packet is generated with a proper token. If a valid stateless reset token is found in the incoming packet, the connection is closed. Example configuration: http { quic_stateless_reset_token_key "foo"; ... }
2020-09-30QUIC: refined the "c->quic->initialized" flag usage.Vladimir Homutov1-53/+66
The flag is tied to the initial secret creation. The presence of c->quic pointer is sufficient to enable execution of ngx_quic_close_quic(). The ngx_quic_new_connection() function now returns the allocated quic connection object and the c->quic pointer is set by the caller. If an early error occurs before secrets initialization (i.e. in cases of invalid retry token or nginx exiting), it is still possible to generate an error response by trying to initialize secrets directly in the ngx_quic_send_cc() function. Before the change such early errors failed to send proper connection close message and logged an error. An auxilliary ngx_quic_init_secrets() function is introduced to avoid verbose call to ngx_quic_set_initial_secret() requiring local variable.
2020-09-30QUIC: packet processing refactoring.Vladimir Homutov3-475/+239
All packet header parsing is now performed by ngx_quic_parse_packet() function, located in the ngx_quic_transport.c file. The packet processing is centralized in the ngx_quic_process_packet() function which decides if the packet should be accepted, ignored or connection should be closed, depending on the connection state. As a result of refactoring, behavior has changed in some places: - minimal size of Initial packet is now always tested - connection IDs are always tested in existing connections - old keys are discarded on encryption level switch
2020-09-25QUIC: simplified packet header parsing.Vladimir Homutov2-26/+3
Now flags are processed in ngx_quic_input(), and raw->pos points to the first byte after the flags. Redundant checks from ngx_quic_parse_short_header() and ngx_quic_parse_long_header() are removed.
2020-09-25QUIC: keep the entire packet size in pkt->len.Roman Arutyunyan3-6/+7
Previously pkt->len kept the length of the packet remainder starting from pkt->raw->pos.
2020-09-18QUIC: switched to using fixed-length server connection IDs.Vladimir Homutov2-10/+5
2020-09-30QUIC: resend frames by moving them to output queue.Roman Arutyunyan1-20/+20
Previously, when a packet was declared lost, another packet was sent with the same frames. Now lost frames are moved to the output frame queue and push event is posted. This has the advantage of forming packets with more frames than before. Also, the start argument is removed from the ngx_quic_resend_frames() function as excess information.
2020-09-29QUIC: switch stream context to a server selected by SNI.Roman Arutyunyan1-2/+15
Previously the default server configuration context was used until the :authority or host header was parsed. This led to using the configuration parameters like client_header_buffer_size or request_pool_size from the default server rather than from the server selected by SNI. Also, the switch to the right server log is implemented. This issue manifested itself as QUIC stream being logged to the default server log until :authority or host is parsed.
2020-09-23QUIC: unbreak client certificate verification after 0d2b2664b41c.Sergey Kandaurov1-0/+2
Initially, client certificate verification didn't work due to the missing hc->ssl on a QUIC stream, which is started to be set in 7738:7f0981be07c4. Then it was lost in 7999:0d2b2664b41c introducing "quic" listen parameter. This change re-adds hc->ssl back for all QUIC connections, similar to SSL.
2020-09-21QUIC: prevented posted push event while in the draining state.Vladimir Homutov1-12/+12
If the push event was posted before ngx_quic_close_connection(), it could send data in the draining state.
2020-09-16HTTP/3: rearranged length check when parsing header.Roman Arutyunyan1-5/+5
The new code looks simpler and is similar to other checks.
2020-09-16HTTP/3: removed HTTP/3 parser call from discard body filter.Roman Arutyunyan1-10/+1
Request body discard is disabled for QUIC streams anyway.
2020-09-16HTTP/3: reject HTTP/2 frames.Roman Arutyunyan1-0/+17
As per HTTP/3 draft 30, section 7.2.8: Frame types that were used in HTTP/2 where there is no corresponding HTTP/3 frame have also been reserved (Section 11.2.1). These frame types MUST NOT be sent, and their receipt MUST be treated as a connection error of type H3_FRAME_UNEXPECTED.
2020-08-28Stream: set module.Pavel Pautov3-0/+239
Adds 'set' directive to the stream server context.
2020-09-24SSL: abort handshake on SSL_set_SSL_CTX() errors.Sergey Kandaurov1-1/+4
In rare cases, such as memory allocation failure, SSL_set_SSL_CTX() returns NULL, which could mean that a different SSL configuration has not been set. Note that this new behaviour seemingly originated in OpenSSL-1.1.0 release.
2020-09-23HTTP/2: run posted requests after reading body.Maxim Dounin1-0/+4
HTTP/2 code failed to run posted requests after calling the request body handler, and this resulted in connection hang if a subrequest was created in the body handler and no other actions were made.
2020-09-23HTTP/2: fixed segfault on DATA frames after 400 errors.Maxim Dounin1-0/+7
If 400 errors were redirected to an upstream server using the error_page directive, DATA frames from the client might cause segmentation fault due to null pointer dereference. The bug had appeared in 6989:2c4dbcd6f2e4 (1.13.0). Fix is to skip such frames in ngx_http_v2_state_read_data() (similarly to 7561:9f1f9d6e056a). With the fix, behaviour of 400 errors in HTTP/2 is now similar to one in HTTP/1.x, that is, nginx doesn't try to read the request body. Note that proxying 400 errors, as well as other early stage errors, to upstream servers might not be a good idea anyway. These errors imply that reading and processing of the request (and the request headers) wasn't complete, and proxying of such incomplete request might lead to various errors. Reported by Chenglong Zhang.
2020-09-16SSL: disabled shutdown when there are buffered data.Maxim Dounin1-1/+1
This fixes "SSL_shutdown() failed (SSL: ... bad write retry)" errors as observed on the second SSL_shutdown() call after SSL shutdown fixes in 09fb2135a589 (1.19.2), notably when HTTP/2 connections are closed due to read timeouts while there are incomplete writes.
2020-09-16SSL: disabled shutdown after connection errors.Maxim Dounin1-1/+1
This fixes "SSL_shutdown() failed (SSL: ... bad write retry)" errors as observed on the second SSL_shutdown() call after SSL shutdown fixes in 09fb2135a589 (1.19.2), notably when sending fails in ngx_http_test_expect(), similarly to ticket #1194. Note that there are some places where c->error is misused to prevent further output, such as ngx_http_v2_finalize_connection() if there are pending streams, or in filter finalization. These places seem to be extreme enough to don't care about missing shutdown though. For example, filter finalization currently prevents keepalive from being used.
2020-09-16SSL: fixed event handling during shutdown.Maxim Dounin1-0/+7
The c->read->ready and c->write->ready flags need to be cleared to ensure that appropriate read or write events will be reported by kernel. Without this, SSL shutdown might wait till the timeout after blocking on writing or reading even if there is a socket activity.
2020-09-16SSL: workaround for incorrect SSL_write() errors in OpenSSL 1.1.1.Maxim Dounin1-0/+12
OpenSSL 1.1.1 fails to return SSL_ERROR_SYSCALL if an error happens during SSL_write() after close_notify alert from the peer, and returns SSL_ERROR_ZERO_RETURN instead. Broken by this commit, which removes the "i == 0" check around the SSL_RECEIVED_SHUTDOWN one: https://git.openssl.org/?p=openssl.git;a=commitdiff;h=8051ab2 In particular, if a client closed the connection without reading the response but with properly sent close_notify alert, this resulted in unexpected "SSL_write() failed while ..." critical log message instead of correct "SSL_write() failed (32: Broken pipe)" at the info level. Since SSL_ERROR_ZERO_RETURN cannot be legitimately returned after SSL_write(), the fix is to convert all SSL_ERROR_ZERO_RETURN errors after SSL_write() to SSL_ERROR_SYSCALL.
2020-09-09Cache: keep c->body_start when Vary changes (ticket #2029).Sergey Kandaurov2-1/+3
If the variant hash doesn't match one we used as a secondary cache key, we switch back to the original key. In this case, c->body_start was kept updated from an existing cache node overwriting the new response value. After file cache update, it led to discrepancy between a cache node and cache file seen as critical errors "file cache .. has too long header".
2020-08-24HTTP/3: skip unknown frames on request stream.Roman Arutyunyan3-11/+60
As per HTTP/3 draft 29, section 4.1: Frames of unknown types (Section 9), including reserved frames (Section 7.2.8) MAY be sent on a request or push stream before, after, or interleaved with other frames described in this section. Also, trailers frame is now used as an indication of the request body end.
2020-09-16HTTP/3: fixed handling request body eof.Roman Arutyunyan3-24/+35
While for HTTP/1 unexpected eof always means an error, for HTTP/3 an eof right after a DATA frame end means the end of the request body. For this reason, since adding HTTP/3 support, eof no longer produced an error right after recv() but was passed to filters which would make a decision. This decision was made in ngx_http_parse_chunked() and ngx_http_v3_parse_request_body() based on the b->last_buf flag. Now that since 0f7f1a509113 (1.19.2) rb->chunked->length is a lower threshold for the expected number of bytes, it can be set to zero to indicate that more bytes may or may not follow. Now it's possible to move the check for eof from parser functions to ngx_http_request_body_chunked_filter() and clean up the parsing code. Also, in the default branch, in case of eof, the following three things happened, which were replaced with returning NGX_ERROR while implementing HTTP/3: - "client prematurely closed connection" message was logged - c->error flag was set - NGX_HTTP_BAD_REQUEST was returned The change brings back this behavior for HTTP/1 as well as HTTP/3.
2020-09-11QUIC: switched to draft 29 by default.Vladimir Homutov2-9/+9
2020-09-09QUIC: allowed old DCID for initial packets until first ACK.Roman Arutyunyan1-8/+21
If a packet sent in response to an initial client packet was lost, then successive client initial packets were dropped by nginx with the unexpected dcid message logged. This was because the new DCID generated by the server was not available to the client.