Commit Graph

3653 Commits

Author SHA1 Message Date
David Craven f4903f5142 Allow upgrading keys before sending CRYPTO frames 2021-04-23 11:25:33 -07:00
Matthias Einwag d6d32b2ad0 Use an array-based RangeSet for tracking outgoing ACKs
This change introduces a second `RangeSet` type which is based on a
linear array/vector instead of a tree. For the purpose of tracking
ACK ranges we usually should not have a big number of disjoint ranges,
since those would only occur with severe fragmentation. Therefore the
main benefit of a tree which is able to find ranges in the middle is
rarely used.

The array-based RangeSet provides 2 benefits:
- There exists an inline representation, which avoids the need of heap
  allocating ACK ranges for `SentFrames` for small ranges.
- Iterating over ranges should usually be faster since there is only
  a single cache-friendly contiguous range.

Performance differences:

With the `BTreeMap` based `RangeSet`:
```
Sent 1073741824 bytes on 1 streams in 1.90s (538.89 MiB/s)
```

With the `TinyVec` based `RangeSet`:
```
Sent 1073741824 bytes on 1 streams in 1.78s (574.73 MiB/s)
```
2021-04-06 10:34:21 +02:00
Matthias Einwag e6f28e9d29 Fix insert and remove behavior for empty ranges
`RangeSet::insert` and `RangeSet::remove` returned `true` when
trying to insert an empty range.
2021-04-06 10:34:21 +02:00
Matthias Einwag 01b95116e9 Update the minimal required version to 1.47
This updates the minimum required Rust version to 1.47, which is
required for the `Default` implementation on `Range`.
2021-04-06 10:34:21 +02:00
Benjamin Saunders 1f59c3d0cf Report stream events after connection events
Allows applications which do not use 0-RTT to rely on `Connected`
being delivered before any application data.
2021-04-04 22:13:51 +02:00
Benjamin Saunders e3a1f0d456 Store connection errors separately from non-error events 2021-04-04 22:13:51 +02:00
Lachezar Lechev c25475039f fix Next up link of Connection Setup chapter 2021-04-03 17:07:51 +02:00
Dirkjan Ochtman e07835b954 crypto: return Option from next_1rtt_keys()
A crypto session cannot return 1-RTT keys before handshaking is finished.
Currently, rustls contains unwrap() calls to deal with this, but hoisting
out the unwrap to the `Connection` level here seems more sensible.

We can adjust the call into rustls once we update rustls for other reasons.
2021-04-02 23:46:35 +02:00
Matthias Einwag cb6598b694 Make echo tests parameterizable and add new stress tests
This change adds additional config arguments to the echo test.
We are then using those arguments to run a higher number of
streams while utilizing low flow control windows to test flow
control updates.
2021-04-01 11:08:59 +02:00
Matthias Einwag 45e802c2f4 Don't enable trace logging in the test by default
This makes the test really slow. For debugging purposes it can
still be enabled via CLI.
2021-04-01 11:08:59 +02:00
Matthias Einwag da81d081f2 Improve test behavior for multiple and longer streams
Stream all the data in the echo handler, and run send and receive
concurrently in the sender.

