]> git.kaiwu.me - nginx.git/log
nginx.git
6 years agoFixed header creation for header_only responses in HTTP/3.
Roman Arutyunyan [Thu, 19 Mar 2020 12:03:09 +0000 (15:03 +0300)]
Fixed header creation for header_only responses in HTTP/3.

6 years agoMAX_DATA frame parser/handler.
Sergey Kandaurov [Wed, 18 Mar 2020 20:26:26 +0000 (23:26 +0300)]
MAX_DATA frame parser/handler.

6 years agoAdded parsing of STREAMS BLOCKED frames.
Vladimir Homutov [Thu, 19 Mar 2020 08:15:43 +0000 (11:15 +0300)]
Added parsing of STREAMS BLOCKED frames.

While there, added hex prefix for debug to avoid frame type confusion.

6 years agoImplemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov [Wed, 18 Mar 2020 20:07:40 +0000 (23:07 +0300)]
Implemented send_alert callback, CONNECTION_CLOSE writer.

The callback produces a CONNECTION_CLOSE frame, as per quic-tls-24#section-4.9.

6 years agoAdded copying addr_text to QUIC stream connections.
Roman Arutyunyan [Wed, 18 Mar 2020 17:28:28 +0000 (20:28 +0300)]
Added copying addr_text to QUIC stream connections.

Now $remote_addr holds client address.

6 years agoHTTP/3 $request_line variable.
Roman Arutyunyan [Wed, 18 Mar 2020 17:22:16 +0000 (20:22 +0300)]
HTTP/3 $request_line variable.

6 years agoMoved setting QUIC methods to runtime.
Roman Arutyunyan [Wed, 18 Mar 2020 13:37:16 +0000 (16:37 +0300)]
Moved setting QUIC methods to runtime.

This allows listening to both https and http3 in the same server.
Also, the change eliminates the ssl_quic directive.

6 years agoAdded parsing of RESET_STREAM and STOP_SENDING frames
Vladimir Homutov [Wed, 18 Mar 2020 13:35:11 +0000 (16:35 +0300)]
Added parsing of RESET_STREAM and STOP_SENDING frames

6 years agoFixed pointer increment while parsing HTTP/3 header.
Roman Arutyunyan [Wed, 18 Mar 2020 12:28:20 +0000 (15:28 +0300)]
Fixed pointer increment while parsing HTTP/3 header.

6 years agoImplemented creation of server unidirectional streams.
Vladimir Homutov [Wed, 18 Mar 2020 10:49:39 +0000 (13:49 +0300)]
Implemented creation of server unidirectional streams.

The ngx_quic_create_stream() function is a generic function extracted from
the ngx_quic_handle_stream_frame() function.

6 years agoFixed HTTP/3 server stream creation.
Roman Arutyunyan [Wed, 18 Mar 2020 11:10:44 +0000 (14:10 +0300)]
Fixed HTTP/3 server stream creation.

6 years agoRemoved comment.
Roman Arutyunyan [Wed, 18 Mar 2020 11:09:50 +0000 (14:09 +0300)]
Removed comment.

6 years agoRefactored HTTP/3 parser.
Roman Arutyunyan [Wed, 18 Mar 2020 10:46:35 +0000 (13:46 +0300)]
Refactored HTTP/3 parser.

6 years agoStyle and handlers.
Vladimir Homutov [Wed, 18 Mar 2020 10:02:19 +0000 (13:02 +0300)]
Style and handlers.

Cleanup in ngx_event_quic.c:
    + reorderded functions, structures
    + added missing prototypes
    + added separate handlers for each frame type
    + numerous indentation/comments/TODO fixes
    + removed non-implemented qc->state and corresponding enum;
        this requires deep thinking, stub was unused.
    + streams inside quic connection are now in own structure

