Skip to content

Fix the OpenBSD UDP send stall behind the routing-table smoke test failure - #7

Merged
losfair merged 10 commits into
mainfrom
claude/wizardly-galileo-wtuew9
Oct 15, 2026
Merged

losfair merged 10 commits into
mainfrom
claude/wizardly-galileo-wtuew9

Conversation

@losfair

@losfair losfair commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

run on OpenBSD (aarch64-unknown-openbsd, emulated) has failed at the routing-table (rtable) check since #5. The cause is neither routing tables nor arm64. On OpenBSD, noq's tokio UDP sender could stall for good, after which the server stopped sending on every connection.

Root cause

The full analysis is in losfair/noq#4 (merged).

  1. EAGAIN without a full buffer. A non-blocking UDP sendmsg on OpenBSD fails with EAGAIN whenever another thread is in sosend on the same socket. Under MSG_DONTWAIT, sosend doesn't sleep for the send-buffer lock.
  2. The sender never wakes. noq's tokio sender cleared the socket's write readiness on that error, then waited for a kqueue write event that a UDP socket never raises again.
  3. One stalled socket, every connection. All connections share the server's socket, so the server stopped sending entirely. It kept receiving, and its connections timed out.

The smoke test's routing-table check was simply the first place that ran a multipath client long enough to hit the race. Emulated arm64 timing hit it most often.

Evidence (OpenBSD VMs, this PR's diagnostic runs)

  • The race itself: the server's kdump shows two concurrent sendmsg(10, …) calls. One returns errno 35 while the other completes. After that the server makes no more sendmsg calls.
  • The stall: packet captures show the server going silent on all connections at once, while a new client's Initials still reach its socket. With the stall in place, a 2 s trace of the server shows recvmsg and no sendmsg.
  • Ruled out: loopback UDP itself and pf. Disabling pf changed nothing.
  • Reproduction: back-to-back multipath rounds reproduced the stall in all 8 OpenBSD jobs without the fix, by round 2–3. With the fix (83433a2), both architectures passed 6 rounds.

Changes

  • noq pinned to the fix: noq and noq-proto are pinned to cad1d3a on dev, the merged fix(noq): don't stall tokio UDP sends on OpenBSD send lock contention noq#4. It changes noq's tokio runtime only, on OpenBSD only.
  • Smoke test (.github/scripts/smoke-test.sh):
    • The routing-table path must now also receive on its own socket, read from the client's /stats. Before, a path reported "up" was enough, and it can be reported up without ever receiving.
    • An extra path without a routing table is checked too.
    • Three back-to-back rounds of both: a client starts and exits right after the previous one, which is what reproduced the stall.
    • On failure it shows both sides' stats, process state, 2 s of syscalls (ktrace) and the UDP sockets.
  • AGENTS.md: a note on the stall.

Testing

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test (58 tests) pass with the new pin.
  • The smoke test passes locally on Linux, where the OpenBSD part is skipped.
  • On 83433a2, all CI jobs passed, including both OpenBSD jobs (6 rounds each). That commit pinned the PR head, which is identical to the merged commit.

🤖 Generated with Claude Code

https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz

…rtable

Dump the client's process state, both sides' stats endpoints, two seconds
of the client's syscalls (ktrace) and the UDP sockets when a check fails,
give the rtable path-up client its own log, and check a plain extra
multipath path before the routing-table one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz
Run the routing-table checks against a second server with noq's trace
log, trace the client too, and capture the proxy port on lo0 and the
egress interface, plus the UDP counters, all shown when a check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz
The path-up wait now also requires datagrams received on the path (from
the client's stats), since the path can be reported up while its socket
never receives. Run it against the shared server again (a fresh server
did not reproduce the failure), with syscall traces of both processes
instead of noq trace logs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz
Start the routing-table client straight after the previous client exits,
with nothing attached, three times; trace the server and client only
once a round has failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz
A failed round showed a fresh client's handshake packets never reaching
lo0 after the previous routing-table client exited. Probe plain UDP over
loopback, dump pf rules, states and counters and the interface and IP
drop counters, then disable pf and probe again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz
In the failing rounds the server reads a fresh client's Initial packets
but never answers. Log the server at debug level (handshake errors) and
trace both processes' syscalls, with their CPU use, when a check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz
The failing rounds show the server going silent on every connection at
once. Trace its syscalls from the first round on and show the first
failing sendmsg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz
OpenBSD fails a non-blocking UDP send with EAGAIN when another thread
holds the socket's send buffer lock; noq's tokio sender then cleared
write readiness and waited for a kqueue event that never comes, so the
server went silent on every connection. Pin the fix branch and run six
routing-table rounds, without tracing the server throughout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz
Keep what the investigation showed is worth checking: the routing-table
path must also receive on its own socket (not just be reported up), and
back-to-back multipath rounds, which reproduced the server's stall every
time before the noq fix. On failure show both sides' stats, process
state, two seconds of syscalls and the UDP sockets; drop the always-on
packet captures, pf probing and debug server log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz
@losfair losfair changed the title Fix the OpenBSD arm64 routing-table smoke test failure Fix the OpenBSD UDP send stall behind the routing-table smoke test failure Oct 15, 2026
@losfair
losfair marked this pull request as ready for review October 15, 2026 18:05
losfair/noq#4 merged as cad1d3a on dev (same tree as the PR head
2f590c1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012baC35vUbLPPhuK4pz4uRz
@losfair
losfair merged commit c56e742 into main Oct 15, 2026
11 checks passed
@losfair
losfair deleted the claude/wizardly-galileo-wtuew9 branch October 15, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants