Keep concurrent overlays working and select faster data carriers

A second subnet on macOS could send with the first utun alias. Reconcile and verify each owned subnet route with its actual source, retry partially applied plans and expose host errors to clients. On Windows verify the alias and prefix on the intended adapter. Do not restart underlay sockets when the only network change is a local overlay address.

Compare mutually enabled carriers using authenticated data probes while the incumbent carries traffic. The dialler coordinates a generation-scoped decision after a sustained median RTT improvement. Old peers retain ordered fallback. Local IPC moves to v24 to report data RTT and the physical path independently of control RTT. The mesh wire versions, keys and saved network settings stay compatible.

Validated formatting, workspace Clippy and the workspace test suite on macOS, including bidirectional dual-network traffic and a live TLS-to-QUIC switch on loopback. Added focused native CI tests for macOS and Windows. The elevated utun test requires administrative access unavailable on the development host.
This commit is contained in:
Aleksandr Bogomiakov committed 2026-11-24 23:55:55 +02:00
1 parent 8d107cf0e9
commit 27e29cf8a7
34 files changed
+1569 -253

No files matched your search

+3 -2
View File
@@ -120,9 +120,10 @@ carrier change. Status and the tray show the actual external transport or relay
route and data readiness. There is no user-selectable internal cipher.
The internal capability is `wireguard-e2e` v4; external `wg` and `awg` use v2,
`wg-quic` v1 and `tcp-tls` v2. All members must upgrade together. Control ALPN
`wg-quic` v1 and `tcp-tls` v2, as in 1.0.1. Control ALPN
`tsunagi/ctrl/8`, discovery, membership and signed state are unchanged. The data
ALPN is `tsunagi/data/6`; the relay envelope format is unchanged. Local IPC is v23,
ALPN is `tsunagi/data/6`; the relay envelope format is unchanged. Automatic
carrier comparisons are optional on the mesh wire. Local IPC is v24,
so agent, CLI and tray must match. Historical `wg-quic/wireguard.sqlite` is the
canonical internal key store. Missing keys are imported transactionally from
`wg` then `awg`, without replacing an existing canonical key or modifying a
+9
View File
@@ -162,6 +162,15 @@ channel is declined, which is an ordinary outcome rather than an error.
Only one side dials — the one with the smaller endpoint id — so two agents
never open two channels for the same thing.
The optional `link-choice` v1 capability lets this dialler compare a second
mutually enabled carrier. An authenticated `Transport` message named
`link-choice` contains two 16-byte identifiers from the private link-health
profiles, in keep/retire order. The responder selects the surviving carrier
and echoes the decision. The dialler keeps accepting traffic on the former
carrier until confirmation or closure. Choices apply to one peer and network
and expire with the link generations. Peers without the capability use the
original carrier negotiation.
Packets ride as QUIC **datagrams**: unreliable and unordered, which is what a
tunnelled protocol wants, and free of the head-of-line blocking a stream would
add. `max_datagram` negotiates the reassembled payload limit (at most 65536
+22 -5
View File
@@ -18,9 +18,11 @@ Each authenticated control session advertises that peer's own direct data
links. There is one table for each network, whatever protocols run over it: a
link is a way to reach a neighbour, while the single internal protocol is an
end-to-end tunnel to a peer. The envelope names the protocol, so the two are independent. A neighbour
reached over several kinds of transport (UDP, TCP, QUIC datagrams) is sent to
over the best open one, in the order the protocols were configured, and over
the next if that one fails or cannot carry the frame. Every authenticated
reached over several kinds of transport (UDP, TCP, QUIC datagrams) receives
traffic over the selected link. Another open link can carry the frame if
the selected link fails or its MTU is too small. The configured order
selects the initial link. Peers with automatic carrier selection can then
prefer a faster measured link for that neighbour. Every authenticated
member enters the graph; a member in the middle needs no protocol in common
with either end, only a link to each. A snapshot refreshes on the maintenance
interval, expires after 90 seconds, and is withdrawn when the session ends.
@@ -33,7 +35,7 @@ capability and independent of the selected external protocols. The tunnel is
created when a member and its key are known; its logical link survives temporary
loss of all physical paths. Carrier selection changes, automatic fallback and
shorter routes keep the same keys, interface and counters. The lower endpoint
id still chooses the mutually enabled external carrier in its preference order.
id chooses among the mutually enabled external carriers.
A relayed AWG first hop can lead to a QUIC next hop: the user's choice governs
this device's adjacent links, while the inner ciphertext stays unchanged.
An existing TCP connection continues after transient loss if its own timeout
@@ -100,6 +102,20 @@ Logical peer links and end-to-end encryption state survive these changes.
## Carrier health and switching
Two peers advertising `link-choice` v1 automatically compare carriers. The
lower endpoint id opens one alternative while the established carrier keeps
serving traffic. At most two comparisons start concurrently per network. Each
peer pair rotates through its alternatives, with a two-minute interval after
a trial. A failed active link still triggers immediate fallback.
The measurements use authenticated round trips over the data carrier. After
at least six seconds and five successful probes on each link, the alternative
must have zero observed loss in its window and a median RTT improvement of
at least 20% and 5 ms. Otherwise traffic stays on the incumbent. The agents
coordinate retirement over their authenticated control session. An older peer
continues using the configured order and failure recovery. One enabled carrier
restricts the pair to that carrier.
Carrier setup failures and persistent encrypted delivery loss advance the
initiator's ordered fallback cycle. Logical end-to-end links survive while
physical links are retired explicitly. The AWG carrier negotiates a fresh
@@ -127,4 +143,5 @@ end-to-end network latency or VPN throughput; encryption, fragmentation,
sockets, congestion and scheduling contribute separately.
Wire compatibility: control ALPN `tsunagi/ctrl/8`, data ALPN `tsunagi/data/6`.
Upgrade every participant together; saved identities and network state persist.
Version 1.0.2 interoperates with 1.0.1 peers using these wire versions.
Saved identities and network state persist.
+6 -2
View File
@@ -50,7 +50,8 @@ boringtun, with an in-memory TUN device so none of it needs privileges. It
covers real IPv6 packets travelling both ways through a tunnel, a three-agent
mesh, a peer that sends from an address it does not own being dropped, packets
for unowned addresses being counted rather than broadcast, a departing peer
losing its tunnel, two networks keeping separate interfaces and keys, restart
losing its tunnel, two networks exchanging traffic in both directions over one
shared interface with separate addresses and keys, restart
keeping the WireGuard identity, shutdown removing every interface, a forged
overlay claim being rejected, and the core carrying the payload without
interpreting it.
@@ -257,7 +258,10 @@ histories. These are headless egui checks, not native desktop screenshots.
`tsunagi-wg-quic/tests/carriers.rs` uses the same internal WireGuard plugin over
real ordinary WG UDP and TCP/TLS, with loopback address selection and memory
TUNs. Exact original IP byte/packet counts exclude health probes and encryption
overhead. The AWG suite connects AWG-only and QUIC-only endpoints through a
overhead. An artificial delay on a real TCP/TLS link exercises automatic
selection of a faster QUIC carrier. Both endpoints exchange packets across the
transition and retain their original encrypted tunnels. The AWG suite connects
AWG-only and QUIC-only endpoints through a
mixed relay. One real smoltcp TCP connection stays established through relay →
direct QUIC → a dropped packet with all local carriers off → AWG relay; both
middle TUNs and endpoint keys are checked. This exercises a real userspace TCP