6 years agoExtracted transport part of the code into separate file.
Vladimir Homutov [Wed, 18 Mar 2020 09:58:27 +0000 (12:58 +0300)]
Extracted transport part of the code into separate file.

All code dealing with serializing/deserializing
is moved int srv/event/ngx_event_quic_transport.c/h file.

All macros for dealing with data are internal to source file.

The header file exposes frame types and error codes.

The exported functions are currently packet header parsers and writers
and frames parser/writer.

The ngx_quic_header_t structure is updated with 'log' member. This avoids
passing extra argument to parsing functions that need to report errors.

6 years agoFirefox fixes.
Vladimir Homutov [Tue, 17 Mar 2020 11:10:37 +0000 (14:10 +0300)]
Firefox fixes.

 + support for more than one initial packet
 + workaround for trailing zeroes in packet
 + ignore application data packet if no keys yet (issue in draft 27/ff nightly)
 + fixed PING frame parser
 + STREAM frames need to be acknowledged

The following HTTP configuration is used for firefox (v74):

http {

    ssl_certificate_key localhost.key;
    ssl_certificate localhost.crt;
    ssl_protocols TLSv1.2 TLSv1.3;

    server {
        listen 127.0.0.1:10368 reuseport http3;
        ssl_quic on;
        server_name  localhost;

        location / {
            return 200 "This-is-QUICK\n";
        }
    }
    server {
        listen 127.0.0.1:5555 ssl; # point the browser here
        server_name  localhost;
        location / {
            add_header Alt-Svc 'h3-24=":10368";ma=100';
            return 200 "ALT-SVC";
        }
    }
}

6 years agoFixed a typo with OpenSSL.
Vladimir Homutov [Mon, 16 Mar 2020 16:42:57 +0000 (19:42 +0300)]
Fixed a typo with OpenSSL.

6 years agoSplit transport and crypto parts into separate files.
Vladimir Homutov [Mon, 16 Mar 2020 16:00:47 +0000 (19:00 +0300)]
Split transport and crypto parts into separate files.

New files:
    src/event/ngx_event_quic_protection.h
    src/event/ngx_event_quic_protection.c

The protection.h header provides interface to the crypto part of the QUIC:

2 functions to initialize corresponding secrets:

ngx_quic_set_initial_secret()
ngx_quic_set_encryption_secret()

and 2 functions to deal with packet processing:

ngx_quic_encrypt()
ngx_quic_decrypt()

Also, structures representing secrets are defined there.

All functions require SSL connection and a pool, only crypto operations
inside, no access to nginx connections or events.

Currently pool->log is used for the logging (instead of original c->log).

6 years agoAdded processing of CONNECTION CLOSE frames.
Vladimir Homutov [Mon, 16 Mar 2020 10:06:43 +0000 (13:06 +0300)]
Added processing of CONNECTION CLOSE frames.

Contents is parsed and debug is output. No actions are taken.

6 years agoTemporary fix for header null-termination in HTTP/3.
Roman Arutyunyan [Sat, 14 Mar 2020 10:18:55 +0000 (13:18 +0300)]
Temporary fix for header null-termination in HTTP/3.

6 years agoFixed header protection application with pn length > 1.
Sergey Kandaurov [Sat, 14 Mar 2020 00:15:09 +0000 (03:15 +0300)]
Fixed header protection application with pn length > 1.

6 years agoFixed sanitizer errors.
Roman Arutyunyan [Fri, 13 Mar 2020 17:44:32 +0000 (20:44 +0300)]
Fixed sanitizer errors.

6 years agoAdded check for initialized c->ssl before calling SSL shutdown.
Vladimir Homutov [Fri, 13 Mar 2020 15:55:58 +0000 (18:55 +0300)]
Added check for initialized c->ssl before calling SSL shutdown.

6 years agoHTTP/3.
Roman Arutyunyan [Fri, 13 Mar 2020 16:36:33 +0000 (19:36 +0300)]
HTTP/3.

