Commit Graph

3790 Commits

Author SHA1 Message Date
Phoenix Kahlo bfbeecdc1c proto: Reject RetryToken with extra bytes
This probably won't affect much, but is slightly more defensive.
2024-12-24 05:31:22 +00:00
Phoenix Kahlo fe67e7cd64 proto: Remove ValidationError
As of the previous commit, RetryToken::decode fails only with the
Unusable variant, and validation only occurs in
IncomingToken::from_header, which uses InvalidRetryTokenError directly.
This allows us to remove ValidationError altogether.
2024-12-24 05:31:22 +00:00
Phoenix Kahlo 692509900b proto: Make address a field of RetryToken
Prior to this commit, a RetryToken encodes the client's address as if it
were a field, but rather than it actually being a field, it's threaded
in to encode, and validated in-place in decode. It's unclear to me why
this is. This commit makes the remote address simply a field of the
RetryToken struct.
2024-12-24 05:31:22 +00:00
Phoenix Kahlo e6380df486 proto: Rearrange lines of RetryToken::encode
Organizes encoding payload section versus encrypting section.
2024-12-24 05:31:22 +00:00
Phoenix Kahlo 5c381aab52 proto: Remove Cursor usage from token.rs 2024-12-24 05:31:22 +00:00
Phoenix Kahlo 5b4518446b proto: Simplify encode_unix_secs 2024-12-24 05:31:22 +00:00
Phoenix Kahlo 371f18032d proto: Factor out encode_unix_secs
This will be useful for NEW_TOKEN usage, as it will make there be more
than one call site for this.
2024-12-24 05:31:22 +00:00
Phoenix Kahlo bde7592ea5 proto: Remove panic hazards from RetryToken decode
Prior to this commit, decoding a socket addr from a RetryToken called
get_u8 and get_u16, which would have panicked if an encrypted token were
minted that terminated after that point. This replaces them with calls
that short-circuit, for consistency with other parts of the code there.
2024-12-24 05:31:22 +00:00
Phoenix Kahlo 8fd8e1a7c8 proto: Factor out encode_ip
This will be useful for NEW_TOKEN usage, as validation tokens will only
include IP address and not port.
2024-12-24 05:31:22 +00:00
Phoenix Kahlo b0e39a97fc proto: Rename RetryToken::from_bytes -> decode
For symmetry with encode.
2024-12-24 05:31:22 +00:00
Phoenix Kahlo 7caa30bd61 proto: Pass ConnectionId by value internally 2024-12-23 21:50:08 +00:00
Phoenix Kahlo f99ca19bfe proto: Factor out return in handle 2024-12-23 19:11:12 +00:00
Phoenix Kahlo b1e77091ea proto: Use pre-existing variable in handle 2024-12-23 19:11:12 +00:00
dependabot[bot] 7cc1db2cbc build(deps): update rustls-platform-verifier requirement from 0.4 to 0.5
Updates the requirements on [rustls-platform-verifier](https://github.com/rustls/rustls-platform-verifier) to permit the latest version.
- [Release notes](https://github.com/rustls/rustls-platform-verifier/releases)
- [Changelog](https://github.com/rustls/rustls-platform-verifier/blob/main/CHANGELOG)
- [Commits](https://github.com/rustls/rustls-platform-verifier/compare/v/0.4.0...v/0.4.0)

---
updated-dependencies:
- dependency-name: rustls-platform-verifier
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-23 17:00:03 +00:00
Phoenix Kahlo ea82621806 Remove various obselete allow directives 2024-12-22 22:10:49 +00:00
Phoenix Kahlo c249f9e838 Remove use self:: occurrences 2024-12-21 19:39:30 +00:00
Phoenix Kahlo b350bb1b15 proto: Refactor Endpoint::handle
Removes some unnecessary indirection.
2024-12-21 19:38:08 +00:00
Phoenix Kahlo c1aa2a8be8 proto: Utilize let-else in Endpoint::handle
Reduces rightward drift.
2024-12-21 19:38:08 +00:00
Phoenix Kahlo 20717041bc proto: Pass SocketAddr by value 2024-12-21 19:37:03 +00:00
Phoenix Kahlo 16f83d1c8f proto: Remove superfluous #[doc(hidden)] fuzzing
The module is already `#[cfg(fuzzing)]`, which should make it not appear
in docs.
2024-12-21 08:19:48 +00:00
Phoenix Kahlo 33954582da udp: Tweak EcnCodepoint::from_bits 2024-12-21 08:19:30 +00:00
Phoenix Kahlo f51c93f2c2 udp: Un-hide EcnCodepoint variants 2024-12-21 08:19:30 +00:00
Phoenix Kahlo 37b93406cd proto: Un-hide EcnCodepoint variants 2024-12-21 08:19:30 +00:00
Phoenix Kahlo e7b5c6c1aa Rename initiate_key_update -> force_key_update 2024-12-21 08:19:05 +00:00
Phoenix Kahlo 5992acf403 Un-hide force_key_update / initiate_key_update 2024-12-21 08:19:05 +00:00
Dirkjan Ochtman 670c517f42 proto: re-order items in token module 2024-12-21 07:51:18 +00:00
Dirkjan Ochtman 268cbd9116 proto: inline IncomingToken::from_retry() 2024-12-21 07:51:18 +00:00
Dirkjan Ochtman 020c38b1b7 token: move RetryToken::validate() to IncomingToken::from_retry() 2024-12-21 07:51:18 +00:00
Dirkjan Ochtman 8a488f2d7e proto: inline trivial constructor 2024-12-21 07:51:18 +00:00
Phoenix Kahlo 506e74417a quinn: Make SendStream::poll_stopped private
Previously, this method was public, but marked as `#[doc(hidden)]`.
However, nothing anywhere was using it. This commit makes it private.
2024-12-20 19:45:30 +00:00
Phoenix Kahlo 69c0406f0b Un-hide get_max_udp_payload_size
- Removes `#[doc(hidden)]`
- Adds hyperlink
- Demotes most of the doc comment to non-doc comment, as it seems more
  like an internal note than something the user needs to see.
2024-12-20 19:41:52 +00:00
Phoenix Kahlo 870375cc83 Implement Default for ClosedStream
This allows us to remove the `#[doc(hidden)] pub fn new() -> Self`.
2024-12-20 19:39:34 +00:00
Dirkjan Ochtman 43b74b658b proto: replace hidden field with From impl 2024-12-20 19:34:28 +00:00
Phoenix Kahlo afc7d7f8ae proto: Factor out IncomingToken::from_header
Moves more logic from Endpoint::handle_first_packet to the proto::token
module. Due to improved decoupling between modules, Token::from_bytes
and ValidationError can now be made private.
2024-12-20 10:31:06 +00:00
Phoenix Kahlo 89f3f458de proto: Factor out IncomingToken
Factors out the retry_src_cid and orig_dst_cid fields of Incoming into
a new token::IncomingToken struct.
2024-12-20 10:31:06 +00:00
Max Inden 6ee883a20c fix(udp): make GRO (i.e. URO) optional, off by default
We have multiple bug reports for URO on Windows, including non-ARM. See:

- https://github.com/quinn-rs/quinn/issues/2041
- https://bugzilla.mozilla.org/show_bug.cgi?id=1916558

Instead of enabling GRO on Windows by default, this commit changes the default
to off, adding a `set_gro` to optionally enable it.
quinn-udp-0.5.9
2024-12-17 19:31:02 +00:00
Max Inden 85011ef42e Revert "fix(udp): do not enable URO on Windows on ARM"
This reverts commit 7260987c91.
2024-12-17 19:31:02 +00:00
Max Inden b720c6a1d3 chore(udp): increase crate patch version to v0.5.9 2024-12-17 12:55:37 +00:00
Max Inden e953059994 fix(udp): retry send on first EINVAL
Android API level < 26 does not support the `libc::IP_TOS` control message.
`sendmsg` calls with `libc::IP_TOS` return `libc::EINVAL`.

https://github.com/quinn-rs/quinn/pull/1516 added a fallback, not setting
`libc::IP_TOS` on consecutive calls to `sendmsg` after a failure with
`libc::EINVAL`. The current datagram would be dropped. Consecutive datagrams
passed to `sendmsg` would succeed as they would be sent without `libc::IP_TOS`
through the fallback.

Instead of dropping the first datagram on `libc::EINVAL`, this commit adds a
retry for it without `libc::IP_TOS`.

This is e.g. relevant for Neqo. When establishing a QUIC connection, dropping
the first datagram [delays connection establishment by
100ms](https://github.com/mozilla/neqo/blob/3001a3a56f2274eaafaa956fb394f0817f526ae7/neqo-transport/src/rtt.rs#L28).
With the retry introduced in this commit, delay due to unsupported
`libc::IP_TOS` should be negligeable.

Closes https://github.com/quinn-rs/quinn/pull/1975.
2024-12-17 12:55:37 +00:00
Max Inden a83c6e463b ci: run on Android API Level 25 2024-12-17 12:55:37 +00:00
Max Inden cb0b59d09c refactor(udp): remove unnecessary return
No need to `return Ok(())` early, given the final `return Ok(())` at the end of
the function. Makes it consistent with other `send` implementations. Makes it
consistent with early returns being errors only.
2024-12-17 12:25:31 +00:00
Phoenix Kahlo 51606c6e34 Make SystemTime mockable via object
- Adds trait TimeSource
- Adds default implementation StdSystemTime
- Adds ServerConfigParameter time_source: Arc<dyn TimeSource>
- Replaces all SystemTime::now calls in proto with TimeSource.now calls
  (there were 2)

This is a backwards-compatible change.
2024-12-17 08:22:09 +00:00
Phoenix Kahlo c5f81bec9b proto: Make Connection externally use SideArgs
Server/client-specific args to proto::Connection::new are now passed
through a new SideArgs enum.
2024-12-16 18:56:53 +00:00
Phoenix Kahlo e706cd8ac0 proto: Make Connection internally use SideState
Moves server/client-specific fields of proto::Connection to a new
SideState enum.
2024-12-16 18:56:53 +00:00
Phoenix Kahlo 51e974e4d9 proto: Refactor TokenDecodeError 2024-12-16 09:30:38 +00:00
Phoenix Kahlo caf838947c tests(proto): Gate PLPMTUD test
There is a should_panic test which depends on a debug assertion to
panic. This commit makes the test enabled only when debug assertions
are enabled. This fixes `cargo test --release`.
2024-12-16 09:28:59 +00:00
Phoenix Kahlo 73545b65b3 Adjust terminology regarding tokens
RFC 9000 presents some unfortunate complications to naming things. It
introduces a concept of a "token" that may cause a connection to be
validated early. In some ways, these tokens must be treated discretely
differently based on whether they originated from a NEW_TOKEN frame or
a Retry packet. It also introduces an unrelated concept of a "stateless
reset token".

If our code and documentation were to constantly use phrases like "token
originating from NEW_TOKEN frame," that would be extremely cumbersome.
Moreover, it would risk feeling like leaking spec internals to the user.

As such, this commit tries to move things towards the following naming
convention:

- A token from a NEW_TOKEN frame is called a "validation token", or
  "address validation token", although the shorter form should be used
  most often.
- A token from a Retry packet is called a "retry token".

  We should avoid saying "stateless retry token" because this phrase is
  not used at all in RFC 9000 and is confusingly similar to "stateless
  reset token". This commit changes public usages of that phrase.
- In the generic case of either, we call it a "token".
- We still call a stateless reset token a "reset token" or "stateless
  reset token".
2024-12-15 06:23:50 +00:00
Phoenix Kahlo 04b9611aff docs(quinn): Tweak Connecting docs 2024-12-15 06:05:34 +00:00
Phoenix Kahlo 8ab077dbce quinn: Remove obsolete must_use for futures 2024-12-15 06:05:09 +00:00
Phoenix Kahlo db4c0e40da chore: Re-ignore stress tests in solaris 2024-12-15 06:04:21 +00:00