Skip to content

fix(caller): a slow unrelated name holds a ready tailnet candidate back for the LAN head start only - #64

Merged
TheAnimatrix merged 2 commits into
mainfrom
tailnet-dns-grace
Dec 1, 2026
Merged

TheAnimatrix merged 2 commits into
mainfrom
tailnet-dns-grace

Conversation

@TheAnimatrix

@TheAnimatrix TheAnimatrix commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

A ready numeric tailnet candidate no longer waits for the lookup of an unrelated hostname to finish. A name that is still resolving may turn out to be LAN, so it still holds the numeric tailnet candidate back, but only for the existing LAN_HEAD_START_MS (1000 ms by default). No new limit was added.

Only numeric tailnet candidates start early. A name that resolved to a tailnet address may also hold public addresses (the dial tries every target), so it waits for the other names to resolve, as before.

What stays the same:

  • A name that resolves to the LAN within the head start still goes first; the tailnet candidate is never dialled in that case.
  • With no name to resolve, scheduling is unchanged: the tailnet starts at once, or after the head start when a LAN candidate is known. It starts early once every LAN candidate failed, and a browse still running never holds it back.
  • Resolved names on the tailnet, and public, tunnel and SSH candidates, still wait until every name is resolved.
  • Queue order, candidate caps, policy, pinned and verified refusals, and closing the losing tries are unchanged.

docs/limits.md and docs/phase1b-design.md describe the new bound.

Result

Real loopback TLS to a paired host, with the numeric route labelled tailnet. An unrelated hostname is added whose lookup takes 1700 ms. Windows, 3 runs each:

numeric only numeric + 1700 ms lookup
main (b757d23) 37 / 61 / 42 ms 1774 / 1750 / 1770 ms
this branch (901b4ee) 28 / 31 / 35 ms 1029 / 1031 / 1035 ms

The remaining ~1000 ms is the LAN head start, kept on purpose. The measurement harness is not part of this PR.

Tests

Three new tests in crates/mousse-helper/tests/app_routes.rs:

  • a_slow_name_holds_the_tailnet_back_for_the_lan_head_start_only: with a 60 s lookup, the numeric tailnet wins after at least the 1 s head start and in under 5 s. It fails on main: the search waits for the lookup.
  • a_name_resolved_to_the_lan_within_the_head_start_beats_the_tailnet: a name that resolves to a LAN address after 300 ms wins, and the tailnet relay is never dialled.
  • a_name_resolved_to_the_tailnet_waits_for_the_other_names: one name resolves at once to a tailnet address that refuses and then a public address that answers, while another name never resolves and gives up after 3 s. The public address is not dialled before 3 s. It fails against 010448b, the first version of this PR.

Verification

Head 901b4ee, on main a15048a. Local checks on Windows:

  • cargo fmt --all --check passes.
  • cargo test -p mousse-helper --test app_routes: 52 of 52 pass.
  • cargo test -p mousse-net-io: all pass.
  • cargo clippy -p mousse-helper --test app_routes --all-features -- -D warnings passes.
  • cargo clippy -p mousse-net-io --all-targets --all-features -- -D warnings stops on Windows at missing_const_for_thread_local in crates/mousse-net-io/src/keystore.rs:1624. That initializer is already const, current main shows the same error, and this PR does not touch that file.

On the first version (010448b), also on Windows:

  • cargo check -p mousse-net-core --target wasm32-unknown-unknown passes.
  • cargo test --workspace: everything else passes, apart from two Windows test failures that are not in this code and that pass on rerun:
    • app_routes::an_inbound_connection_takes_the_class_of_the_port_it_arrived_on failed with peers.json: Access is denied (os error 5).
    • app_invite_way::a_failed_selection_leaves_no_invitation_code_or_slot failed because of an extra relay.state event.
    • A rerun of both suites passes: 51 of 51 and 20 of 20.
  • cargo clippy --workspace --all-targets --all-features -- -D warnings stops at the same missing_const_for_thread_local lint, in crates/mousse-helper/src/app/out.rs:53; that initializer is also already const.

…ack for the LAN head start only

A hostname being resolved may turn out to be LAN, so the tailnet waits for
it, but now only for LAN_HEAD_START_MS. Before, a slow lookup of an
unrelated name held a ready numeric tailnet candidate back until the
lookup ended. Public, tunnel and SSH still wait for every name, and a name
that resolves to the LAN within the head start still keeps the LAN first.
…is resolved

A name resolved to the tailnet may also hold public addresses, so it waits for the other names like public, tunnel and ssh candidates.
@TheAnimatrix
TheAnimatrix merged commit 7ea2937 into main Dec 1, 2026
1 check passed
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.

1 participant