Commit graph

6810 commits

Author SHA1 Message Date
Sergey Kandaurov
21f4be001a QUIC packet padding to fulfil header protection sample demands. 2020-04-01 13:27:42 +03:00
Sergey Kandaurov
7d5fe69bb2 Improved SSL_do_handshake() error handling in QUIC.
It can either return a recoverable SSL_ERROR_WANT_READ or fatal errors.
2020-04-01 13:27:42 +03:00
Sergey Kandaurov
108bc03458 Style. 2020-04-01 13:27:41 +03:00
Vladimir Homutov
ed21279b6f Removed unused field from ngx_quic_header_t. 2020-03-31 13:13:12 +03:00
Sergey Kandaurov
6749f64f7f HTTP/3: http3 variable. 2020-03-28 18:41:31 +03:00
Sergey Kandaurov
536810e48b HTTP/3: static table cleanup. 2020-03-28 18:02:20 +03:00
Roman Arutyunyan
48a1eeb5c2 Parsing HTTP/3 request body. 2020-03-27 19:41:06 +03:00
Roman Arutyunyan
732e383dd1 Fixed handling QUIC stream eof.
Set r->pending_eof flag for a new QUIC stream with the fin bit.  Also, keep
r->ready set when r->pending_eof is set and buffer is empty.
2020-03-27 10:02:45 +03:00
Roman Arutyunyan
6bc0ecd946 Push QUIC stream frames in send() and cleanup handler. 2020-03-27 19:08:24 +03:00
Roman Arutyunyan
50e32ed41d Chunked response body in HTTP/3. 2020-03-27 19:46:54 +03:00
Roman Arutyunyan
1903ad35b9 Fixed buffer overflow. 2020-03-27 15:50:42 +03:00
Sergey Kandaurov
20659b28cc Unbreak sending CONNECTION_CLOSE from the send_alert callback. 2020-03-27 12:52:08 +03:00
Vladimir Homutov
dd88e287a5 Merged ngx_quic_send_packet() into ngx_quic_send_frames().
This allows to avoid extra allocation and use two static buffers instead.
Adjusted maximum paket size calculation: need to account a tag.
2020-03-26 18:29:38 +03:00
Vladimir Homutov
559e9b7f59 Got rid of memory allocation in decryption.
Static buffers are used instead in functions where decryption takes place.

The pkt->plaintext points to the beginning of a static buffer.
The pkt->payload.data points to decrypted data actual start.
2020-03-26 16:54:46 +03:00
Vladimir Homutov
6bad711183 Logging cleanup.
pool->log is replaced with pkt->log or explicit argument passing where
possible.
2020-03-26 13:54:49 +03:00
Roman Arutyunyan
5f6d337e47 QUIC frames reuse. 2020-03-25 23:40:50 +03:00
Vladimir Homutov
73fc0300aa Removed memory allocations from encryption code.
+ ngx_quic_encrypt():
     - no longer accepts pool as argument
     - pkt is 1st arg
     - payload is passed as pkt->payload
     - performs encryption to the specified static buffer

 + ngx_quic_create_long/short_packet() functions:
    - single buffer for everything, allocated by caller
    - buffer layout is: [ ad | payload | TAG ]
      the result is in the beginning of buffer with proper length
    - nonce is calculated on stack
    - log is passed explicitly, pkt is 1st arg
    - no more allocations inside

 + ngx_quic_create_long_header():
    - args changed: no need to pass str_t

 + added ngx_quic_create_short_header()
2020-03-26 12:11:50 +03:00
Roman Arutyunyan
8decfa3847 Fixed QUIC stream insert and find. 2020-03-25 14:05:40 +03:00
Roman Arutyunyan
5162a3da50 Simplifed handling HTTP/3 streams. 2020-03-25 12:14:24 +03:00
Roman Arutyunyan
897df08a00 Safe QUIC stream creation. 2020-03-25 12:56:21 +03:00
Roman Arutyunyan
372d6283c2 When closing a QUIC connection, wait for all streams to finish.
Additionally, streams are now removed from the tree in cleanup handler.
2020-03-24 18:05:45 +03:00
Roman Arutyunyan
22a1957f92 Removed ngx_quic_stream_node_t.
Now ngx_quic_stream_t is directly inserted into the tree.
2020-03-24 16:38:03 +03:00
Roman Arutyunyan
f4b6701ab4 Implemented eof in QUIC streams. 2020-03-24 13:49:42 +03:00
Vladimir Homutov
34e20825bb Fixed log initialization.
Should be done after memzero.
2020-03-25 19:42:00 +03:00
Sergey Kandaurov
9dda9e51f3 Advertise our max_idle_timeout in transport parameters.
So we can easily tune how soon client would decide to close a connection.
2020-03-24 22:12:52 +03:00
Sergey Kandaurov
c87e5a3a13 QUIC streams don't need filter_need_in_memory after 7f0981be07c4.
Now they inherit c->ssl always enabled from the main connection,
which makes r->main_filter_need_in_memory set for them.
2020-03-24 19:17:57 +03:00
Vladimir Homutov
6b8343d4cf Logging cleanup.
+ Client-related errors (i.e. parsing) are done at INFO level
 + c->log->action is updated through the process of receiving, parsing.
   handling packet/payload and generating frames/output.