Also spawn a separate task per stream.
2021-04-01 11:08:59 +02:00
Matthias Einwag 860273f559 Allow to send test data of an arbitrary size
This allows to generate a certain amount of test data in reproducible
fashion and echo it back.
2021-04-01 11:08:59 +02:00
Benjamin Saunders 5bd1ba570b Simplify state juggling 2021-03-31 09:00:26 +02:00
Benjamin Saunders 6616bc958a Don't unconditionally predict transmits on reset
The exact logic should handle this case just fine.
2021-03-31 09:00:26 +02:00
Benjamin Saunders 7ba3e3d3d3 Fix transmit prediction false negative regarding stream ID credit 2021-03-31 09:00:26 +02:00
Benjamin Saunders e4c3d9f89f Inline Retransmits::post_read 2021-03-31 09:00:26 +02:00
Benjamin Saunders 9d0d10ca6f Centralize post_read calls 2021-03-31 09:00:26 +02:00
Benjamin Saunders 08996a3676 Simplify state inspection 2021-03-31 09:00:26 +02:00
Benjamin Saunders 4b2909ac1a Decouple state from connection-level flow control issuing 2021-03-31 09:00:26 +02:00
Benjamin Saunders 3d3a0aa849 Deduplicate asserts 2021-03-31 09:00:26 +02:00
Benjamin Saunders ed6ddd46bd Inline Chunks::done 2021-03-31 09:00:26 +02:00
Benjamin Saunders 63b0586a2d Fold Blocked state into Readable
Because the only remaining possible error is Reset, we rename and
specialize the error state for clarity.
2021-03-31 09:00:26 +02:00
Benjamin Saunders 8538ff31c1 Improve test log readability 2021-03-31 09:00:26 +02:00
Benjamin Saunders e703d9d643 Fix missing flow control credit when reading a stream's tail 2021-03-31 09:00:26 +02:00
Benjamin Saunders 2cb44d06e4 Remove dead state
This field was always `true`.
2021-03-31 09:00:26 +02:00
daxpedda ed164fc458 Doc typo 2021-03-30 13:15:26 +02:00
daxpedda b3e7661911 Fix overflow in crypto_buffer_size 2021-03-29 19:59:09 +02:00
Matthias Einwag f8aac71171 Log max_data when write blocked
This can help to determine whether max_data limits are in sync
2021-03-27 08:40:33 +01:00
Matthias Einwag 20e9fbf545 Remove authenticated log
This pollutes the log a lot and doesn't help debugging.
All cases where a packet is not authenticated should already be
logged in different places, so just remove this.
2021-03-27 08:40:33 +01:00
Matthias Einwag 3162df74b7 Log all received frames
Before this change only stream frames had been logged.
Logging all frames helps debugging.
2021-03-27 08:40:33 +01:00
Benjamin Saunders 90f6168919 Update path validation timeout 2021-03-26 21:20:56 +01:00
Benjamin Saunders 1a3b613bde Define NO_VIABLE_PATH error
We don't need to generate this, but we might as well provide good
diagnostics if the peer generates it.
2021-03-26 21:20:56 +01:00
Benjamin Saunders 7c47c6e47c Don't issue MAX_STREAMS on locally-initiated stream completion 2021-03-26 20:13:33 +01:00
Benjamin Saunders e0f344fd99 Simplify 2021-03-26 20:13:33 +01:00
Benjamin Saunders cd7963221d Remove unnecessary reborrow 2021-03-26 20:13:33 +01:00
Benjamin Saunders 1082c13167 Idiomatic capitalization of CipherSuite variants 2021-03-26 20:13:33 +01:00
Benjamin Saunders 5315e6d4c7 Idiomatic capitalization of PseudoType variants 2021-03-26 20:13:33 +01:00
Benjamin Saunders fe5673bf20 Idiomatic capitalization of EcnCodepoint variants 2021-03-26 20:13:33 +01:00
Benjamin Saunders 5e68a8681e Replace Into impl with From 2021-03-26 20:13:33 +01:00
Benjamin Saunders 754106c2f8 Replace slicing with Deref 2021-03-26 20:13:33 +01:00
Benjamin Saunders a5667774f8 Import assert_matches explicitly
Fixes test build on rust beta.
2021-03-26 20:13:33 +01:00
Benjamin Saunders e801527c9b Lazily initialize Endpoint::default_client_config
Pure servers never need this. once_cell is already a transitive dep,
and is expected to eventually land in std, so it's free to add.
2021-03-21 14:51:19 -07:00
Benjamin Saunders 14813d33c2 Remove unintentional, obfuscatory use of Result::into_iter 2021-03-21 22:27:17 +01:00
Benjamin Saunders 68bd25d407 Simplify anti-deadlock logic
If no ACK-eliciting packets are in flight, then the only reason we'd
be setting the PTO is for anti-deadlock, so there's no need to scan
all spaces.
2021-03-21 22:27:17 +01:00
Benjamin Saunders 246ef596ec Remove dead code
Anti-deadlock packets are accounted for by
Connection::pto_time_and_space, so returning None on timeout is never
expected.
2021-03-21 22:27:17 +01:00
Benjamin Saunders 81b8d1e3ca Fix handshake deadlock
When the server's first flight is interrupted by anti-amplification
and the client's second flight is lost, the client has no
ack-eliciting packets in flight but will not be able to proceed until
an anti-amplification deadlock prevention probe is sent.
2021-03-21 22:27:17 +01:00
Thomas de Zeeuw 817a57d281 Increase type_length_limit to 2121396
Previously rustc would fail with
error: reached the type-length limit while instantiating
`<std::vec::IntoIter<Peer> as std...rs:216:58: 220:6 keylog:&bool]]>`
2021-03-21 14:39:11 +01:00
Thomas de Zeeuw 2a6c0afaf1 Increase MSRV to 1.46 2021-03-21 14:39:11 +01:00
Thomas de Zeeuw 49475c22b2 Update to socket2 v0.4 2021-03-21 14:39:11 +01:00
Matthias Einwag a5f8325ee7 Create ClientConfig lazily in EndpointBuilder
Creating a `ClientConfig` can on some platforms take an excessive amount
of time, likely due to rustls scanning the systems cert store.
This slows down all functions which make use of `quinn::Endpoint::builder()`,
even if the client config is known upfront and shared between mutliple connections.

In some tests I noticed an extra connection establishment time of 1s for
creating a client.

This changes will create the `ClientConfig` only if the Endpoint is built
when the `ClientConfig` hasn't been set by the application.

Server side code still suffers from the issue, since `ClientConfig`s there are not
known. However it might be less impacting, since a second of startup time for
a server matters less than for a client.
2021-03-20 11:14:31 -07:00