]> git.kaiwu.me - nginx.git/log
nginx.git
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 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 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 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 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.

5 years agoQUIC: revised value separators in debug and error messages.
Vladimir Homutov [Tue, 27 Oct 2020 11:12:31 +0000 (14:12 +0300)]
QUIC: revised value separators in debug and error messages.

All values are prefixed with name and separated from it using colon.
Multiple values are listed without commas in between.

Rationale: this greatly simplifies log parsing for analysis.

5 years agoQUIC: single function for frame debug logging.
Vladimir Homutov [Tue, 27 Oct 2020 11:32:08 +0000 (14:32 +0300)]
QUIC: single function for frame debug logging.

The function may be called for any initialized frame, both rx and tx.

While there, shortened level names.

5 years agoQUIC: optimized acknowledgement generation.
Vladimir Homutov [Fri, 23 Oct 2020 14:08:50 +0000 (17:08 +0300)]
QUIC: optimized acknowledgement generation.

For application level packets, only every second packet is now acknowledged,
respecting max ack delay.

13.2.1 Sending ACK Frames

   In order to assist loss detection at the sender, an endpoint SHOULD
   generate and send an ACK frame without delay when it receives an ack-
   eliciting packet either:

   *  when the received packet has a packet number less than another
      ack-eliciting packet that has been received, or

   *  when the packet has a packet number larger than the highest-
      numbered ack-eliciting packet that has been received and there are
      missing packets between that packet and this packet.

13.2.2.  Acknowledgement Frequency

    A receiver SHOULD send an ACK frame after receiving at least two
    ack-eliciting packets.

5 years agoQUIC: added missing "quic" prefix in debug messages.
Vladimir Homutov [Fri, 23 Oct 2020 15:22:01 +0000 (18:22 +0300)]
QUIC: added missing "quic" prefix in debug messages.

