Commit Graph

4328 Commits

Author SHA1 Message Date
Philipp Krüger 8e0185f851 Avoid .collecting in populate_packet 2025-11-06 13:03:19 +01:00
Philipp Krüger da4ceaf371 Lookup paths slightly less often 2025-11-06 12:33:31 +01:00
Philipp Krüger 378f3421ed Make PacketBuilder::new not depend on &mut Paths.
Instead, it takes `max_pto: Duration`, which would otherwise be computed deep inside of it.
Unfortunately, this means we're pre-computing the value, and we also need to expose `close_pto` in `Connection`.

I'll experiment with this for now, but we'll see if this worsens performance.
2025-11-06 10:06:31 +01:00
Philipp Krüger 1e92178fac Split out paths into their own struct outside Connection 2025-11-05 17:24:55 +01:00
dignifiedquire 4eae1e739c happy clippy 2025-11-04 16:05:50 +01:00
dignifiedquire 7196383f1e update MSRV to 1.79 2025-11-04 16:01:40 +01:00
dignifiedquire 5a03abc0ca fixup docs 2025-11-04 15:59:27 +01:00
dignifiedquire d20aff012d perf: use IdentityMap 2025-11-04 15:51:15 +01:00
dignifiedquire 0bc51d4f12 refactor: implement basic SmallMap for timers 2025-11-04 15:51:15 +01:00
dignifiedquire 6164dafd5b make a little bit faster by avoiding iterators 2025-11-04 15:51:15 +01:00
dignifiedquire f35a0778b4 fixup comparisons 2025-11-04 15:51:15 +01:00
dignifiedquire c35fafc43e perf: implement more efficient timeouts 2025-11-04 15:51:15 +01:00
Floris Bruynooghe 34eee26fc7 fix: Key update on the first packet of a new PathId (#165)
The first packet on a new PathId could be a key update.  Handle this
correctly: The expected packet number of the key update packet is 0 in
this case.

This changes the expected packet number when expanding the packet
number as well: Formerly we always expected packet 1 on a new PathId,
while strictly we would be expecting packet 0.  This makes no
measurable difference though, since both values would be encoded in
the same way anyway so the expansion was still doing the right thing.
2025-11-04 15:50:23 +01:00
Floris Bruynooghe f8b9a7f062 Fix wasm and time computations (#164)
Ported from https://github.com/quinn-rs/quinn/pull/2436

* Remove `instant_saturating_sub` fn in favor of `Instant::saturating_duration_since`

* Avoid underflow panic in packet loss `Instant` calculations
2025-11-04 15:44:00 +01:00
Floris Bruynooghe bc99406e75 Fix clippy for rust 1.91 (#163) 2025-11-04 13:05:16 +01:00
Diva Martínez 20e462d810 nat traversal requires multipath (#159)
* nat traversal requires multipath

* allow crate access, not ideal, but unavoidable

* satisfty MSRV limits

* pub all the way to the top

* update wasm-bindgen-test
2025-10-28 09:25:02 -05:00
Diva Martínez 85a2706e3c add transport parameter (#158)
* add nat_traversal field to TransportParameters

* add nat traversal's concurrency limit field to TransportConfig

* add nat_traversal TransportParameterId

* make field private to prevent zero values, reject 0 always

* enforce 0-rrt data matches
2025-10-28 09:25:02 -05:00
Diva Martínez 07d5a908e4 add RemoveAddress frame (#156) 2025-10-28 09:25:02 -05:00
Diva Martínez 3c9c86222a add PunchMeNow frame (#155) 2025-10-28 09:25:02 -05:00
Diva Martínez 7ab314eea9 add AddAddress frame (#154) 2025-10-28 09:25:02 -05:00
Floris Bruynooghe d6dcb2d33c Improve docs (#161) 2025-10-28 11:49:35 +01:00
Floris Bruynooghe e74c803219 Fix check for max permitted PathId in PATH_CIDS_BLOCKED frame (#157)
Also sneak in a unrelated logging improvement.
2025-10-25 17:41:20 +02:00
Divma a4597406bf Fix connection's mtu calculation (#151)
* calculate this connection's mtu as the minimum across all paths

* add TODO to check buffer reserving

* improve docs

* apply clippy fixes

* more docs tweaks

* second perspective on TODO

* spelling

* address TODO: reserving is already done in poll_transmit with the appropiate sizes
2025-10-17 14:17:51 -05:00
Floris Bruynooghe 2d68ea5303 Switch to released rustls (#152) 2025-10-17 11:00:04 -05:00
Divma 5b8ce80053 enforce MAX_PATH_ID and abandoned paths check for new CIDs (#150) 2025-10-15 22:57:34 -05:00
Divma 63accf039b remove TODOs since the current state seems acceptable (#149) 2025-10-15 12:20:21 -05:00
Divma 0f295e0502 cleanup use of PathId constants and access to inner (#148)
* use PathId::ZERO whenever possible

* avoid accesing PathId's inner in general

* fmt

* prefer PathId::MAX over max construction
2025-10-15 11:34:15 -05:00
Floris Bruynooghe 5268c3046d remove redundant logging (#147)
I messed this up earlier, this is already logged.
2025-10-15 13:43:20 +02:00
Divma 78d5e13e5d add missing path stats in debug impl, remove obsolte comment (#145) 2025-10-14 16:01:56 -05:00
Divma 6b1415086b cleanup frame.rs ToDos and unwraps (#144)
* remove obsolete dead code annotation

* add missing docs for coding and encoding path related frames

* make `RetireConnectionId` max size into consts

* make `NewConnectionId` max size into consts

* remove unwraps comming from n0 members in frame.rs
2025-10-14 12:35:18 -05:00
Floris Bruynooghe ef19d53391 Fix remote addresses in paths (#141)
* Fix remote addresses in paths

- Remove quinn_proto::Connection::remote_address.  You should use
  path_remote_address now.

- Change quinn::Connection::remote_address to return *any* remote
  address from any of the open paths.

- Fix opening paths on IPv4 addresses, when the endpoint supports
  IPv6.

  When the endpoint supports IPv6 it uses IPv4-mapped IPv6 addresses
  for IPv4 remotes.  This is enforced when establishing a connection,
  and quinn-udp automatically does this for incoming datagrams.
  However when opening a path we should do the same mapping.
  Otherwise we will end up with an IPv4 remote address in the PathData
  and incoming datagrams will come from an IPv6 address and be
  dropped.

* fix tests
2025-10-14 17:39:08 +02:00
Floris Bruynooghe 3d93d11d3f Bump the max padding allowe in GSO batches (#143)
When building packets in GSO batches the batch is terminated if too
many padding bytes would be needed to continue this batch.  This was
chosen fairly arbitrarily to be 16 bytes.

However when you have multipath enabled and allow a half-decent number
of simulatneous paths to be opened, you have to issue 5 *
initial_max_path_id PATH_NEW_CONNECTION_ID frames.  This quickly
spills over into multiple datagrams, especially since this happens
early in the connection when the PMTU has not yet been discovered.

CIDs however, are 32 bytes by default.  So if such a frame does no
longer fit in a datagram you would easily need more than 16 bytes of
padding.  And in that case the GSO batch would break.  Even though all
you're doing is sending a series of datagrams full of CIDs.

So tweaking this number to 32 allows us to build these packes without
breaking the GSO batch.
2025-10-14 17:38:55 +02:00
Floris Bruynooghe 1645586095 fix span field name (#142)
If only tracing would be type-safe.  But yeah, strings are fiiiine
2025-10-14 17:32:04 +02:00
Floris Bruynooghe 61381971aa Allow setting the status of a path (#140) 2025-10-14 17:31:44 +02:00
Floris Bruynooghe 257d32deae Only send an MTUD if there is an active CID, fixes a panic (#139) 2025-10-10 17:45:17 +02:00
Floris Bruynooghe a63efb2d02 Make Path impl fmt::Debug (#138) 2025-10-10 17:45:06 +02:00
Floris Bruynooghe 06c83ffe67 Trace log the OBSERVED_ADDR frames (#135)
This in the same style as the other frames are logged.  It's very
confusing to not have a trace log of this.
2025-10-08 13:40:58 +02:00
Floris Bruynooghe 3820a0ae48 upgrade rustls to 0.23.29 to match iroh (#134) 2025-10-06 12:38:49 +02:00
Floris Bruynooghe 5cab4537d9 Fix WeakConnection::upgrade (#132)
* Fix WeakConnection::upgrade

It created a ConnectionRef that did not increment the manually-tracked
reference count inside the Arc<ConnectionInner>.  This triggered the
ConnectionRef's Drop impl to actually drop the connection.

This works around this by using the fact that the ConnectionRef's
Clone impl does know how to manipulate the reference count in a way
that works together with the ConnectionRef's Drop.  I think this is
preferred over manipulating the ref_count directly in the
WeakConnectionHandle since that code is closer by.

* Nicer implementation
2025-10-03 12:43:19 +02:00
Floris Bruynooghe df461f1500 Expose the remote address of a path (#133) 2025-10-03 09:50:43 +02:00
Floris Bruynooghe 1053f8ed28 Allow the WeakConnectionHandle to be cloned (#131) 2025-10-02 16:23:42 +02:00
Floris Bruynooghe 28f94e99c6 Allow server migration before authenticated handshake packets (#130)
The previous logic does not work: the client has the path validated
immediately, even before any packet is sent.

Now we need to have received an authenticated handshake packet before
we stop allowing migration.  This exposes us to a little more off-path
attacking, but in terms of processing all the earlier packets: only
the correct server can generate an authenticated handshake packet IIUC.
2025-10-02 16:22:36 +02:00
Floris Bruynooghe 9ba8b774fa Add OpenPath::path_id and some docs (#127)
* Add OpenPath::path_id and some docs

* Try and word this a little better
2025-10-02 10:47:36 +02:00
Divma dc582a3a97 cherry-pick Phillip's changes from quinn/main (#129)
This also includes removing async-std support. These are commits on top
of which Phillip's ones are made
2025-10-01 13:26:58 -05:00
Diva M 56a5a35f38 fixes to make everything work together 2025-10-01 13:22:35 -05:00
Diva M 4d39665d48 Revert Dig's merge fixed to bring back const
This reverts commit 44a3dc6e45.
2025-10-01 13:22:24 -05:00
Philipp Krüger 2e95861ce8 Store a Box<dyn AsyncUdpSocket> instead of Arcing it, make poll_recv take &mut self 2025-10-01 13:21:08 -05:00
Philipp Krüger 42a39e7b69 Refactor UdpPoller into UdpSender and use it in favor of AsyncUdpSocket in connections 2025-10-01 13:21:04 -05:00
Dirkjan Ochtman 0e2d551c27 Remove more traces of async-std 2025-10-01 13:20:43 -05:00
Dirkjan Ochtman 04c1aaf1e6 quinn: drop async-std support 2025-10-01 13:19:43 -05:00