3510 Commits

Author SHA1 Message Date
Benjamin Saunders 0e9a19665a Rename UnknownStream to ClosedStream for clarity 0.11.0 2024-05-03 11:52:44 -07:00
Benjamin Saunders 130d956efc Don't treat UnknownStream as an error in SendStream::stopped
UnknownStream here corresponds to graceful stream shutdown, which is
not an error case.
2024-05-03 11:52:44 -07:00
Benjamin Saunders b42e21e74d Make SendStream::finish synchronous
`await`ing on this was error-prone and not very useful, since it gave
little insight into application state, and was redundant to `stopped`.
2024-05-03 11:52:44 -07:00
Dirkjan Ochtman f28cb3d8d6 Check compilation without default features in CI
Other workspace members enable some features, so check in isolation.
2024-05-03 11:38:05 -07:00
Dirkjan Ochtman 272dd5d45f quinn: add proper guards to Endpoint constructor helpers 2024-05-03 11:38:05 -07:00
Dirkjan Ochtman 74c035822b quinn: UdpPoller::new() is only called if a runtime is enabled 2024-05-03 11:38:05 -07:00
Dirkjan Ochtman faf7dbc051 quinn: require rustls for insecure_connection example 2024-05-03 11:38:05 -07:00
Dirkjan Ochtman e764fe48ce proto: remove incorrect feature guard
`HashedConnectionIdGenerator::new()` uses the mandatory rand crate to
generate a key by default, not the *ring* crate.
2024-05-03 11:38:05 -07:00
Dirkjan Ochtman 7af5296dc3 proto: guard rustls-specific types 2024-05-03 11:38:05 -07:00
Dirkjan Ochtman de3f63737b Apply clippy suggestions from Rust 1.78 2024-05-03 16:11:44 +02:00
Dirkjan Ochtman 5b722706b3 proto: take advantage of rustls::quic::Suite being Copy 2024-05-02 15:39:30 -07:00
Benjamin Saunders d5fc528930 Truncate GSO when necessary to avoid excessive padding 2024-05-01 09:41:03 -07:00
Benjamin Saunders 003b1d54b5 Don't try to send datagrams that won't fit in a GSO batch 2024-05-01 09:41:03 -07:00
Benjamin Saunders 9d8ee9f068 Factor packet overhead math out of Datagrams::max_size 2024-05-01 09:41:03 -07:00
Benjamin Saunders ad4919babc Match GSO segment size to the first datagram, not the MTU
Reduces the amount of padding required when sending homogeneously
sized non-fragmentable data like application datagrams.
2024-05-01 09:41:03 -07:00
Benjamin Saunders bbff686a32 Factor GSO segment size out into a local variable 2024-05-01 09:41:03 -07:00
Benjamin Saunders fe6989bdf4 Track starting offset of the current datagram explicitly 2024-05-01 09:41:03 -07:00
Benjamin Saunders 8c89b79e15 Delete dead comment 2024-05-01 09:33:38 -07:00
Benjamin Saunders 3089e8739a Additional trace logs 2024-05-01 09:33:38 -07:00
Benjamin Saunders ff8609b6d4 Verify that GSO is used for simple large streams 2024-05-01 09:33:38 -07:00
Benjamin Saunders c76c378aaa Fix unit test time travel
The current system time must only be sampled once to establish the
unit test epoch. Because test time doesn't advance unless told to,
this was causing connections to sometimes receive packets from before
they were created, causing odd warnings and potentially other
unintended behavior.
2024-05-01 09:33:38 -07:00
Benjamin Saunders 7056581575 Fix loss detection timer sometimes lingering after close 2024-05-01 09:33:38 -07:00
Benjamin Saunders 6053163874 Use RAII span guard in PacketBuilder
Prevents spans from leaking when packets aren't finished
2024-05-01 09:33:38 -07:00
Benjamin Saunders 7b2351556b Drop outgoing datagrams forbidden by current MTU 2024-05-01 09:33:38 -07:00
Benjamin Saunders e4f2629af2 Notify congestion control of MTU reductions 2024-05-01 09:33:38 -07:00
Benjamin Saunders 9add93e19e Fix panic in max_datagram_size before 1-RTT keys are known 2024-05-01 09:33:38 -07:00
Benjamin Saunders bd516098e0 Factor out complex subexpression 2024-05-01 09:33:38 -07:00
Benjamin Saunders 7cf0a025fc Look up the time through trait Runtime 2024-05-01 10:37:39 +02:00
Benjamin Saunders d5849f0544 Pass time getter into WorkLimiter
Groundwork for runtime-managed time
2024-05-01 10:37:39 +02:00
Phoenix Kahlo 30e1d6fe14 Fix race condition between 0-RTT and Incoming
Closes #1820

The fix:

