]> git.kaiwu.me - nginx.git/log
nginx.git
5 years agoHTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan [Fri, 22 Jan 2021 12:57:41 +0000 (15:57 +0300)]
HTTP/3: client pseudo-headers restrictions.

- :method, :path and :scheme are expected exactly once and not empty
- :method and :scheme character validation is added
- :authority cannot appear more than once

5 years agoHTTP/3: refactored request parser.
Roman Arutyunyan [Fri, 22 Jan 2021 13:34:06 +0000 (16:34 +0300)]
HTTP/3: refactored request parser.

The change reduces diff to the default branch for
src/http/ngx_http_request.c and src/http/ngx_http_parse.c.

5 years agoQUIC: draft-33 salt and retry keys.
Sergey Kandaurov [Mon, 11 Jan 2021 12:25:48 +0000 (15:25 +0300)]
QUIC: draft-33 salt and retry keys.

Notably, the version negotiation table is updated to reject draft-33/QUICv1
(which requires a new TLS codepoint) unless explicitly asked to built with.

5 years agoQUIC: fixed header protection macro name.
Vladimir Homutov [Wed, 30 Dec 2020 17:47:35 +0000 (20:47 +0300)]
QUIC: fixed header protection macro name.

5 years agoQUIC: ngx_quic_bpf module.
Vladimir Homutov [Fri, 25 Dec 2020 12:01:15 +0000 (15:01 +0300)]
QUIC: ngx_quic_bpf module.

The quic kernel bpf helper inspects packet payload for DCID, extracts key
and routes the packet into socket matching the key.

Due to reuseport feature, each worker owns a personal socket, which is
identified by the same key, used to create DCID.

BPF objects are locked in RAM and are subject to RLIMIT_MEMLOCK.
The "ulimit -l" command may be used to setup proper limits, if maps
cannot be created with EPERM or updated with ETOOLONG.

5 years agoCore: added interface to linux bpf() system call.
Vladimir Homutov [Tue, 15 Dec 2020 12:23:07 +0000 (15:23 +0300)]
Core: added interface to linux bpf() system call.

It contains wrappers for operations with BPF maps and for loading BPF programs.

5 years agoQUIC: ngx_quic_module.
Vladimir Homutov [Fri, 25 Dec 2020 11:18:51 +0000 (14:18 +0300)]
QUIC: ngx_quic_module.

5 years agoQUIC: moved all quic sources into src/event/quic.
Vladimir Homutov [Fri, 25 Dec 2020 11:01:28 +0000 (14:01 +0300)]
QUIC: moved all quic sources into src/event/quic.

5 years agoQUIC: removed unused <openssl/aes.h> inclusion.
Sergey Kandaurov [Tue, 22 Dec 2020 13:41:56 +0000 (16:41 +0300)]
QUIC: removed unused <openssl/aes.h> inclusion.

The low-level API was used in early QUIC development.

5 years agoQUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104).
Sergey Kandaurov [Tue, 22 Dec 2020 09:04:16 +0000 (12:04 +0300)]
QUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104).

5 years agoQUIC: fixed logging PATH_CHALLENGE/RESPONSE and build with GCC < 5.
Sergey Kandaurov [Tue, 22 Dec 2020 09:04:15 +0000 (12:04 +0300)]
QUIC: fixed logging PATH_CHALLENGE/RESPONSE and build with GCC < 5.

5 years agoQUIC: fixed building ALPN callback without debug and http2.
Sergey Kandaurov [Tue, 22 Dec 2020 09:04:15 +0000 (12:04 +0300)]
QUIC: fixed building ALPN callback without debug and http2.

5 years agoQUIC: fixed build with OpenSSL < 1.1.1.
Sergey Kandaurov [Tue, 22 Dec 2020 09:03:43 +0000 (12:03 +0300)]
QUIC: fixed build with OpenSSL < 1.1.1.

The <openssl/kdf.h> header is available since OpenSSL 1.1.0, and HKDF API
used for separate Extract and Expand steps in TLSv1.3 - since OpenSSL 1.1.1.

5 years agoQUIC: converted to SSL_CIPHER_get_protocol_id().
Sergey Kandaurov [Mon, 21 Dec 2020 12:05:43 +0000 (15:05 +0300)]
QUIC: converted to SSL_CIPHER_get_protocol_id().