6 years agoFixed infinite loop in ngx_quic_stream_send_chain().
Roman Arutyunyan [Fri, 13 Mar 2020 15:30:37 +0000 (18:30 +0300)]
Fixed infinite loop in ngx_quic_stream_send_chain().

6 years agoImplemented tracking offset in STREAM frames.
Roman Arutyunyan [Fri, 13 Mar 2020 15:29:50 +0000 (18:29 +0300)]
Implemented tracking offset in STREAM frames.

6 years agoImplemented ngx_quic_stream_send_chain() method.
Roman Arutyunyan [Fri, 13 Mar 2020 12:56:10 +0000 (15:56 +0300)]
Implemented ngx_quic_stream_send_chain() method.

 - just call send in a loop

6 years agoStream "connection" read/write methods.
Vladimir Homutov [Fri, 13 Mar 2020 11:39:23 +0000 (14:39 +0300)]
Stream "connection" read/write methods.

6 years agoFix build.
Sergey Kandaurov [Thu, 12 Mar 2020 15:08:26 +0000 (18:08 +0300)]
Fix build.

6 years agoRemoved hardcoded CRYPTO and ACK frame sizes.
Vladimir Homutov [Thu, 12 Mar 2020 11:23:27 +0000 (14:23 +0300)]
Removed hardcoded CRYPTO and ACK frame sizes.

6 years agoHTTP/QUIC interface reworked.
Vladimir Homutov [Thu, 12 Mar 2020 13:54:43 +0000 (16:54 +0300)]
HTTP/QUIC interface reworked.

 - events handling moved into src/event/ngx_event_quic.c
 - http invokes once ngx_quic_run() and passes stream callback
 (diff to original http_request.c is now minimal)

 - streams are stored in rbtree using ID as a key
 - when a new stream is registered, appropriate callback is called

 - ngx_quic_stream_t type represents STREAM and stored in c->qs

6 years agoInitial parsing of STREAM frames.
Vladimir Homutov [Wed, 11 Mar 2020 12:41:35 +0000 (15:41 +0300)]
Initial parsing of STREAM frames.

6 years agoAdded support of multiple QUIC packets in single datagram.
Vladimir Homutov [Thu, 12 Mar 2020 11:43:24 +0000 (14:43 +0300)]
Added support of multiple QUIC packets in single datagram.

 - now NEW_CONNECTION_ID frames can be received and parsed

The packet structure is created in ngx_quic_input() and passed
to all handlers (initial, handshake and application data).

The UDP datagram buffer is saved as pkt->raw;
The QUIC packet is stored as pkt->data and pkt->len (instead of pkt->buf)
(pkt->len is adjusted after parsing headers to actual length)

The pkt->pos is removed, pkt->raw->pos is used instead.

6 years agoAdded more transport parameters.
Vladimir Homutov [Wed, 11 Mar 2020 12:43:23 +0000 (15:43 +0300)]
Added more transport parameters.

Needed for client to start sending streams.

6 years agoCompatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov [Wed, 11 Mar 2020 18:53:02 +0000 (21:53 +0300)]
Compatibility with BoringSSL revised QUIC encryption secret APIs.

See for details: https://boringssl.googlesource.com/boringssl/+/1e85905%5E!/

6 years agoChacha20 header protection support with BoringSSL.
Sergey Kandaurov [Tue, 10 Mar 2020 16:15:12 +0000 (19:15 +0300)]
Chacha20 header protection support with BoringSSL.

BoringSSL lacks EVP for Chacha20.  Here we use CRYPTO_chacha_20() instead.

6 years agoChaCha20 / Poly1305 initial support.
Sergey Kandaurov [Tue, 10 Mar 2020 16:13:09 +0000 (19:13 +0300)]
ChaCha20 / Poly1305 initial support.