5 years agoSSL: ssl_reject_handshake directive (ticket #195).
Maxim Dounin [Thu, 22 Oct 2020 15:02:28 +0000 (18:02 +0300)]
SSL: ssl_reject_handshake directive (ticket #195).

In some cases it might be needed to reject SSL handshake based on SNI
server name provided, for example, to make sure an invalid certificate
is not returned to clients trying to contact a name-based virtual server
without SSL configured.  Previously, a "ssl_ciphers aNULL;" was used for
this.  This workaround, however, is not compatible with TLSv1.3, in
particular, when using BoringSSL, where it is not possible to configure
TLSv1.3 ciphers at all.

With this change, the ssl_reject_handshake directive is introduced,
which instructs nginx to reject SSL handshakes with an "unrecognized_name"
alert in a particular server block.

For example, to reject handshake with names other than example.com,
one can use the following configuration:

    server {
        listen 443 ssl;
        ssl_reject_handshake on;
    }

    server {
        listen 443 ssl;
        server_name example.com;
        ssl_certificate example.com.crt;
        ssl_certificate_key example.com.key;
    }

The following configuration can be used to reject all SSL handshakes
without SNI server name provided:

    server {
        listen 443 ssl;
        ssl_reject_handshake on;
    }

    server {
        listen 443 ssl;
        server_name ~^;
        ssl_certificate example.crt;
        ssl_certificate_key example.key;
    }

Additionally, the ssl_reject_handshake directive makes configuring
certificates for the default server block optional.  If no certificates
are configured in the default server for a given listening socket,
certificates must be defined in all non-default server blocks with
the listening socket in question.

5 years agoStream: proxy_ssl_conf_command directive.
Maxim Dounin [Thu, 22 Oct 2020 15:00:27 +0000 (18:00 +0300)]
Stream: proxy_ssl_conf_command directive.

Similarly to ssl_conf_command, proxy_ssl_conf_command can be used to
set arbitrary OpenSSL configuration parameters as long as nginx is
compiled with OpenSSL 1.0.2 or later, when connecting to upstream
servers with SSL.  Full list of available configuration commands
can be found in the SSL_CONF_cmd manual page
(https://www.openssl.org/docs/man1.1.1/man3/SSL_CONF_cmd.html).

5 years agoUpstream: proxy_ssl_conf_command and friends.
Maxim Dounin [Thu, 22 Oct 2020 15:00:23 +0000 (18:00 +0300)]
Upstream: proxy_ssl_conf_command and friends.

Similarly to ssl_conf_command, proxy_ssl_conf_command (grpc_ssl_conf_command,
uwsgi_ssl_conf_command) can be used to set arbitrary OpenSSL configuration
parameters as long as nginx is compiled with OpenSSL 1.0.2 or later,
when connecting to upstream servers with SSL.  Full list of available
configuration commands can be found in the SSL_CONF_cmd manual page
(https://www.openssl.org/docs/man1.1.1/man3/SSL_CONF_cmd.html).

5 years agoSSL: ssl_conf_command directive.
Maxim Dounin [Thu, 22 Oct 2020 15:00:22 +0000 (18:00 +0300)]
SSL: ssl_conf_command directive.

With the ssl_conf_command directive it is now possible to set
arbitrary OpenSSL configuration parameters as long as nginx is compiled
with OpenSSL 1.0.2 or later.  Full list of available configuration
commands can be found in the SSL_CONF_cmd manual page
(https://www.openssl.org/docs/man1.1.1/man3/SSL_CONF_cmd.html).

In particular, this allows configuring PrioritizeChaCha option
(ticket #1445):

    ssl_conf_command Options PrioritizeChaCha;

It can be also used to configure TLSv1.3 ciphers in OpenSSL,
which fails to configure them via the SSL_CTX_set_cipher_list()
interface (ticket #1529):

    ssl_conf_command Ciphersuites TLS_CHACHA20_POLY1305_SHA256;

Configuration commands are applied after nginx own configuration
for SSL, so they can be used to override anything set by nginx.
Note though that configuring OpenSSL directly with ssl_conf_command
might result in a behaviour nginx does not expect, and should be
done with care.

5 years agoCore: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.
Maxim Dounin [Thu, 22 Oct 2020 15:00:20 +0000 (18:00 +0300)]
Core: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.

With this change, it is now possible to use ngx_conf_merge_ptr_value()
to merge keyval arrays.  This change actually follows much earlier
changes in ngx_conf_merge_ptr_value() and ngx_conf_set_str_array_slot()
in 1452:cd586e963db0 (0.6.10) and 1701:40d004d95d88 (0.6.22).

To preserve compatibility with existing 3rd party modules, both NULL
and NGX_CONF_UNSET_PTR are accepted for now.

5 years agoQUIC: updated README.
Sergey Kandaurov [Thu, 22 Oct 2020 11:55:15 +0000 (12:55 +0100)]
QUIC: updated README.

 - ACK ranges are implemented
 - up to draft-32 is now supported
 - removed mentions of early alpha quality and further cleanup

5 years agoQUIC: restored proper usage of ngx_quic_drop_ack_ranges().
Sergey Kandaurov [Thu, 22 Oct 2020 10:05:50 +0000 (11:05 +0100)]
QUIC: restored proper usage of ngx_quic_drop_ack_ranges().

ACK Ranges are again managed based on the remembered Largest Acknowledged
sent in the packet being acknowledged, which partially reverts c01964fd7b8b.

5 years agoQUIC: fixed dropping output ack ranges on input ack.
Vladimir Homutov [Wed, 21 Oct 2020 17:39:25 +0000 (20:39 +0300)]
QUIC: fixed dropping output ack ranges on input ack.

While there, additional debug messages were added.

5 years agoQUIC: added macro for unset packet number.
Vladimir Homutov [Wed, 21 Oct 2020 15:44:25 +0000 (18:44 +0300)]
QUIC: added macro for unset packet number.

5 years agoQUIC: drop acknowledged ranges.
Vladimir Homutov [Tue, 20 Oct 2020 15:53:25 +0000 (18:53 +0300)]
QUIC: drop acknowledged ranges.

13.2.4.  Limiting Ranges by Tracking ACK Frames

   When a packet containing an ACK frame is sent, the largest
   acknowledged in that frame may be saved.  When a packet containing an
   ACK frame is acknowledged, the receiver can stop acknowledging
   packets less than or equal to the largest acknowledged in the sent
   ACK frame.

5 years agoQUIC: added ACK frame range support.
Vladimir Homutov [Tue, 20 Oct 2020 15:53:00 +0000 (18:53 +0300)]
QUIC: added ACK frame range support.

The history of acknowledged packet is kept in send context as ranges.
Up to NGX_QUIC_MAX_RANGES ranges is stored.

As a result, instead of separate ack frames, single frame with ranges
is sent.

5 years agoQUIC: expand UDP datagrams with an ack-eliciting Initial packet.
Sergey Kandaurov [Wed, 21 Oct 2020 11:46:23 +0000 (12:46 +0100)]
QUIC: expand UDP datagrams with an ack-eliciting Initial packet.

Per draft-ietf-quic-transport-32 on the topic:

:   Similarly, a server MUST expand the payload of all UDP datagrams carrying
:   ack-eliciting Initial packets to at least the smallest allowed maximum
:   datagram size of 1200 bytes.

5 years agoQUIC: teach how to compute only the length of created QUIC headers.
Sergey Kandaurov [Wed, 21 Oct 2020 11:03:23 +0000 (12:03 +0100)]
QUIC: teach how to compute only the length of created QUIC headers.

It will be used for precise expansion of UDP datagram payload.

5 years agoQUIC: simplified ngx_quic_create_long_header().
Sergey Kandaurov [Wed, 21 Oct 2020 11:03:22 +0000 (12:03 +0100)]
QUIC: simplified ngx_quic_create_long_header().

As seen in the quic-transport draft, which this implementation follows:
Initial packets sent by the server MUST set the Token Length field to zero.

5 years agoQUIC: avoided excessive initialization in ngx_quic_send_frames().
Sergey Kandaurov [Wed, 21 Oct 2020 11:03:22 +0000 (12:03 +0100)]
QUIC: avoided excessive initialization in ngx_quic_send_frames().

A zero-length token was used to initialize a prezeroed packet header.

5 years agoQUIC: sorted ngx_quic_send_frames() declarations.
Sergey Kandaurov [Wed, 21 Oct 2020 11:03:21 +0000 (12:03 +0100)]
QUIC: sorted ngx_quic_send_frames() declarations.

5 years agoQUIC: account packet header length in amplification limit.
Vladimir Homutov [Mon, 19 Oct 2020 09:19:38 +0000 (12:19 +0300)]
QUIC: account packet header length in amplification limit.

This is the restoration of 02ee77f8d53d accidentally reverted by 93be5658a250.

5 years agoQUIC: reverted previous 3 commits.
Vladimir Homutov [Mon, 19 Oct 2020 07:32:53 +0000 (10:32 +0300)]
QUIC: reverted previous 3 commits.

Changes were intended for the test repository.

5 years agotry: --skiptests
Vladimir Homutov [Mon, 19 Oct 2020 07:10:21 +0000 (10:10 +0300)]
try:   --skiptests

5 years agoQUIC: added ACK frame range support.
Vladimir Homutov [Wed, 14 Oct 2020 20:21:36 +0000 (23:21 +0300)]
QUIC: added ACK frame range support.

The history of acknowledged packet is kept in send context as ranges.
Up to NGX_QUIC_MAX_RANGES ranges is stored.

As a result, instead of separate ack frames, single frame with ranges
is sent.

5 years agoCpp test: added stream.
Ruslan Ermilov [Tue, 13 Oct 2020 04:44:09 +0000 (07:44 +0300)]
Cpp test: added stream.

5 years agoLimit req: unlocking of nodes on complex value errors.
Maxim Dounin [Thu, 8 Oct 2020 14:44:34 +0000 (17:44 +0300)]
Limit req: unlocking of nodes on complex value errors.

Previously, if there were multiple limits configured, errors in
ngx_http_complex_value() during processing of a non-first limit
resulted in reference count leak in shared memory nodes of already
processed limits.  Fix is to explicity unlock relevant nodes, much
like we do when rejecting requests.

5 years agoMail: proxy_smtp_auth directive.
Maxim Dounin [Sat, 3 Oct 2020 18:04:57 +0000 (21:04 +0300)]
Mail: proxy_smtp_auth directive.

The proxy_smtp_auth directive instructs nginx to authenticate users
on backend via the AUTH command (using the PLAIN SASL mechanism),
similar to what is normally done for IMAP and POP3.

If xclient is enabled along with proxy_smtp_auth, the XCLIENT command
won't try to send the LOGIN parameter.

5 years agoVersion bump.
Maxim Dounin [Sat, 3 Oct 2020 18:01:12 +0000 (21:01 +0300)]
Version bump.

5 years agorelease-1.19.3 tag
Maxim Dounin [Tue, 29 Sep 2020 14:32:10 +0000 (17:32 +0300)]
release-1.19.3 tag

5 years agonginx-1.19.3-RELEASE release-1.19.3
Maxim Dounin [Tue, 29 Sep 2020 14:32:10 +0000 (17:32 +0300)]
nginx-1.19.3-RELEASE

5 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Tue, 29 Sep 2020 12:56:16 +0000 (15:56 +0300)]
Updated OpenSSL used for win32 builds.

5 years agoProxy: error checking for array init, missed in 7716:d6a5e14aa3e4.
Maxim Dounin [Tue, 29 Sep 2020 12:54:09 +0000 (15:54 +0300)]
Proxy: error checking for array init, missed in 7716:d6a5e14aa3e4.

Found by Coverity (CID 1467637).

5 years agoUserid: userid_flags fixup.
Maxim Dounin [Tue, 29 Sep 2020 12:52:18 +0000 (15:52 +0300)]
Userid: userid_flags fixup.

In 7717:e3e8b8234f05, the 1st bit was incorrectly used.  It shouldn't
be used for bitmask values, as it is used by NGX_CONF_BITMASK_SET.

Additionally, special value "off" added to make it possible to clear
inherited userid_flags value.

5 years agoResolver: improved error messages (ticket #2024).
Maxim Dounin [Mon, 28 Sep 2020 14:41:22 +0000 (17:41 +0300)]
Resolver: improved error messages (ticket #2024).

5 years agoUserid: userid_flags directive to set cookie flags.
Maxim Dounin [Mon, 28 Sep 2020 14:07:48 +0000 (17:07 +0300)]
Userid: userid_flags directive to set cookie flags.

5 years agoProxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov [Sun, 27 Sep 2020 20:21:11 +0000 (23:21 +0300)]
Proxy: added the "proxy_cookie_flags" directive.

5 years agoProxy: changed interface of some internal functions.
Ruslan Ermilov [Sun, 27 Sep 2020 20:21:10 +0000 (23:21 +0300)]
Proxy: changed interface of some internal functions.

This is in preparation for the next change.

Also, moved optimization from ngx_http_proxy_rewrite_regex_handler()
to ngx_http_proxy_rewrite().