This API is available in BoringSSL for quite some time:
https://boringssl.googlesource.com/boringssl/+/3743aaf

5 years agoHTTP/3: staticize internal parsing functions.
Sergey Kandaurov [Wed, 16 Dec 2020 12:47:41 +0000 (12:47 +0000)]
HTTP/3: staticize internal parsing functions.

5 years agoHTTP/3: staticize ngx_http_v3_methods.
Sergey Kandaurov [Wed, 16 Dec 2020 12:47:38 +0000 (12:47 +0000)]
HTTP/3: staticize ngx_http_v3_methods.

5 years agoMerged with the default branch.
Sergey Kandaurov [Tue, 15 Dec 2020 16:55:43 +0000 (16:55 +0000)]
Merged with the default branch.

5 years agorelease-1.19.6 tag
Maxim Dounin [Tue, 15 Dec 2020 14:41:39 +0000 (17:41 +0300)]
release-1.19.6 tag

5 years agonginx-1.19.6-RELEASE release-1.19.6
Maxim Dounin [Tue, 15 Dec 2020 14:41:39 +0000 (17:41 +0300)]
nginx-1.19.6-RELEASE

5 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Tue, 15 Dec 2020 13:49:24 +0000 (16:49 +0300)]
Updated OpenSSL used for win32 builds.

5 years agoFixed double close of non-regular files in flv and mp4.
Maxim Dounin [Fri, 11 Dec 2020 10:42:07 +0000 (13:42 +0300)]
Fixed double close of non-regular files in flv and mp4.

With introduction of open_file_cache in 1454:f497ed7682a7, opening a file
with ngx_open_cached_file() automatically adds a cleanup handler to close
the file.  As such, calling ngx_close_file() directly for non-regular files
is no longer needed and will result in duplicate close() call.

In 1454:f497ed7682a7 ngx_close_file() call for non-regular files was removed
in the static module, but wasn't in the flv module.  And the resulting
incorrect code was later copied to the mp4 module.  Fix is to remove the
ngx_close_file() call from both modules.

Reported by Chris Newton.

5 years agoRemoved extra allocation for r->uri.
Maxim Dounin [Thu, 10 Dec 2020 17:09:39 +0000 (20:09 +0300)]
Removed extra allocation for r->uri.

The ngx_http_parse_complex_uri() function cannot make URI longer and does
not null-terminate URI, so there is no need to allocate an extra byte.  This
allocation appears to be a leftover from changes in 461:a88a3e4e158f (0.1.5),
where null-termination of r->uri and many other strings was removed.