6 years agoUsing SSL cipher suite id to obtain cipher/digest, part 2.
Sergey Kandaurov [Tue, 10 Mar 2020 16:12:22 +0000 (19:12 +0300)]
Using SSL cipher suite id to obtain cipher/digest, part 2.

Ciphers negotiation handling refactored into ngx_quic_ciphers().

6 years agoFixed nonce in short packet protection.
Sergey Kandaurov [Tue, 10 Mar 2020 15:40:18 +0000 (18:40 +0300)]
Fixed nonce in short packet protection.

6 years agoGeneric payload handler for quic packets.
Vladimir Homutov [Tue, 10 Mar 2020 15:24:39 +0000 (18:24 +0300)]
Generic payload handler for quic packets.

 - added basic parsing of ACK, PING and PADDING frames on input
 - added preliminary parsing of SHORT headers

The ngx_quic_output() is now called after processing of each input packet.
Frames are added into output queue according to their level: inital packets
go ahead of handshake and application data, so they can be merged properly.

The payload handler is called from both new, handshake and applicataion data
handlers (latter is a stub).

6 years agoFixed header protection with negotiated cipher suite.
Sergey Kandaurov [Thu, 5 Mar 2020 17:05:40 +0000 (20:05 +0300)]
Fixed header protection with negotiated cipher suite.

6 years agoInitial packets are protected with AEAD_AES_128_GCM.
Sergey Kandaurov [Thu, 5 Mar 2020 16:49:49 +0000 (19:49 +0300)]
Initial packets are protected with AEAD_AES_128_GCM.

6 years agoFixed write secret logging in set_encryption_secrets callback.
Sergey Kandaurov [Thu, 5 Mar 2020 15:01:18 +0000 (18:01 +0300)]
Fixed write secret logging in set_encryption_secrets callback.

6 years agoFixed format specifiers.
Vladimir Homutov [Thu, 5 Mar 2020 14:51:22 +0000 (17:51 +0300)]
Fixed format specifiers.

6 years agoStyle.
Vladimir Homutov [Thu, 5 Mar 2020 14:24:04 +0000 (17:24 +0300)]
Style.

6 years agoAdded functions to decrypt long packets.
Vladimir Homutov [Thu, 5 Mar 2020 14:18:33 +0000 (17:18 +0300)]
Added functions to decrypt long packets.

6 years agoFixed ngx_quic_varint_len misuse in the previous change.
Sergey Kandaurov [Thu, 5 Mar 2020 12:26:15 +0000 (15:26 +0300)]
Fixed ngx_quic_varint_len misuse in the previous change.

6 years agoMacro for calculating size of varint.
Vladimir Homutov [Wed, 4 Mar 2020 20:24:51 +0000 (23:24 +0300)]
Macro for calculating size of varint.

6 years agoFixed packet "input" debug log message.
Sergey Kandaurov [Thu, 5 Mar 2020 10:10:01 +0000 (13:10 +0300)]
Fixed packet "input" debug log message.

6 years agoUsing SSL cipher suite id to obtain cipher/digest, part 1.
Sergey Kandaurov [Thu, 5 Mar 2020 10:00:59 +0000 (13:00 +0300)]
Using SSL cipher suite id to obtain cipher/digest, part 1.

While here, log the negotiated cipher just once, - after handshake.

6 years agoUsing cached ssl_conn in ngx_quic_handshake_input(), NFC.
Sergey Kandaurov [Thu, 5 Mar 2020 09:51:49 +0000 (12:51 +0300)]
Using cached ssl_conn in ngx_quic_handshake_input(), NFC.

6 years agoAdjusted transport parameters stub for active_connection_id_limit.
Sergey Kandaurov [Wed, 4 Mar 2020 13:05:39 +0000 (16:05 +0300)]
Adjusted transport parameters stub for active_connection_id_limit.