2020-03-24 17:03:39 +03:00
Vladimir Homutov
55680af808 Added QUIC version check for sending HANDSHAKE_DONE frame. 2020-03-24 12:15:39 +03:00
Vladimir Homutov
f38c75578c Implemented sending HANDSHAKE_DONE frame after handshake.
This makes it possible to switch to draft 27 by default.
2020-03-24 11:59:14 +03:00
Sergey Kandaurov
ac4d386e29 Fixed client certificate verification.
For ngx_http_process_request() part to work, this required to set both
r->http_connection->ssl and c->ssl on a QUIC stream.  To avoid damaging
global SSL object, ngx_ssl_shutdown() is managed to ignore QUIC streams.
2020-03-23 20:48:34 +03:00
Roman Arutyunyan
b20601811e Respect QUIC max_idle_timeout. 2020-03-23 21:20:20 +03:00
Roman Arutyunyan
ca0bc7f0d7 Allow ngx_queue_frame() to insert frame in the front.
Previously a frame could only be inserted after the first element of the list.
2020-03-23 19:42:09 +03:00
Roman Arutyunyan
0d50d1718c Support for HTTP/3 ALPN.
This is required by Chrome.
2020-03-23 19:26:24 +03:00
Roman Arutyunyan
ce532aa3e2 Put zero in 'First ACK Range' when acknowledging one packet.
This fixes Chrome CONNECTION_ID_LIMIT_ERROR with the reason:
"Underflow with first ack block length 2 largest acked is 1".
2020-03-23 15:32:24 +03:00
Roman Arutyunyan
25447805a2 Avoid using QUIC connection after CONNECTION_CLOSE. 2020-03-23 19:19:44 +03:00
Roman Arutyunyan
aca8dcc624 Better flow control and buffering for QUIC streams. 2020-03-23 15:49:31 +03:00
Roman Arutyunyan
d60818a0d3 Limit output QUIC packets with client max_packet_size.
Additionally, receive larger packets than 512 bytes.
2020-03-23 18:47:17 +03:00
Sergey Kandaurov
1afb9cd2be Fixed received ACK fields order in debug logging. 2020-03-23 18:20:42 +03:00
Vladimir Homutov
b934f9289b Connection states code cleanup.
+ ngx_quic_init_ssl_methods() is no longer there, we setup methods on SSL
   connection directly.

 + the handshake_handler is actually a generic quic input handler

 + updated c->log->action and debug to reflect changes and be more informative

 + c->quic is always set in ngx_quic_input()

 + the quic connection state is set by the results of SSL_do_handshake();
2020-03-23 14:53:04 +03:00
Vladimir Homutov
a707587883 Skip unknown transport parameters. 2020-03-23 12:57:24 +03:00
Vladimir Homutov
f26700cc7f Add unsupported version into log.
This makes it easier to understand what client wants.
2020-03-23 10:57:28 +03:00
Vladimir Homutov
b0972707a3 Added processing of client transport parameters.
note:
 + parameters are available in SSL connection since they are obtained by ssl
   stack

quote:
   During connection establishment, both endpoints make authenticated
   declarations of their transport parameters.  These declarations are
   made unilaterally by each endpoint.

and really, we send our parameters before we read client's.

no handling of incoming parameters is made by this patch.
2020-03-21 20:51:59 +03:00
Sergey Kandaurov
02a2cbf438 Fixed CRYPTO offset generation. 2020-03-22 12:15:54 +03:00
Sergey Kandaurov
457e579896 Closing connection on NGX_QUIC_FT_CONNECTION_CLOSE. 2020-03-22 11:35:15 +03:00
Vladimir Homutov
76db776d70 Implemented parsing of remaining frame types. 2020-03-21 20:49:55 +03:00
Sergey Kandaurov
9e02252c76 Fixed parsing NGX_QUIC_FT_CONNECTION_CLOSE. 2020-03-21 19:45:24 +03:00
Sergey Kandaurov
d588f9da33 Fixed buffer overrun in create_transport_params() with -24.
It writes 16-bit prefix as designed, but length calculation assumed varint.
2020-03-21 19:22:39 +03:00
Sergey Kandaurov
5a823e8656 Fixed build with macOS's long long abomination. 2020-03-21 18:44:10 +03:00
Roman Arutyunyan
587adbda18 Removed unused variable. 2020-03-20 23:49:42 +03:00
Vladimir Homutov
8c69d52595 Removed unused variable. 2020-03-20 20:39:41 +03:00