5 years agoFixed parsing of absolute URIs with empty path (ticket #2079).
Maxim Dounin [Thu, 10 Dec 2020 17:09:30 +0000 (20:09 +0300)]
Fixed parsing of absolute URIs with empty path (ticket #2079).

When the request line contains request-target in the absolute-URI form,
it can contain path-empty instead of a single slash (see RFC 7230, RFC 3986).
Previously, the ngx_http_parse_request_line() function only accepted empty
path when there was no query string.

With this change, non-empty query is also correctly handled.  That is,
request line "GET http://example.com?foo HTTP/1.1" is accepted and results
in $uri "/" and $args "foo".

Note that $request_uri remains "?foo", similarly to how spaces in URIs
are handled.  Providing "/?foo", similarly to how "/" is provided for
"GET http://example.com HTTP/1.1", requires allocation.

5 years agoQUIC: always calculate rtt for largest acknowledged packet.
Roman Arutyunyan [Wed, 9 Dec 2020 21:26:21 +0000 (21:26 +0000)]
QUIC: always calculate rtt for largest acknowledged packet.

Previously, when processing client ACK, rtt could be calculated for a packet
different than the largest if it was missing in the sent chain.  Even though
this is an unlikely situation, rtt based on a different packet could be larger
than needed leading to bigger pto timeout and performance degradation.

5 years agoQUIC: send and process ack_delay for Initial and Handshake levels.
Roman Arutyunyan [Thu, 10 Dec 2020 14:54:53 +0000 (14:54 +0000)]
QUIC: send and process ack_delay for Initial and Handshake levels.

Previously, this only worked for Application level because before
quic-transport-30, there were the following constraints:

   Because the receiver doesn't use the ACK Delay for Initial and Handshake
   packets, a sender SHOULD send a value of 0.

   When adjusting an RTT sample using peer-reported acknowledgement delays, an
   endpoint ...  MUST ignore the ACK Delay field of the ACK frame for packets
   sent in the Initial and Handshake packet number space.

5 years agoQUIC: use client max_ack_delay when computing pto timeout.
Roman Arutyunyan [Wed, 9 Dec 2020 16:15:24 +0000 (16:15 +0000)]
QUIC: use client max_ack_delay when computing pto timeout.

Previously, server max_ack_delay was used which is wrong.

Also, level check is simplified.

5 years agoQUIC: resend handshake packets along with initial.
Roman Arutyunyan [Tue, 8 Dec 2020 17:10:22 +0000 (17:10 +0000)]
QUIC: resend handshake packets along with initial.

To speed up handshake, resend both initial and handshake packets if there's
at least one unacknowledged initial packet.

5 years agoQUIC: set the temporary flag for input frame buffers.
Roman Arutyunyan [Tue, 8 Dec 2020 14:44:41 +0000 (14:44 +0000)]
QUIC: set the temporary flag for input frame buffers.

Missing flag prevented frame data from being copied as the buffer was not
considered a memory buffer.

5 years agoSSL: fixed SSL shutdown on lingering close.
Ruslan Ermilov [Mon, 7 Dec 2020 22:43:36 +0000 (01:43 +0300)]
SSL: fixed SSL shutdown on lingering close.

Ensure c->recv is properly reset to ngx_recv if SSL_shutdown()
blocks on writing.

The bug had appeared in 554c6ae25ffc.

5 years agoQUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan [Mon, 7 Dec 2020 15:09:08 +0000 (15:09 +0000)]
QUIC: coalesce output packets into a single UDP datagram.

Now initial output packet is not padded anymore if followed by a handshake
packet.  If the datagram is still not big enough to satisfy minimum size
requirements, handshake packet is padded.

5 years agoQUIC: introduced QUIC buffers.
Roman Arutyunyan [Tue, 1 Dec 2020 19:11:01 +0000 (19:11 +0000)]
QUIC: introduced QUIC buffers.

Buffers are used to hold frame data.  They have a fixed size and are reused
after being freed.

5 years agoQUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov [Mon, 7 Dec 2020 11:06:00 +0000 (14:06 +0300)]
QUIC: fixed handling of clients connected to wildcard address.

The patch replaces c->send() occurences with c->send_chain(), because the
latter accounts for the local address, which may be different if the wildcard
listener is used.

Previously, server sent response to client using address different from
one client connected to.

5 years agoQUIC: disabling bidirectional SSL shutdown earlier.
Sergey Kandaurov [Sun, 6 Dec 2020 14:24:38 +0000 (14:24 +0000)]
QUIC: disabling bidirectional SSL shutdown earlier.

Notably, this fixes an issue with Chrome that can emit a "certificate_unknown"
alert during the SSL handshake where c->ssl->no_wait_shutdown is not yet set.

5 years agoQUIC: fixed missing quic flag on listener in the stream module.
Vladimir Homutov [Fri, 4 Dec 2020 12:19:03 +0000 (15:19 +0300)]
QUIC: fixed missing quic flag on listener in the stream module.

5 years agoHTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan [Fri, 27 Nov 2020 17:46:21 +0000 (17:46 +0000)]
HTTP/3: introduced ngx_http_v3_filter.

The filter is responsible for creating HTTP/3 response header and body.

The change removes differences to the default branch for
ngx_http_chunked_filter_module and ngx_http_header_filter_module.

5 years agoQUIC: fixed send contexts cleanup.
Vladimir Homutov [Wed, 2 Dec 2020 07:55:49 +0000 (10:55 +0300)]
QUIC: fixed send contexts cleanup.

The ngx_quic_get_send_ctx() macro takes 'level' argument, not send context
index.

5 years agoQUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov [Fri, 27 Nov 2020 15:43:36 +0000 (18:43 +0300)]
QUIC: removed ngx_quic_hexdump() macro.

Instead, appropriate format specifier for hexadecimal is used
in ngx_log_debug().

The STREAM frame "data" debug is moved into ngx_quic_log_frame(), similar
to all other frame fields debug.

5 years agoUpstream: excluded down servers from the next_upstream tries.
Ruslan Ermilov [Thu, 26 Nov 2020 21:01:20 +0000 (00:01 +0300)]
Upstream: excluded down servers from the next_upstream tries.

Previously, the number of next_upstream tries included servers marked
as "down", resulting in "no live upstreams" with the code 502 instead
of the code derived from an attempt to connect to the last tried "up"
server (ticket #2096).

5 years agoVersion bump.
Ruslan Ermilov [Thu, 26 Nov 2020 20:46:59 +0000 (23:46 +0300)]
Version bump.

5 years agoHTTP/3: eliminated r->method_start.
Roman Arutyunyan [Wed, 25 Nov 2020 17:57:43 +0000 (17:57 +0000)]
HTTP/3: eliminated r->method_start.

The field was introduced to ease parsing HTTP/3 requests.

The change reduces diff to the default branch.

5 years agorelease-1.19.5 tag
Maxim Dounin [Tue, 24 Nov 2020 15:06:34 +0000 (18:06 +0300)]
release-1.19.5 tag

5 years agonginx-1.19.5-RELEASE release-1.19.5
Maxim Dounin [Tue, 24 Nov 2020 15:06:34 +0000 (18:06 +0300)]
nginx-1.19.5-RELEASE

5 years agogRPC: RST_STREAM(NO_ERROR) handling after "trailer only" responses.
Pavel Pautov [Thu, 19 Nov 2020 02:41:16 +0000 (18:41 -0800)]
gRPC: RST_STREAM(NO_ERROR) handling after "trailer only" responses.

Similarly to the problem fixed in 2096b21fcd10 (ticket #1792),
when a "trailer only" gRPC response (that is, a response with the
END_STREAM flag in the HEADERS frame) was immediately followed by
RST_STREAM(NO_ERROR) in the data preread along with the response
header, RST_STREAM wasn't properly skipped and caused "upstream
rejected request with error 0" errors.
Observed with "unknown service" gRPC errors returned by grpc-go.

Fix is to set ctx->done if we are going to parse additional data,
so the RST_STREAM(NO_ERROR) is properly skipped.  Additionally, now
ngx_http_grpc_filter() will complain about frames sent for closed
stream if there are any.

5 years agoUse .Mt to mark up email addresses.
Sergey Kandaurov [Thu, 19 Nov 2020 17:15:22 +0000 (17:15 +0000)]
Use .Mt to mark up email addresses.

5 years agoCore: "-e" command line option.
Igor Ippolitov [Thu, 19 Nov 2020 16:59:00 +0000 (16:59 +0000)]
Core: "-e" command line option.

When installing or running from a non-root user it is sometimes required to
override default, compiled in error log path. There was no way to do this
without rebuilding the binary (ticket #147).

This patch introduced "-e" command line option which allows one to override
compiled in error log path.

5 years agoHTTP/3: null-terminate empty header value.
Roman Arutyunyan [Tue, 17 Nov 2020 20:54:10 +0000 (20:54 +0000)]
HTTP/3: null-terminate empty header value.

Header value returned from the HTTP parser is expected to be null-terminated or
have a spare byte after the value bytes.  When an empty header value was passed
by client in a literal header representation, neither was true.  This could
result in segfault.  The fix is to assign a literal empty null-terminated
string in this case.

Thanks to Andrey Kolyshkin.

5 years agoHTTP/3: finalize chunked response body chain with NULL.
Roman Arutyunyan [Tue, 17 Nov 2020 21:12:36 +0000 (21:12 +0000)]
HTTP/3: finalize chunked response body chain with NULL.

Unfinalized chain could result in segfault.  The problem was introduced in
ef83990f0e25.

Patch by Andrey Kolyshkin.

5 years agoMerged with the default branch.
Sergey Kandaurov [Tue, 24 Nov 2020 17:19:40 +0000 (17:19 +0000)]
Merged with the default branch.

5 years agoQUIC: rejecting zero-length packets with PROTOCOL_VIOLATION.
Sergey Kandaurov [Wed, 18 Nov 2020 20:56:11 +0000 (20:56 +0000)]
QUIC: rejecting zero-length packets with PROTOCOL_VIOLATION.

Per the latest post draft-32 specification updates on the topic:
https://github.com/quicwg/base-drafts/pull/4391

5 years agoQUIC: simplified and streamlined ngx_quic_decrypt().
Sergey Kandaurov [Tue, 17 Nov 2020 21:33:16 +0000 (21:33 +0000)]
QUIC: simplified and streamlined ngx_quic_decrypt().

Both clearflags and badflags are removed.  It makes a little sense now
to keep them as intermediate storage.

5 years agoQUIC: merged create_long/short_packet() functions.
Sergey Kandaurov [Tue, 17 Nov 2020 21:33:12 +0000 (21:33 +0000)]
QUIC: merged create_long/short_packet() functions.

They no longer differ.

5 years agoQUIC: macros for manipulating header protection and reserved bits.
Sergey Kandaurov [Tue, 17 Nov 2020 21:32:22 +0000 (21:32 +0000)]
QUIC: macros for manipulating header protection and reserved bits.

This gets rid of magic numbers from quic protection and allows to push down
header construction specifics further to quic transport.

5 years agoQUIC: hide header creation internals in ngx_event_quic_transport.c.
Sergey Kandaurov [Tue, 17 Nov 2020 21:32:06 +0000 (21:32 +0000)]
QUIC: hide header creation internals in ngx_event_quic_transport.c.

It doesn't make sense to expose the header type in a public function.

5 years agoQUIC: refactored long header parsing.
Sergey Kandaurov [Tue, 17 Nov 2020 21:32:04 +0000 (21:32 +0000)]
QUIC: refactored long header parsing.

The largely duplicate type-specific functions ngx_quic_parse_initial_header(),
ngx_quic_parse_handshake_header(), and a missing one for 0-RTT, were merged.
The new order of functions listed in ngx_event_quic_transport.c reflects this.

|_ ngx_quic_parse_long_header    - version-invariant long header fields
\_ ngx_quic_supported_version    - a helper to decide we can go further
\_ ngx_quic_parse_long_header_v1 - QUICv1-specific long header fields

0-RTT packets previously appeared as Handshake are now logged as appropriate:
 *1 quic packet rx long flags:db version:ff00001d
 *1 quic packet rx early len:870

Logging SCID/DCID is no longer duplicated as were seen with Initial packets.

5 years agoQUIC: sorted header parsing functions in order of appearance.
Sergey Kandaurov [Tue, 17 Nov 2020 21:31:51 +0000 (21:31 +0000)]
QUIC: sorted header parsing functions in order of appearance.

No functional changes.

5 years agoQUIC: removed macros for stream limits unused since c5324bb3a704.
Sergey Kandaurov [Tue, 17 Nov 2020 12:22:24 +0000 (12:22 +0000)]
QUIC: removed macros for stream limits unused since c5324bb3a704.

5 years agoCore: hide "struct ngx_quic_connection_s" and further reduce diffs.
Sergey Kandaurov [Fri, 13 Nov 2020 15:11:29 +0000 (15:11 +0000)]
Core: hide "struct ngx_quic_connection_s" and further reduce diffs.

As with the previous change, it became feasible with feec2cc762f6
that removes ngx_quic_connection_t from ngx_connection_s.

5 years agoCore: reduced diff to the default branch.
Sergey Kandaurov [Fri, 13 Nov 2020 15:11:27 +0000 (15:11 +0000)]
Core: reduced diff to the default branch.

It became feasible to reduce after feec2cc762f6 that
removes ngx_quic_connection_t from ngx_connection_s.

5 years agoQUIC: microoptimization in varint parsing.
Sergey Kandaurov [Fri, 13 Nov 2020 13:24:45 +0000 (13:24 +0000)]
QUIC: microoptimization in varint parsing.

Removed a useless mask from the value being shifted, since it is 1-byte wide.

5 years agoFixed generating chunked response after 46e3542d51b3.
Roman Arutyunyan [Tue, 10 Nov 2020 20:42:45 +0000 (20:42 +0000)]
Fixed generating chunked response after 46e3542d51b3.

If trailers were missing and a chain carrying the last_buf flag had no data
in it, then last HTTP/1 chunk was broken.  The problem was introduced while
implementing HTTP/3 response body generation.

The change fixes the issue and reduces diff to the mainline nginx.

5 years agoQUIC: generate default stateless reset token key.
Roman Arutyunyan [Wed, 11 Nov 2020 21:08:48 +0000 (21:08 +0000)]
QUIC: generate default stateless reset token key.

Previously, if quic_stateless_reset_token_key was empty or unspecified,
initial stateless reset token was not generated.  However subsequent tokens
were generated with empty key, which resulted in error with certain SSL
libraries, for example OpenSSL.

Now a random 32-byte stateless reset token key is generated if none is
specified in the configuration.  As a result, stateless reset tokens are now
generated for all server ids.

5 years agoQUIC: removed comment.
Roman Arutyunyan [Wed, 11 Nov 2020 19:40:41 +0000 (19:40 +0000)]
QUIC: removed comment.

5 years agoQUIC: added quic_stateless_reset_token_key Stream directive.
Roman Arutyunyan [Wed, 11 Nov 2020 19:39:23 +0000 (19:39 +0000)]
QUIC: added quic_stateless_reset_token_key Stream directive.

A similar directive is already available in HTTP.

5 years agoQUIC: reallocate qc->dcid on retry.
Roman Arutyunyan [Wed, 11 Nov 2020 17:56:02 +0000 (17:56 +0000)]
QUIC: reallocate qc->dcid on retry.

Previously new dcid was generated in the same memory that was allocated for
qc->dcid when creating the QUIC connection.  However this memory was also
referenced by initial_source_connection_id and retry_source_connection_id
transport parameters.  As a result these parameters changed their values after
retry which broke the protocol.

5 years agoQUIC: renamed c->qs to c->quic.
Roman Arutyunyan [Tue, 10 Nov 2020 19:40:00 +0000 (19:40 +0000)]
QUIC: renamed c->qs to c->quic.

5 years agoQUIC: got rid of the c->quic field.
Roman Arutyunyan [Tue, 10 Nov 2020 18:38:42 +0000 (18:38 +0000)]
QUIC: got rid of the c->quic field.

Now QUIC connection is accessed via the c->udp field.

5 years agoQUIC: connection multiplexing per port.
Roman Arutyunyan [Wed, 11 Nov 2020 11:57:50 +0000 (11:57 +0000)]
QUIC: connection multiplexing per port.

Also, connection migration within a single worker is implemented.

5 years agoConfigure: shared sources for addon modules.
Maxim Dounin [Tue, 10 Nov 2020 14:13:20 +0000 (17:13 +0300)]
Configure: shared sources for addon modules.

Addon modules, both dynamic and static, can now use shared source files.
Shared sources result in only one make rule even if specified several
times in different modules.

5 years agoConfigure: initialization of NGX_ADDON_SRCS.
Maxim Dounin [Tue, 10 Nov 2020 14:13:17 +0000 (17:13 +0300)]
Configure: initialization of NGX_ADDON_SRCS.

5 years agoConfigure: style.
Maxim Dounin [Tue, 10 Nov 2020 14:13:14 +0000 (17:13 +0300)]
Configure: style.

5 years agoRequest body: removed error assumption (ticket #2058).
Maxim Dounin [Mon, 9 Nov 2020 19:41:54 +0000 (22:41 +0300)]
Request body: removed error assumption (ticket #2058).

Before introduction of request body filter in 42d9beeb22db, the only
possible return code from the ngx_http_request_body_filter() call
without actual buffers was NGX_HTTP_INTERNAL_SERVER_ERROR, and
the code in ngx_http_read_client_request_body() hardcoded the only
possible error to simplify the code of initial call to set rb->rest.

This is no longer true after introduction of request body filters though,
as a request body filter might need to return other errors, such as 403.
Fix is to preserve the error code actually returned by the call
instead of assuming 500.

5 years agoRequest body: improved logging.
Maxim Dounin [Mon, 9 Nov 2020 19:40:53 +0000 (22:40 +0300)]
Request body: improved logging.

Added logging before returning NGX_HTTP_INTERNAL_SERVER_ERROR if there
are busy buffers after a request body flush.  This should never happen
with current code, though bugs can be introduced by 3rd party modules.
Make sure debugging will be easy enough.

5 years agoQUIC: renamed field and function related to client ids.
Roman Arutyunyan [Mon, 9 Nov 2020 18:58:29 +0000 (18:58 +0000)]
QUIC: renamed field and function related to client ids.

Particularly, c->curr_seqnum is renamed to c->client_seqnum and
ngx_quic_alloc_connection_id() is renamed to ngx_quic_alloc_client_id().

5 years agoQUIC: multiple versions support in ALPN.
Sergey Kandaurov [Mon, 9 Nov 2020 21:32:56 +0000 (00:32 +0300)]
QUIC: multiple versions support in ALPN.

Previously, a version based on NGX_QUIC_DRAFT_VERSION was always set.
Now it is taken from the negotiated QUIC version that may differ.

5 years agoQUIC: multiple versions support.
Sergey Kandaurov [Mon, 9 Nov 2020 21:23:04 +0000 (00:23 +0300)]
QUIC: multiple versions support.

Draft-29 and beyond are now treated as compatible versions.

5 years agoQUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov [Mon, 9 Nov 2020 21:20:44 +0000 (00:20 +0300)]
QUIC: preparatory changes for multiple QUIC versions support.

A negotiated version is decoupled from NGX_QUIC_VERSION and, if supported,
now stored in c->quic->version after packets processing.  It is then used
to create long header packets.  Otherwise, the list of supported versions
(which may be many now) is sent in the Version Negotiation packet.

All packets in the connection are expected to have the same version.
Incoming packets with mismatched version are now rejected.

5 years agoSSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov [Fri, 6 Nov 2020 20:44:54 +0000 (23:44 +0300)]
SSL: fixed non-working SSL shutdown on lingering close.

When doing lingering close, the socket was first shut down for writing,
so SSL shutdown initiated after lingering close was not able to send
the close_notify alerts (ticket #2056).

The fix is to call ngx_ssl_shutdown() before shutting down the socket.

5 years agoRemoved dead code from ngx_http_set_keepalive().
Ruslan Ermilov [Fri, 6 Nov 2020 20:44:47 +0000 (23:44 +0300)]
Removed dead code from ngx_http_set_keepalive().

The code removed became dead after 98f03cd8d6cc (0.8.14),
circa when the request reference counting was introduced.

5 years agoQUIC: added proper logging of special values.
Vladimir Homutov [Fri, 6 Nov 2020 15:21:31 +0000 (18:21 +0300)]
QUIC: added proper logging of special values.

A number of unsigned variables has a special value, usually -1 or some maximum,
which produces huge numeric value in logs and makes them hard to read.

In order to distinguish such values in log, they are casted to the signed type
and printed as literal '-1'.

5 years agoQUIC: fixed address validation issues in a new connection.
Sergey Kandaurov [Mon, 2 Nov 2020 17:38:11 +0000 (17:38 +0000)]
QUIC: fixed address validation issues in a new connection.

The client address validation didn't complete with a valid token,
which was broken after packet processing refactoring in d0d3fc0697a0.

An invalid or expired token was treated as a connection error.
Now we proceed as outlined in draft-ietf-quic-transport-32,
section 8.1.3 "Address Validation for Future Connections" below,
which is unlike validating the client address using Retry packets.

   When a server receives an Initial packet with an address validation
   token, it MUST attempt to validate the token, unless it has already
   completed address validation.  If the token is invalid then the
   server SHOULD proceed as if the client did not have a validated
   address, including potentially sending a Retry.

The connection is now closed in this case on internal errors only.

5 years agoQUIC: refactored key handling.
Sergey Kandaurov [Mon, 2 Nov 2020 15:21:34 +0000 (18:21 +0300)]
QUIC: refactored key handling.

All key handling functionality is moved into ngx_quic_protection.c.
Public structures from ngx_quic_protection.h are now private and new
methods are available to manipulate keys.

A negotiated cipher is cached in QUIC connection from the set secret callback
to avoid calling SSL_get_current_cipher() on each encrypt/decrypt operation.
This also reduces the number of unwanted c->ssl->connection occurrences.

5 years agoQUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov [Thu, 29 Oct 2020 21:50:49 +0000 (21:50 +0000)]
QUIC: refactored SSL_do_handshake() handling.

No functional changes.

5 years agoQUIC: passing ssl_conn to SSL_get0_alpn_selected() directly.
Sergey Kandaurov [Thu, 29 Oct 2020 21:50:19 +0000 (21:50 +0000)]
QUIC: passing ssl_conn to SSL_get0_alpn_selected() directly.

No functional changes.

5 years agoMerged with the default branch.
Sergey Kandaurov [Thu, 29 Oct 2020 14:53:58 +0000 (14:53 +0000)]
Merged with the default branch.

5 years agoQUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan [Thu, 29 Oct 2020 14:25:02 +0000 (14:25 +0000)]
QUIC: handle more frames in ngx_quic_resend_frames().

When a packet is declared lost, its frames are handled differently according to
13.3. Retransmission of Information.

5 years agoQUIC: avoided retransmission of stale ack frames.
Vladimir Homutov [Wed, 28 Oct 2020 11:22:51 +0000 (14:22 +0300)]
QUIC: avoided retransmission of stale ack frames.

Acknowledgments are regenerated using the most recent data available.

5 years agoCore: added format specifiers to output binary data as hex.
Vladimir Homutov [Wed, 28 Oct 2020 07:56:11 +0000 (10:56 +0300)]
Core: added format specifiers to output binary data as hex.

Now "s", "V", and "v" format specifiers may be prefixed with "x" (lowercase)
or "X" (uppercase) to output corresponding data in hexadecimal format.

In collaboration with Maxim Dounin.

5 years agoVersion bump.
Vladimir Homutov [Thu, 5 Nov 2020 19:37:27 +0000 (22:37 +0300)]
Version bump.

5 years agoQUIC: changed STREAM frame debugging.
Roman Arutyunyan [Tue, 27 Oct 2020 18:21:36 +0000 (18:21 +0000)]
QUIC: changed STREAM frame debugging.

5 years agoQUIC: changed ACK frame debugging.
Roman Arutyunyan [Wed, 28 Oct 2020 09:15:04 +0000 (09:15 +0000)]
QUIC: changed ACK frame debugging.

Previously ACK ranges were logged as a gap/range sequence.  Now these
values are expanded to packet number ranges for easier reading.

5 years agorelease-1.19.4 tag
Maxim Dounin [Tue, 27 Oct 2020 15:09:20 +0000 (18:09 +0300)]
release-1.19.4 tag

5 years agonginx-1.19.4-RELEASE release-1.19.4
Maxim Dounin [Tue, 27 Oct 2020 15:09:20 +0000 (18:09 +0300)]
nginx-1.19.4-RELEASE

5 years agoQUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan [Tue, 27 Oct 2020 13:24:00 +0000 (13:24 +0000)]
QUIC: unified range format for rx and tx ACK frames.

Previously, tx ACK frames held ranges in an array of ngx_quic_ack_range_t,
while rx ACK frames held ranges in the serialized format.  Now serialized format
is used for both types of frames.

5 years agoQUIC: cleanup send context properly.
Vladimir Homutov [Mon, 26 Oct 2020 21:14:24 +0000 (00:14 +0300)]
QUIC: cleanup send context properly.

The patch resets ctx->frames queue, which may contain frames.  It was possible
that congestion or amplification limits prevented all frames to be sent.

Retransmitted frames could be accounted twice as inflight: first time in
ngx_quic_congestion_lost() called from ngx_quic_resend_frames(), and later
from ngx_quic_discard_ctx().

5 years agoQUIC: added push event afer the address was validated.
Vladimir Homutov [Mon, 26 Oct 2020 21:00:56 +0000 (00:00 +0300)]
QUIC: added push event afer the address was validated.

This allows to continue processing when the anti-amplification limit was hit.

5 years agoQUIC: updated anti-amplification check for draft 32.
Vladimir Homutov [Mon, 26 Oct 2020 20:58:34 +0000 (23:58 +0300)]
QUIC: updated anti-amplification check for draft 32.

This accounts for the following change:

   *  Require expansion of datagrams to ensure that a path supports at
      least 1200 bytes:

      -  During the handshake ack-eliciting Initial packets from the
         server need to be expanded

5 years agoQUIC: got rid of "pkt" abbreviation in logs.
Vladimir Homutov [Mon, 26 Oct 2020 20:47:49 +0000 (23:47 +0300)]
QUIC: got rid of "pkt" abbreviation in logs.

5 years agoQUIC: added "rx" and "tx" prefixes to packet debug.
Vladimir Homutov [Mon, 26 Oct 2020 20:47:16 +0000 (23:47 +0300)]
QUIC: added "rx" and "tx" prefixes to packet debug.

5 years agoQUIC: added connection state debug to event handlers.
Vladimir Homutov [Mon, 26 Oct 2020 20:17:54 +0000 (23:17 +0300)]
QUIC: added connection state debug to event handlers.

5 years agoQUIC: added logging of a declined packet without retry token.
Vladimir Homutov [Sun, 25 Oct 2020 21:34:24 +0000 (00:34 +0300)]
QUIC: added logging of a declined packet without retry token.