Fixes#864
## Description
`PrevCrypto` now records, for each path, the first packet received under
the new keys. A packet decrypts with the previous keys until its own
path has seen one. `end_packet` is split into `end_time` (still used by
the discard timer) and `end_packets`. Adds
`key_update_keeps_late_old_key_packets_on_another_path`, which fails on
main.
## Notes
A path with no new-key packet yet keeps using the previous keys, so a
further key update the peer started on such a path before we drop the
old keys would fail to decrypt. RFC 9001 §6.5 has the peer wait three
PTOs after its previous update is acknowledged, and accepts that packets
may be discarded if it doesn't.
## Change checklist
- [x] Self-review.
- [x] Tests if relevant.
- [x] `cargo make` passes locally.
<!-- Attention agents and contributors using AI, please see our AI
policy before opening a PR:
https://github.com/n0-computer/noq/blob/main/AI_POLICY.md -->
<!-- Any PRs violating this policy will be closed. -->
<!-- As per our contributor guidelines, all PRs that do not link to an
issue with the label `ready-for-pr` will be closed:
https://github.com/n0-computer/noq/blob/main/CONTRIBUTING.md -->
## Description
Add additional tests for stream affinity.
noq-proto test is a vanity test so I can have a hook into starting to
understand stream affinity and packet building.
<!-- A summary of what this pull request achieves and a rough list of
changes. -->
## API Changes
<!-- Optional, any API additions, deprecations or breaking changes,
including how to migrate older code. -->
## Notes & open questions
<!-- Any notes, remarks or open questions you have to make about the PR.
-->
Not finished, going to add additional tests for these cases:
- general noq test showing affinities are respected
- test showing stream affinity changes happen if you change from block
-> any
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] `cargo make` passes locally.
## Description
This allows streams to declare an affinity to a particular path. The
path ID must be known, which can be retrieved from path events etc.
## API Changes
New API:
- `SendStream::set_affinity`
## Notes & open questions
Replaces #871.
The way to to discover which paths are available and how to get updates
to them could be improved. But the existing APIs are already able to do
this. E.g. iroh does expose this in an easier way already. Improving
those APIs can be a reasonable thing to do, but does not need to be part
of this API.
This does not yet allow setting a connection-wide affinity. It is too
easy to accidentally block all data on a connection. There are already
other APIs that affect global path use: closing paths or using the path
status. This is specifically for stream-specific exceptions, so leaving
the API like this makes this more clear.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [ ] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
## Description
Fixes#883.
## Notes & open questions
These are just two cherry-picks. Still needs review from somebody
familiar with the context.
Verified that
`recv_single_after_truncation_returns_would_block_instead_of_spin` fails
without the fix (macOS).
## Change checklist
- [x] Self-review.
- [ ] ~~Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.~~
- [x] Tests if relevant.
- [ ] ~~All API changes documented.~~
- [x] This PR was created by a human that thought critically about the
proposed change and wrote an as clear and concise description as
they could.
- [x] This PR isn't slop, and is carefully crafted to do have the
intented effect.
- [x] `cargo make` passes locally.
---------
Co-authored-by: zerox80 <rujbin@protonmail.com>
Co-authored-by: Dirkjan Ochtman <dirkjan@ochtman.nl>
## Description
- There was a use-after-fee regression in 1.14 that means it was yanked
which made cargo-deny unhappy.
- patchbay failed to build because noq main has deprecated an API that
iroh uses. But we don't actually care about build warnings of iroh in
noq. Allow them.
## API Changes
n/a
## Notes & open questions
n/a
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
## Description
This moves the minimal-crates tests to the shared workflow. This will
allow us to make this test required again as it should no longer fail
when we release our own crates.
Also triggers the wine and zizmor workflows for the merge queue, so that
we can make those required checks as well.
## API Changes
n/a
## Notes & open questions
Needs a new tag on the workflows repo once
https://github.com/n0-computer/workflows/pull/10 is merged. Then pinact
and zizmor will be happy here.
This will allow us making the min-crates a required check again.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
## Description
The new BBR3 tests do so much work that they're slow. I guess we have
to accept this slowness for now :(
## API Changes
n/a
## Notes & open questions
This is kinda sad, but I didn't see an easy win as to why they're slow.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
## Description
Fixes#865.
`defragment` dropped everything below `bytes_read`, which in unordered
mode is a count of delivered bytes, not an offset, so compaction could
throw away data that was never read. `defragment` now takes the offset
to discard below: `insert` passes 0, and only the switch to unordered
mode passes `bytes_read`, where it's still an offset. That matches
quinn.
Adds `unordered_compaction_keeps_unread_data`, the repro from the issue.
## API Changes
None.
## Notes & open questions
This touches `defragment` like #866, so whichever lands second needs a
small rebase.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
## Description
Replaces #828, as discussed there. The first two commits of that PR
landed in #823, so this is the remaining one: the port of
quinn-rs/quinn#2814, adapted to the sorted `VecDeque` from #823.
Without it, 1.4.0 can close a connection with "too many gaps in stream
buffer" when a reader falls about 2,048 packets behind, even with no
gaps. Packet-sized chunks get marked defragmented and are never merged
again, so compaction can't get back under `MAX_CHUNKS`. `defragment` now
also merges contiguous chunks smaller than `buffered / MAX_CHUNKS` (at
least 128 bytes), like quinn.
Brings over quinn's two tests. `ordered_lossless_stream_is_not_rejected`
fails on `main` and passes here.
## API Changes
None.
## Notes & open questions
quinn-rs/quinn#2955 (contiguous data behind a single gap under sustained
loss) is still open upstream and isn't covered here. This touches
`defragment` like #867 (the fix for #865), so whichever lands second
needs a small rebase.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
Co-authored-by: Eanna Lyons <eanna@magic.dev>
Co-authored-by: Luke Curley <kixelated@gmail.com>
Co-authored-by: Floris Bruynooghe <flub@n0.computer>
## Description
Makes cargo-deny happy.
## API Changes
n/a
## Notes & open questions
Not bumping Cargo.toml as we didn't need any code changes. So we're
not using any of the dangerous APIs.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
## Description
Implements setting a stream's affinity to being sent on paths. See the
doc comment on `SendStream::set_affinity` for more information.
This is implemented via keeping multiple `PendingStreamsQueue`s instead
of just one: One queue for each possible affinity, except
`StreamAffinity::Block`, which doesn't need a queue.
On sending in each path, we first check the `any` queue, and then
compare it with pending streams that are pinned to our path.
Between these we compare which one is supposed to go first and use that.
When a stream changes affinity, we need to potentially move it between
queues.
If a stream goes from blocked to another affinity, we don't restore its
recency, instead, we give it a new one. This is as if the data the
stream had queued were submitted just when switching. This is to avoid a
situation in which someone suddenly unblocks a lot of small streams
after a long time of being blocked and these streams suddenly jumping
the queue and starving out other streams.
## API Changes
- Adds `noq_proto::StreamAffinity`
- Adds `noq_proto::SendStream::set_affinity`
## Notes & open questions
- Plan is to also add APIs for noq, but not in this PR
- This is stacked on top of #835 because that simplifies this
implementation.
- This somewhat conflicts with #859 but the conflicts are reconcilable.
- I'm using `PendingQueueMut` as an abstraction to ensure we don't
accidentally leave empty `PendingStreamsQueue`s around for sticky paths
that don't exist anymore.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
---------
Co-authored-by: Floris Bruynooghe <flub@n0.computer>
<!-- Attention agents and contributors using AI, please see our AI
policy before opening a PR:
https://github.com/n0-computer/noq/blob/main/AI_POLICY.md -->
<!-- Any PRs violating this policy will be closed. -->
<!-- As per our contributor guidelines, all PRs that do not link to an
issue with the label `ready-for-pr` will be closed:
https://github.com/n0-computer/noq/blob/main/CONTRIBUTING.md -->
## Description
Recent runner images got bumped from Ubuntu 24.04 to 26.04 and some of
the package layout changed. Bumping the dep makes sure things work
again.
## API Changes
<!-- Optional, any API additions, deprecations or breaking changes,
including how to migrate older code. -->
## Notes & open questions
<!-- Any notes, remarks or open questions you have to make about the PR.
-->
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
Co-authored-by: Floris Bruynooghe <flub@n0.computer>
## Description
feat rather than chore because of the minor version bump, even though
this isn't directly a feat itself.
## API Changes
n/a
## Notes & open questions
none
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
## Description
Always schedule equal-priority streams round-robin, removing
continuation handling before introducing stream affinity. Keep the
setter as a deprecated no-op for source compatibility.
## API Changes
- `noq::TransportConfig::send_fairness` is now deprecated.
## Notes & open questions
We might want to wait for #833 before we release with this PR, so we can
have an alternative to link to in deprecation documentation (the
`incremental=false` setting).
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
## Description
Updates webpki dependency versions in lockfile due to
`RUSTSEC-2026-0383` and `RUSTSEC-2026-0382`.
## API Changes
None.
## Notes & open questions
No changes to `Cargo.toml`, because they're only indirect dependencies.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
<!-- Attention agents and contributors using AI, please see our AI
policy before opening a PR:
https://github.com/n0-computer/noq/blob/main/AI_POLICY.md -->
<!-- Any PRs violating this policy will be closed. -->
<!-- As per our contributor guidelines, all PRs that do not link to an
issue with the label `ready-for-pr` will be closed:
https://github.com/n0-computer/noq/blob/main/CONTRIBUTING.md -->
## Description
Closes#840
A build without `std` needs `hashbrown` maps in place of the `std` ones,
including the `rustc-hash` and `identity-hash` maps, (`std` maps with a
different hasher). With the map types and `hash_map::Entry` named in one
place, as time already is, that becomes a change to `lib.rs` alone. The
`clippy.toml` keeps new code from going around it.
## API Changes
None
## Notes & open questions
<details>
<summary>Design notes</summary>
- Type aliases instead of the `use` re-exports from the issue: clippy
resolves a re-export to the original type, so it would flag every use.
- `hash_map::Entry` goes through an alias in a crate-root `hash_map`
module, so the existing `hash_map::Entry::Occupied` matches stay as they
are. Clippy catches a direct `use std::collections::hash_map::Entry`,
but not `use std::collections::hash_map;`, because it can't ban a module
import (rust-lang/rust-clippy#9489). A CI build without `std` will catch
that case.
</details>
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
## Description
A receive stream that is both stopped and reset gets its
connection-level flow control credit issued twice for unread data.
Both paths credit unread data without knowing whether the other already
did:
- `RecvStream::stop` credits `end - bytes_read`
- `StreamsState::received_reset` credits `final_size - bytes_read`
Example: 32 bytes received and unread, final size 64. Stopping credits
32, then the reset credits 64, so `local_max_data` grows by 96 instead
of 64. The same happens in the other order (reset, then stop). The peer
can then send more than the receive window allows before we'd consider
it a flow control violation.
The fix tracks, per stream, how much credit has already been issued for
data the application will never read (`Recv::unread_credit`).
`Recv::take_unread_credit` returns only what's still owed, so each byte
of the stream is credited once regardless of the order of stop, reset
and incoming frames. Reads still credit through `Chunks::finalize` as
before.
Two regression tests cover both orders: `stopped_reset_flow_control` and
`reset_stopped_flow_control`. Both fail on `main` (crediting 96 instead
of 64).
Found while working on RESET_STREAM_AT (#809), which builds on this.
## Breaking Changes
None.
## Change checklist
- [x] Self-review.
- [x] Tests if relevant.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Floris Bruynooghe <flub@n0.computer>
Closes#2739 via option 1.
Chunks now live in a `VecDeque` ordered by offset instead of a
`BinaryHeap`:
- `read` takes from the front
- an in-order frame appends to the back
- a frame below everything buffered pushes to the front; anything else
is placed by binary search
Two orderings are now explicit:
- a partial read can advance the front chunk past a neighbour it
overlaps
- `defragment` has to emit the accumulated chunk before a later
defragmented one
Tie order stays unspecified, as it was under the heap.
Measurements
- nanoseconds per frame
- 1200 byte frames
- best-of-N with N sized to at least 300ms per case
- median of five processes, or three for the bounded-read and 32 chunk
rows
- binaries interleaved
Note: the figures I posted in the issue were best-of-40 and too noisy to
use, so please ignore them.
| case | BinaryHeap | VecDeque |
| --- | --- | --- |
| in-order, 1 chunk buffered | 52.6 | 31.5 |
| in-order, 25 chunks buffered | 64.1 | 31.5 |
| in-order, 127 chunks buffered | 84.7 | 31.8 |
| in-order, 1000 chunks buffered | 108.4 | 31.9 |
| in-order, 127 buffered, 1024 byte reads | 106.6 | 55.8 |
| descending offsets | 36.1 | 18.8 |
| gapped inserts mid-range, 32 buffered | 37.1 | 68.9 |
| gapped inserts mid-range, 500 buffered | 38.5 | 187.2 |
| gapped inserts mid-range, 1500 buffered | 37.1 | 423.9 |
| one `defragment` call at 1900 chunks | 179 us | 39 us |
Summary
- about 19ns of each in-order row (in both columns) is `Bytes::clone`
plus the `Chunk` drop
- the heap slows down as the buffer deepens and the deque does not
- the bounded-read row exercises the partial-read path, where the new
code restores ordering by hand; it costs nothing measurable, since the
guard returns immediately on in-order data
The gapped rows are what it costs: the deque is already the slower of
the two by about 32 buffered chunks; `COMPACT_THRESHOLD` holds the
buffer to 2048 chunks of 56 bytes, so the shift should stay under ~57KB;
in unordered mode the dedup loop can do several of these inserts for one
frame, which I measured at parity with the heap.
`defragment` gets cheaper because its input is already ordered, so it no
longer sorts.
(cherry picked from commit ba18f6c12a)
RFC 9000 §12.4 Table 3 marks CONNECTION_CLOSE `ih01`, where `ih` means
"Only a CONNECTION_CLOSE frame of type 0x1c can appear in Initial or
Handshake packets", and §12.4 requires PROTOCOL_VIOLATION on receipt of
a frame in a packet type that is not permitted.
quinn applies this on the send path: `poll_transmit` rewrites an
application close into a 0x1c close with APPLICATION_ERROR for non-Data
spaces, per §10.2.3. The receive path does not.
Two changes, one per direction:
1. `process_early_payload` accepted both close types. Initial packets
are protected with keys derived from the cleartext original DCID, so
anyone observing the handshake can forge one and hand the application an
arbitrary application error code and reason phrase. Now only 0x1c is
accepted; 0x1d falls through to the existing "illegal frame type in
handshake" arm.
2. The 0-RTT filter rejected a 0x1d close. §12.5 lists the frames that
cannot appear in 0-RTT as ACK, CRYPTO, HANDSHAKE_DONE, NEW_TOKEN,
PATH_RESPONSE and RETIRE_CONNECTION_ID. CONNECTION_CLOSE is not in that
list, and §19.19 says 0x1d "can only be sent using 0-RTT or 1-RTT
packets". This turned a peer's clean application close into a transport
error.
Test: `application_close_in_initial_is_rejected` builds an
Initial-key-protected packet containing a 0x1d close and checks the
connection fails with PROTOCOL_VIOLATION rather than surfacing
`ApplicationClosed`. It fails before this change. There is no test for
the 0-RTT half because quinn never emits such a packet itself:
`poll_transmit` skips the Data space for a close unless 1-RTT keys
exist, so it cannot be reproduced quinn to quinn.
`cargo test -p quinn-proto` passes (294), `cargo test -p quinn` passes
(23), fmt and clippy are clean.
(cherry picked from commit d5d5b978c2)
The commit cherry-picked by the current one fixes a bug in quinn that we
had already solved in noq. The cherry-pick limits the brought changes to
adding the test.
Fixes#2785.
Calling `close()` while the congestion window is full never gets
CONNECTION_CLOSE onto
the wire. The gate in `poll_transmit` classifies the packet by the
stream frames still
pending in the space, but a closing connection will never send those —
the packet it
actually builds is just ACKs + CONNECTION_CLOSE. And once closed nothing
can reopen the
gate: incoming ACKs aren't processed anymore so in-flight bytes never
drain, and
`close_common()` stopped the loss timers so the `loss_probes` bypass
never fires. The
peer just sits there until its idle timeout.
We hit this cancelling a bulk sender mid-transfer — captures showed zero
close datagrams
leaving, every time the cancel landed on a saturated window.
Fix is to exempt close packets from the gate, same idea as the existing
tail-loss-probe
exemption on the line above: the close packet isn't congestion
controlled, and blocking
it can deadlock.
The new test saturates the window with unacked data, closes, and checks
the peer sees
the right close code/reason within a few PTOs instead of idle-timing
out. Fails on main,
passes with the change.
(cherry picked from commit e556fde4b5)
Expose the bandwidth estimate from the congestion controller.
With Reno/CUBIC we can compute this from window / RTT, but for BBR we
need the actual estimate from the CC algorithm.
(cherry picked from commit 766cca4822)
Fixes#2791.
`BlackHoleDetector::on_non_probe_acked` returned early for any packet no
larger than `acked_mtu`, so once a full-size packet had been
acknowledged, `largest_post_loss_packet` never advanced again as long as
every packet was full-size — the steady state of a bulk transfer.
Because `on_ack_received` registers acknowledgments before running loss
detection, one ACK that confirms newer full-size packets and reveals ≥
`BLACK_HOLE_THRESHOLD + 1` older non-adjacent holes then judged all of
those holes suspicious, even though the same ACK had just shown that
full-size packets still get through. On a lossy path this turns ordinary
congestion loss during a download into a black hole verdict and a drop
to `min_mtu` (details and production numbers in #2791).
The change: when `len == acked_mtu`, keep `acked_mtu` but advance
`largest_post_loss_packet` to the newer packet number, so loss bursts
that precede that delivery are non-suspicious under the existing rule
while losses transmitted after the last delivery remain suspicious. This
matches the design in #1855 ("larger than any more recently acknowledged
packet").
The new unit test fails on `main` before the change and passes after;
the existing black hole tests, including
`blackhole_after_mtu_change_repairs_itself`, still pass.
On 0.11.x this fix alone is not sufficient because `finish_loss_burst`
there still uses strict `<` (fixed on `main` by #2400 but not
backported); I have a branch with #2400's two commits cherry-picked plus
this one, all tests green
(https://github.com/vcarus/quinn/tree/bhd-0.11.x), if you'd like a
backport PR.
Co-authored-by: vcarus <8207711+vcarus@users.noreply.github.com>
(cherry picked from commit b0afb6e6fb)
Extract Retransmits::retire_cids, bounding pending_retired regardless of
which branch queues a retirement. The Ok(Some(..)) branch already enforced
MAX_PENDING_RETIRED_CIDS; the Err(InsertError::Retired) branch pushed
directly onto retire_cids, bypassing the cap entirely. Route both call sites
through the shared, bounded method instead of duplicating the check.
The `TooManyChunks` cap was only checked inside the over-allocation
branch of `Assembler::insert`, and only for the tail push. A peer
sending many small gapped STREAM frames can keep over-allocation below
the defragmentation threshold while the chunk count grows to the stream
flow-control limit, and frames handled entirely by the unordered dedup
loop return before the check runs. Either way the buffered chunk count
is unbounded, which is the memory-exhaustion class the original advisory
addressed.
Check the chunk count after every push, including the unordered dedup
loop, and compact once it passes a watermark above the cap so that a
flood of mergeable (duplicate or contiguous) frames cannot force a
defragmentation on every frame. A stream is rejected once compaction
cannot bring the distinct span count back to the cap. Buffered chunks
are bounded at O(twice the cap); the count is re-checked after every
insert, though a single unordered frame may transiently push a few
chunks past the watermark before that check.
(cherry picked from commit 4b88c9403a)
The locally-created-CID index (`connection_ids`) mapped directly to
`ConnectionHandle`, while the initial-DCID index already used
`RouteDatagramTo`. Store `RouteDatagramTo` in `connection_ids` too:
`new_cid` takes the route to register, and `ConnectionIndex::get`
returns it without re-wrapping.
No behavior change (every route is still `RouteDatagramTo::Connection`);
this is what later lets a locally-created CID point at an in-flight
`Incoming`.
(cherry picked from commit 97a5386e06)
`Connection::new` only queried `cid_len()` and `cid_lifetime()` on the
generator; it never minted a CID. Take the two values directly.
(cherry picked from commit c9008d05a9)
The `send` API handles IO errors by logging them. This is an error
handling policy that can just as easily be implemented by consumers as
well.
More importantly, upcoming features like the support for partial sends
conflicts with this API because we cannot return a truthful `Ok(())`
value when silencing an error.
To preserve the original behaviour of logging non-fatal IO errors, quinn
itself is transitioned to rate-limit the logging of errors inside each
`UdpSenderHelper`. This is a slight change in behaviour. Previously, the
errors were rate-limited per socket whereas now the errors are
rate-limited per `UdpSenderHelper`. Several of those share a single
socket.
(cherry picked from commit 148d760d88)
A native cmsg buffer is only guaranteed to be aligned for the control
message header. On musl that header is less strictly aligned than some
payloads (e.g. `libc::timespec`), so decoding through an aligned
`ptr::read` is unsound; read it unaligned instead.
(cherry picked from commit d9919a18a3)
Explain at the copy site why datagrams are copied into a reusable BytesMut
rather than read directly into it: recv_buf is allocate-once scratch, while
the BytesMut is handed out to connections and cannot be reused across polls
once a slice is still in flight.
(cherry picked from commit 5c9ffd5c25)
RecvState::poll_socket copied every received datagram into its own freshly
allocated BytesMut. Instead, copy the batch into a single reusable buffer and
split each datagram off as an owned slice that shares that allocation. reserve
reclaims the buffer once the previous batch's slices have been dropped, so it
only reallocates while datagrams are still in flight. The rest of the receive
path stays zero-copy.
Measured with dhat on a 200 MiB loopback bulk transfer, the receive-path
allocations drop from ~38.6k blocks to ~6.7k. Loopback throughput is unchanged
within noise, since it is bound by crypto/CPU rather than allocation there.
(cherry picked from commit 8cef96c999)
We're currently not handling ICMPv4 Fragmentation Needed and ICMPv6
Packet Too Big (PTB) messages since they cannot be authenticated, and
Datagram Packetization Layer Path MTU Discovery (DPLPMTUD) works without
it anyways.
A dedicated check for this type became necessary due to a recent change
in how internal errors originating from recvmsg are exposed to the
caller as errors (rather than letting the runtime silently retry the
read).
Fixes#2733.
(cherry picked from commit 2d78048fc8)
Non-blocking sendmsg/sendmsg_x on Apple platforms can permanently return with EWOULDBLOCK when a datagram plus its cmsg lands just under `SO_SNDBUF`. Enforce a safe `SO_SNDBUF` floor on socket creation and resize.
See https://feedbackassistant.apple.com/feedback/23671230
(cherry picked from commit 3d59275b29)
`AsyncUdpSocket::poll_recv` discarded every error the socket returned and
re-polled. On the tokio runtime that is a busy loop: `try_io` clears readiness
only for `WouldBlock`, so any other error leaves readiness asserted,
`poll_recv_ready` completes at once, and the recv fails again — a synchronous
loop inside a single poll, with no yield point. Seen on iOS as ~1.07M
`recvmsg`/s all returning `ENOTCONN` after the bound interface went away,
pegging a core and starving every other task on a current-thread runtime.
It also left `RecvState::poll_socket`'s error handling unreachable for both
bundled runtimes: neither the `ConnectionReset => continue` retry nor the
`Err(e) => return Err(e)` teardown — present since 71927fb8 — can ever run,
because `poll_recv` never yields `Ready(Err(_))`.
Return the error instead, in the tokio and smol sockets alike, and let
`poll_socket` decide what is fatal.
(cherry picked from commit 57ea8a5124)
The GSO-disable path just above already treats EIO like EINVAL, but the
cmsg fallback (sendmsg_einval, which stops setting the ECN IP_TOS cmsg)
only triggered on EINVAL. Some Android kernels return EIO for the ECN
cmsg, so the fallback never ran and every sendmsg kept failing.
(cherry picked from commit 89837617fe)
## Description
Updates the rustls min version to 0.23.46 due to some vulnerability
reports.
## API Changes
APIs including rustls types now need rustls 0.23.46 or older.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.
<!-- Attention agents and contributors using AI, please see our AI
policy before opening a PR:
https://github.com/n0-computer/noq/blob/main/AI_POLICY.md -->
<!-- Any PRs violating this policy will be closed. -->
<!-- As per our contributor guidelines, all PRs that do not link to an
issue with the label `ready-for-pr` will be closed:
https://github.com/n0-computer/noq/blob/main/CONTRIBUTING.md -->
## Description
Closes#820
`noq-proto` is sans-io, which makes it a candidate for targets without
`std`. Most of what it takes from `std` is re-exported from `core` or
`alloc`. Taking those items directly shrinks what a `no_std` build would
have to change. The lints plus the `core` prelude keep those `std` paths
from creeping back in.
`std` remains for the following imports: `Instant`, `SystemTime`,
`HashMap`, `HashSet`, `Mutex`, `io`, `path`.
The three clippy lints from the issue are added as warnings in `lib.rs`.
CI will catch new `std` paths.
The `std` prelude and macros would not fire the lints, because the lints
only check explicitly written paths. Adding `#![no_std]` to `lib.rs`
swaps in the `core` prelude and macros. `extern crate std` keeps `std`
linked without its prelude or macros, so items like `Box`, `Vec`, and
`vec!` need an import by path, which the lints can check. This is the
same pattern that `rustls` uses.
## API Changes
None
## Notes & open questions
N/A
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.