- Endpoint now maintains a slab with an entry for each pending Incoming
  to buffer received data.
- ConnectionIndex now maps initial DCID to that slab key immediately
  upon construction of Incoming.
- If Incoming is accepted, association is overridden with association
  with ConnectionHandle, and all buffered datagrams are fed to newly
  constructed Connection.
- If Incoming is refused/retried/ignored, or accepting errors,
  association and slab entry are cleaned up to prevent memory leak.

Additional considerations:

- The Incoming::ignore operation can no longer be implemented as just
  dropping it. To help prevent incorrect API usage, proto::Incoming is
  modified to log a warning if it is dropped without being passed to
  Endpoint::accept/refuse/retry/ignore.
- Three things protect against memory exhaustion attacks here:

  1. The MAX_INCOMING_CONNECTIONS limit is moved from quinn to proto,
     limiting the number of concurrent incoming connections for which
     datagrams will be buffered before the application decides what to
     do with them. Also, it is changed from a constant to a field of the
     server config, max_incoming.
  2. Per-incoming buffered data is limited to a new limit stored in the
     server config, incoming_buffer_size, beyond which subsequent
     packets are discarded if received in these conditions.
  3. The sum total of all incoming buffered data is limited to a new
     limit stored in the server config, incoming_buffer_size_total,
     beyond which subsequent packets are discarded if received in these
     conditions.
2024-05-01 10:19:25 +02:00
Phoenix Kahlo 89f99bbdc0 proto: Factor out DatagramConnectionEvent 2024-05-01 10:19:25 +02:00
Dirkjan Ochtman af30cbdc4b Add references to OpenCollective 2024-04-26 10:40:23 -07:00
Dirkjan Ochtman 76b9099108 Remove badges from metadata 2024-04-26 10:36:49 -07:00
Benjamin Saunders 46ac7d70cd Replace BytesMut transmit buffers with Vec
We no longer need to share ownership of this memory, so we should use
a simpler type to reflect our simpler requirements.
2024-04-25 18:21:13 -07:00
Benjamin Saunders 375445db2b Fix incorrect size in split_transmit
This didn't impact any tests, but was confusing.
2024-04-25 18:21:13 -07:00
Benjamin Saunders 5613a45924 Transmit borrowed UDP payloads
Because we no longer buffer transmits for unpredictable periods,
there's no need to share ownership of their contents.
2024-04-25 18:21:13 -07:00
Benjamin Saunders ee0882657a Drop sendmmsg support
As we no longer buffer multiple transmits in memory, this complexity
is unused. GSO is expected to account for most, if not all, of the
performance benefit.
2024-04-25 18:21:13 -07:00
Benjamin Saunders 07222809c0 Fix bitrotted fallback UDP backend
`UdpState` was removed some time ago, and various other interface
details have changed. As a result, the build would fail on platforms
without native support.
2024-04-25 18:21:13 -07:00
Benjamin Saunders d075733dda Don't buffer endpoint-generated datagrams
Dropping these has low cost because they're not associated with any
connection.
2024-04-25 18:21:13 -07:00
Benjamin Saunders 9860617e34 Annotate client/server tasks in rebind_recv test 2024-04-25 18:21:13 -07:00
Benjamin Saunders 7727989b30 Don't reallocate send buffer for every batch of transmits 2024-04-25 18:21:13 -07:00
Benjamin Saunders 3adf5338b0 Reduce rightward drift 2024-04-25 18:21:13 -07:00
Benjamin Saunders 426c1d26a0 Remove newly superfluous quinn::EndpointEvent 2024-04-25 18:21:13 -07:00
Benjamin Saunders fe1643dc8b Transmit directly from connection tasks 2024-04-25 18:21:13 -07:00
Benjamin Saunders 3a62a9eeab Update connection sockets on rebind 2024-04-25 18:21:13 -07:00
Benjamin Saunders de7d3342f9 Replace AsyncUdpSocket::poll_send with try_send and poller object
Allows multiple tasks to concurrently wait for writability on the same
socket. See the [tokio] and [async-io] docs for details.

[tokio]: https://docs.rs/tokio/latest/tokio/net/struct.UdpSocket.html
[async-io]: https://docs.rs/async-io/latest/async_io/struct.Async.html#concurrent-io
2024-04-25 18:21:13 -07:00
Benjamin Saunders ef73b2df97 Lift udp_transmit helper out of endpoint.rs 2024-04-25 18:21:13 -07:00
Benjamin Saunders 5507c6bf7e Fold redundant use blocks 2024-04-25 18:21:13 -07:00
Benjamin Saunders 5f63104b6a Accept connections with unrecognized address validation tokens 2024-04-25 09:06:24 +02:00
Benjamin Saunders b07370a5e3 Store client address explicitly in the retry token 2024-04-25 09:06:24 +02:00