summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-04-15Added reordering support for STREAM frames.Vladimir Homutov2-72/+159
Each stream node now includes incoming frames queue and sent/received counters for tracking offset. The sent counter is not used, c->sent is used, not like in crypto buffers, which have no connections.
2020-04-14Crypto buffer frames reordering.Vladimir Homutov3-50/+307
If offset in CRYPTO frame doesn't match expected, following actions are taken: a) Duplicate frames or frames within [0...current offset] are ignored b) New data from intersecting ranges (starts before current_offset, ends after) is consumed c) "Future" frames are stored in a sorted queue (min offset .. max offset) Once a frame is consumed, current offset is updated and the queue is inspected: we iterate the queue until the gap is found and act as described above for each frame. The amount of data in buffered frames is limited by corresponding macro. The CRYPTO and STREAM frame structures are now compatible: they share the same set of initial fields. This allows to have code that deals with both of this frames. The ordering layer now processes the frame with offset and invokes the handler when it can organise an ordered stream of data.
2020-04-13Cleaned up magic numbers in ngx_quic_output_frames().Vladimir Homutov1-8/+8
2020-04-14Rename types and variables used for packet number space.Vladimir Homutov1-67/+71
Quote: Conceptually, a packet number space is the context in which a packet can be processed and acknowledged. ngx_quic_namespace_t => ngx_quic_send_ctx_t qc->ns => qc->send_ctx ns->largest => send_ctx->largest_ack The ngx_quic_ns(level) macro now returns pointer, not just index: ngx_quic_get_send_ctx(c->quic, level) ngx_quic_retransmit_ns() => ngx_quic_retransmit() ngx_quic_output_ns() => ngx_quic_output_frames()
2020-04-14Merged with the default branch.Sergey Kandaurov5-45/+113
2020-04-13HTTP/3: fixed reading request body.Roman Arutyunyan1-1/+2
2020-04-08The new auth_delay directive for delaying unauthorized requests.Ruslan Ermilov2-1/+82
The request processing is delayed by a timer. Since nginx updates internal time once at the start of each event loop iteration, this normally ensures constant time delay, adding a mitigation from time-based attacks. A notable exception to this is the case when there are no additional events before the timer expires. To ensure constant-time processing in this case as well, we trigger an additional event loop iteration by posting a dummy event for the next event loop iteration.
2020-04-07Added basic offset support in client CRYPTO frames.Vladimir Homutov1-9/+19
The offset in client CRYPTO frames is tracked in c->quic->crypto_offset_in. This means that CRYPTO frames with non-zero offset are now accepted making possible to finish handshake with client certificates that exceed max packet size (if no reordering happens). The c->quic->crypto_offset field is renamed to crypto_offset_out to avoid confusion with tracking of incoming CRYPTO stream.
2020-04-07Fixed build with OpenSSL using old callbacks API.Sergey Kandaurov1-1/+1
2020-04-06ACK ranges processing.Vladimir Homutov3-29/+134
+ since number of ranges in unknown, provide a function to parse them once again in handler to avoid memory allocation + ack handler now processes all ranges, not only the first + ECN counters are parsed and saved into frame if present
2020-04-06Ignore non-yet-implemented frames.Vladimir Homutov1-13/+15
Such frames are grouped together in a switch and just ignored, instead of closing the connection This may improve test coverage. All such frames require acknowledgment.
2020-04-04Added check for SSL_get_current_cipher() results.Vladimir Homutov1-2/+8
The function may return NULL and result need to be checked before use.
2020-04-06Added a bit more debugging in STREAM frame parser.Vladimir Homutov1-1/+2
2020-04-04Do not set timers after the connection is closed.Vladimir Homutov1-2/+6
The qc->closing flag is set when a connection close is initiated for the first time. No timers will be set if the flag is active. TODO: this is a temporary solution to avoid running timer handlers after connection (and it's pool) was destroyed. It looks like currently we have no clear policy of connection closing in regard to timers.
2020-04-06Discarding Handshake packets if no Handshake keys yet.Sergey Kandaurov1-2/+8
Found with a previously received Initial packet with ACK only, which instantiates a new connection but do not produce the handshake keys. This can be triggered by a fairly well behaving client, if the server stands behind a load balancer that stripped Initial packets exchange. Found by F5 test suite.
2020-04-06Rejecting new connections with non-zero Initial packet.Sergey Kandaurov1-0/+6
2020-04-06TLS Key Update in QUIC.Sergey Kandaurov4-11/+156
Old keys retention is yet to be implemented.
2020-04-04Removed excessive debugging in QUIC packet creation.Sergey Kandaurov1-12/+6
While here, eliminated further difference in between.
2020-04-04Logging of packet numbers in QUIC packet creation.Sergey Kandaurov1-0/+8
2020-04-03Removed unneccesary milliseconds conversion.Vladimir Homutov1-1/+1
2020-04-03Proper handling of packet number in header.Vladimir Homutov4-14/+96
- fixed setting of largest received packet number. - sending properly truncated packet number - added support for multi-byte packet number
2020-04-03Advertizing MAX_STREAMS (0x12) credit in advance.Sergey Kandaurov1-1/+52
This makes sending large number of bidirectional stream work within ngtcp2, which doesn't bother sending optional STREAMS_BLOCKED when exhausted. This also introduces tracking currently opened and maximum allowed streams.
2020-04-03Fixed computing nonce again, by properly shifting packet number.Sergey Kandaurov1-4/+4
2020-04-03Fixed missing propagation of need_ack flag from frames to packet.Vladimir Homutov1-0/+4
2020-04-02Fixed excessive push timer firing.Vladimir Homutov1-4/+0
The timer is set when an output frame is generated; there is no need to arm it after it was fired.
2020-04-02Fixed computing nonce by xoring all packet number bytes.Sergey Kandaurov1-9/+14
Previously, the stub worked only with pnl=0.
2020-04-01Output buffering.Vladimir Homutov1-3/+39
Currently, the output is called periodically, each 200 ms to invoke ngx_quic_output() that will push all pending frames into packets. TODO: implement flags a-là Nagle & co (NO_DELAY/NO_PUSH...)
2020-04-01Implemented retransmission and retransmit queue.Vladimir Homutov3-74/+356
All frames collected to packet are moved into a per-namespace send queue. QUIC connection has a timer which fires on the closest max_ack_delay time. The frame is deleted from the queue when a corresponding packet is acknowledged. The NGX_QUIC_MAX_RETRANSMISSION is a timeout that defines maximum length of retransmission of a frame.
2020-04-01Introduced packet namespace in QUIC connection.Vladimir Homutov4-18/+37
The structure contains all data that is related to the namespace: packet number and output queue (next patch).
2020-04-01Refactored QUIC secrets storage.Vladimir Homutov3-85/+87
The quic->keys[4] array now contains secrets related to the corresponding encryption level. All protection-level functions get proper keys and do not need to switch manually between levels.
2020-04-01Added missing debug description.Vladimir Homutov1-0/+1
2020-04-01TLS Early Data support.Sergey Kandaurov1-12/+98
2020-04-01TLS Early Data key derivation support.Sergey Kandaurov3-1/+11
2020-04-01Sending HANDSHAKE_DONE just once with BoringSSL.Sergey Kandaurov1-1/+1
If early data is accepted, SSL_do_handshake() completes as soon as ClientHello is processed. SSL_in_init() will report the handshake is still in progress.
2020-04-01QUIC packet padding to fulfil header protection sample demands.Sergey Kandaurov1-0/+5
2020-04-01Improved SSL_do_handshake() error handling in QUIC.Sergey Kandaurov1-1/+7
It can either return a recoverable SSL_ERROR_WANT_READ or fatal errors.
2020-04-01Style.Sergey Kandaurov2-5/+4
2020-03-31Removed unused field from ngx_quic_header_t.Vladimir Homutov1-1/+0
2020-03-28HTTP/3: http3 variable.Sergey Kandaurov1-0/+24
2020-03-28HTTP/3: static table cleanup.Sergey Kandaurov1-7/+8
2020-03-27Parsing HTTP/3 request body.Roman Arutyunyan8-10/+167
2020-03-27Fixed handling QUIC stream eof.Roman Arutyunyan1-2/+7
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-27Push QUIC stream frames in send() and cleanup handler.Roman Arutyunyan1-0/+4
2020-03-27Chunked response body in HTTP/3.Roman Arutyunyan3-18/+76
2020-03-27Fixed buffer overflow.Roman Arutyunyan1-1/+1
2020-03-27Unbreak sending CONNECTION_CLOSE from the send_alert callback.Sergey Kandaurov1-4/+0
2020-03-26Merged ngx_quic_send_packet() into ngx_quic_send_frames().Vladimir Homutov1-45/+22
This allows to avoid extra allocation and use two static buffers instead. Adjusted maximum paket size calculation: need to account a tag.
2020-03-26Got rid of memory allocation in decryption.Vladimir Homutov4-29/+34
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-26Logging cleanup.Vladimir Homutov1-18/+13
pool->log is replaced with pkt->log or explicit argument passing where possible.
2020-03-25QUIC frames reuse.Roman Arutyunyan2-25/+95