As was objserved with ngtcp2 client, Finished CRYPTO frame within Handshake
packet may not be sent for some reason if there's nothing to append on 1-RTT.
This results in unnecessary retransmit.  To avoid this edge case, a non-zero
active_connection_id_limit transport parameter is now used to append datagram
with NEW_CONNECTION_ID 1-RTT frames.

6 years agoImplemented improved version of quic_output().
Vladimir Homutov [Wed, 4 Mar 2020 12:52:12 +0000 (15:52 +0300)]
Implemented improved version of quic_output().

Now handshake generates frames, and they are queued in c->quic->frames.
The ngx_quic_output() is called from ngx_quic_flush_flight() or manually,
processes the queue and encrypts all frames according to required encryption
level.

6 years agoQUIC handshake final bits.
Sergey Kandaurov [Tue, 3 Mar 2020 14:25:02 +0000 (17:25 +0300)]
QUIC handshake final bits.

Added handling of client Finished, both feeding and acknowledgement.
This includes sending NST in 1-RTT triggered by a handshake process.

6 years agoSplit frame and packet generation into separate steps.
Vladimir Homutov [Tue, 3 Mar 2020 10:30:30 +0000 (13:30 +0300)]
Split frame and packet generation into separate steps.

While there, a number of QUIC constants from spec defined and magic numbers
were replaced.

6 years agoAded the "ngx_quic_hexdump" macro.
Vladimir Homutov [Mon, 2 Mar 2020 18:38:03 +0000 (21:38 +0300)]
Aded the "ngx_quic_hexdump" macro.

ngx_quic_hexdump0(log, format, buffer, buffer_size);
    - logs hexdump of buffer to specified error log

    ngx_quic_hexdump0(c->log, "this is foo:", foo.data, foo.len);

ngx_quic_hexdump(log, format, buffer, buffer_size, ...)
    - same as hexdump0, but more format/args possible:

    ngx_quic_hexdump(c->log, "a=%d b=%d, foo is:", foo.data, foo.len, a, b);

6 years agoMoved all QUIC code into ngx_event_quic.c
Vladimir Homutov [Fri, 28 Feb 2020 13:23:25 +0000 (16:23 +0300)]
Moved all QUIC code into ngx_event_quic.c

Introduced ngx_quic_input() and ngx_quic_output() as interface between
nginx and protocol.  They are the only functions that are exported.

While there, added copyrights.

6 years agoIntroduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:52 +0000 (13:09 +0300)]
Introduced quic_version macro, uint16/uint32 routines ported.

6 years agoCleanup.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:52 +0000 (13:09 +0300)]
Cleanup.

6 years agoGeneric function for HKDF expansion.
Vladimir Homutov [Wed, 26 Feb 2020 13:56:47 +0000 (16:56 +0300)]
Generic function for HKDF expansion.

6 years agoQUIC header protection routines, introduced ngx_quic_tls_hp().
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:52 +0000 (13:09 +0300)]
QUIC header protection routines, introduced ngx_quic_tls_hp().

6 years agoAEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:52 +0000 (13:09 +0300)]
AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().

6 years agoTransport parameters stub, to complete handshake.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:52 +0000 (13:09 +0300)]
Transport parameters stub, to complete handshake.

6 years agoIntroduced ngx_quic_secret_t.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:52 +0000 (13:09 +0300)]
Introduced ngx_quic_secret_t.

6 years agoQUIC handshake handler, draft 24 bump.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:52 +0000 (13:09 +0300)]
QUIC handshake handler, draft 24 bump.

6 years agoFixed indentation.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:52 +0000 (13:09 +0300)]
Fixed indentation.

6 years agoPN-aware AEAD nonce, feeding proper CRYPTO length.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:52 +0000 (13:09 +0300)]
PN-aware AEAD nonce, feeding proper CRYPTO length.

6 years agoOpenSSL compatibility.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:51 +0000 (13:09 +0300)]
OpenSSL compatibility.

6 years agoQUIC add_handshake_data callback, varint routines.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:51 +0000 (13:09 +0300)]
QUIC add_handshake_data callback, varint routines.

6 years agoQUIC set_encryption_secrets callback.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:51 +0000 (13:09 +0300)]
QUIC set_encryption_secrets callback.

6 years agoServer Initial Keys.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:51 +0000 (13:09 +0300)]
Server Initial Keys.

6 years agoInitial QUIC support in http.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:51 +0000 (13:09 +0300)]
Initial QUIC support in http.

6 years agoHTTP UDP layer, QUIC support autotest.
Sergey Kandaurov [Fri, 28 Feb 2020 10:09:51 +0000 (13:09 +0300)]
HTTP UDP layer, QUIC support autotest.

6 years agoCreated the "quic" branch.
Vladimir Homutov [Tue, 3 Mar 2020 09:14:44 +0000 (12:14 +0300)]
Created the "quic" branch.

6 years agoAdded default overwrite in error_page 494.
Maxim Dounin [Fri, 28 Feb 2020 14:21:18 +0000 (17:21 +0300)]
Added default overwrite in error_page 494.

We used to have default error_page overwrite for 495, 496, and 497, so
a configuration like

    error_page 495 /error;

will result in error 400, much like without any error_page configured.

The 494 status code was introduced later (in 3848:de59ad6bf557, nginx 0.9.4),
and relevant changes to ngx_http_core_error_page() were missed, resulting
in inconsistent behaviour of "error_page 494" - with error_page configured
it results in 494 being returned instead of 400.

Reported by Frank Liu,
http://mailman.nginx.org/pipermail/nginx/2020-February/058957.html.

6 years agoMp4: fixed possible chunk offset overflow.
Roman Arutyunyan [Wed, 26 Feb 2020 12:10:46 +0000 (15:10 +0300)]
Mp4: fixed possible chunk offset overflow.

In "co64" atom chunk start offset is a 64-bit unsigned integer.  When trimming
the "mdat" atom, chunk offsets are casted to off_t values which are typically
64-bit signed integers.  A specially crafted mp4 file with huge chunk offsets
may lead to off_t overflow and result in negative trim boundaries.

The consequences of the overflow are:
- Incorrect Content-Length header value in the response.
- Negative left boundary of the response file buffer holding the trimmed "mdat".
  This leads to pread()/sendfile() errors followed by closing the client
  connection.

On rare systems where off_t is a 32-bit integer, this scenario is also feasible
with the "stco" atom.

The fix is to add checks which make sure data chunks referenced by each track
are within the mp4 file boundaries.  Additionally a few more checks are added to
ensure mp4 file consistency and log errors.

6 years agoDisabled connection reuse while in SSL handshake.
Sergey Kandaurov [Thu, 27 Feb 2020 16:03:21 +0000 (19:03 +0300)]
Disabled connection reuse while in SSL handshake.

During SSL handshake, the connection could be reused in the OCSP stapling
callback, if configured, which subsequently leads to a segmentation fault.

6 years agoDisabled duplicate "Host" headers (ticket #1724).
Maxim Dounin [Thu, 20 Feb 2020 13:51:07 +0000 (16:51 +0300)]
Disabled duplicate "Host" headers (ticket #1724).

Duplicate "Host" headers were allowed in nginx 0.7.0 (revision b9de93d804ea)
as a workaround for some broken Motorola phones which used to generate
requests with two "Host" headers[1].  It is believed that this workaround
is no longer relevant.

[1] http://mailman.nginx.org/pipermail/nginx-ru/2008-May/017845.html

6 years agoRemoved "Transfer-Encoding: identity" support.
Maxim Dounin [Thu, 20 Feb 2020 13:19:34 +0000 (16:19 +0300)]
Removed "Transfer-Encoding: identity" support.

The "identity" transfer coding has been removed in RFC 7230.  It is
believed that it is not used in real life, and at the same time it
provides a potential attack vector.

6 years agoDisabled multiple Transfer-Encoding headers.
Maxim Dounin [Thu, 20 Feb 2020 13:19:29 +0000 (16:19 +0300)]
Disabled multiple Transfer-Encoding headers.

We anyway do not support more than one transfer encoding, so accepting
requests with multiple Transfer-Encoding headers doesn't make sense.
Further, we do not handle multiple headers, and ignore anything but
the first header.

Reported by Filippo Valsorda.

6 years agoMade ngx_http_get_forwarded_addr_internal() non-recursive.
Vladimir Homutov [Tue, 11 Feb 2020 10:22:44 +0000 (13:22 +0300)]
Made ngx_http_get_forwarded_addr_internal() non-recursive.

6 years agoHTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov [Wed, 5 Feb 2020 13:29:23 +0000 (16:29 +0300)]
HTTP/2: fixed socket leak with an incomplete HEADERS frame.

A connection could get stuck without timers if a client has partially sent
the HEADERS frame such that it was split on the individual header boundary.
In this case, it cannot be processed without the rest of the HEADERS frame.

The fix is to call ngx_http_v2_state_headers_save() in this case.  Normally,
it would be called from the ngx_http_v2_state_header_block() handler on the
next iteration, when there is not enough data to continue processing.  This
isn't the case if recv_buffer became empty and there's no more data to read.

6 years agoVersion bump.
Sergey Kandaurov [Wed, 5 Feb 2020 13:29:14 +0000 (16:29 +0300)]
Version bump.

6 years agorelease-1.17.8 tag
Maxim Dounin [Tue, 21 Jan 2020 13:39:42 +0000 (16:39 +0300)]
release-1.17.8 tag

6 years agonginx-1.17.8-RELEASE release-1.17.8
Maxim Dounin [Tue, 21 Jan 2020 13:39:41 +0000 (16:39 +0300)]
nginx-1.17.8-RELEASE

6 years agogRPC: variables support in the "grpc_pass" directive.
Vladimir Homutov [Fri, 17 Jan 2020 09:13:02 +0000 (12:13 +0300)]
gRPC: variables support in the "grpc_pass" directive.

6 years agoHTTP/2: removed ngx_debug_point() call.
Daniil Bondarev [Tue, 14 Jan 2020 11:20:08 +0000 (14:20 +0300)]
HTTP/2: removed ngx_debug_point() call.
    
With the recent change to prevent frames flood in d4448892a294,
nginx will finalize the connection with NGX_HTTP_V2_INTERNAL_ERROR
whenever flood is detected, causing nginx aborting or stopping if
the debug_points directive is used in nginx config.

6 years agoSSL: reworked posted next events again.
Maxim Dounin [Fri, 27 Dec 2019 16:43:01 +0000 (19:43 +0300)]
SSL: reworked posted next events again.

Previous change 1ce3f01a4355 incorrectly introduced processing of the
ngx_posted_next_events queue at the end of operation, effectively making
posted next events a nop, since at the end of an event loop iteration
the queue is always empty.  Correct approach is to move events to the
ngx_posted_events queue at an iteration start, as it was done previously.

Further, in some cases the c->read event might be already in the
ngx_posted_events queue, and calling ngx_post_event() with the
ngx_posted_next_events queue won't do anything.  To make sure the event
will be correctly placed into the ngx_posted_next_events queue
we now check if it is already posted.

6 years agoTrailing space removed.
Maxim Dounin [Fri, 27 Dec 2019 14:20:25 +0000 (17:20 +0300)]
Trailing space removed.

6 years agoVersion bump.
Maxim Dounin [Fri, 27 Dec 2019 14:20:20 +0000 (17:20 +0300)]
Version bump.

6 years agorelease-1.17.7 tag
Maxim Dounin [Tue, 24 Dec 2019 15:00:09 +0000 (18:00 +0300)]
release-1.17.7 tag

6 years agonginx-1.17.7-RELEASE release-1.17.7
Maxim Dounin [Tue, 24 Dec 2019 15:00:09 +0000 (18:00 +0300)]
nginx-1.17.7-RELEASE

6 years agoSSL: reworked posted next events.
Maxim Dounin [Tue, 24 Dec 2019 14:24:59 +0000 (17:24 +0300)]
SSL: reworked posted next events.

Introduced in 9d2ad2fb4423 available bytes handling in SSL relied
on connection read handler being overwritten to set the ready flag
and the amount of available bytes.  This approach is, however, does
not work properly when connection read handler is changed, for example,
when switching to a next pipelined request, and can result in unexpected
connection timeouts, see here:

http://mailman.nginx.org/pipermail/nginx-devel/2019-December/012825.html

Fix is to introduce ngx_event_process_posted_next() instead, which
will set ready and available regardless of how event handler is set.

6 years agoHTTP/2: introduced separate handler to retry stream close.
Maxim Dounin [Mon, 23 Dec 2019 18:25:21 +0000 (21:25 +0300)]
HTTP/2: introduced separate handler to retry stream close.

When ngx_http_v2_close_stream_handler() is used to retry stream close
after queued frames are sent, client timeouts on the stream can be
logged multiple times and/or in addition to already happened errors.
To resolve this, separate ngx_http_v2_retry_close_stream_handler()
was introduced, which does not try to log timeouts.

6 years agoHTTP/2: fixed socket leak with queued frames (ticket #1689).
Maxim Dounin [Mon, 23 Dec 2019 18:25:17 +0000 (21:25 +0300)]
HTTP/2: fixed socket leak with queued frames (ticket #1689).

If a stream is closed with queued frames, it is possible that no further
write events will occur on the stream, leading to the socket leak.
To fix this, the stream's fake connection read handler is set to
ngx_http_v2_close_stream_handler(), to make sure that finalizing the
connection with ngx_http_v2_finalize_connection() will be able to
close the stream regardless of the current number of queued frames.

Additionally, the stream's fake connection fc->error flag is explicitly
set, so ngx_http_v2_handle_stream() will post a write event when queued
frames are finally sent even if stream flow control window is exhausted.

6 years agoDav: added checks for chunked to body presence conditions.
Maxim Dounin [Mon, 23 Dec 2019 17:39:27 +0000 (20:39 +0300)]
Dav: added checks for chunked to body presence conditions.

These checks were missed when chunked support was introduced.  And also
added an explicit error message to ngx_http_dav_copy_move_handler()
(it was missed for some reason, in contrast to DELETE and MKCOL handlers).

6 years agoUpdate manpage, sort command line options.
Sergey A. Osokin [Mon, 23 Dec 2019 15:56:21 +0000 (18:56 +0300)]
Update manpage, sort command line options.

6 years agoDiscard request body when redirecting to a URL via error_page.
Ruslan Ermilov [Mon, 23 Dec 2019 12:45:46 +0000 (15:45 +0300)]
Discard request body when redirecting to a URL via error_page.

Reported by Bert JW Regeer and Francisco Oca Gonzalez.

6 years agoRewrite: disallow empty replacements.
Ruslan Ermilov [Mon, 16 Dec 2019 12:19:01 +0000 (15:19 +0300)]
Rewrite: disallow empty replacements.

While empty replacements were caught at run-time, parsing code
of the "rewrite" directive expects that a minimum length of the
"replacement" argument is 1.

6 years agoTolerate '\0' in URI when mapping URI to path.
Ruslan Ermilov [Mon, 16 Dec 2019 12:19:01 +0000 (15:19 +0300)]
Tolerate '\0' in URI when mapping URI to path.

If a rewritten URI has the null character, only a part of URI was
copied to a memory buffer allocated for path.  In some setups this
could be exploited to expose uninitialized memory via the Location
header.