Preserve mesh transport through an internet exit in 1.0.3-rc1
On macOS a connected socket using the physical source lost its route before PF could see the packet. Fresh sockets could leave via the physical uplink, but Darwin rejected reverse-NAT replies delivered to a utun address there. With two live meshes remote control and data sessions expired within a minute. Install matching interface-scoped uplink routes before capturing the two unscoped defaults. Keep PF state on the physical interface, preserve transport ports and return tagged replies via loopback. Reconcile uplink changes and recover only owned routes using a private journal and kernel markers. On Windows keep existing LAN routes, retain recent verified reconnect paths and refresh the gateway and relay DNS without replacing the split defaults. Exercise two memberships of the same peer, new and established native transport sockets, ordinary application traffic and scoped route cleanup. Run hosted macOS and Windows native regressions on affected changes. Bump the packages to 1.0.3-rc1 and encode Debian prereleases with a tilde so apt can upgrade to the final release. Mesh wire formats and identities are unchanged. Checked workspace formatting, strict Clippy and the full workspace suite on macOS (586 passed, four opt-in tests skipped by default). The privileged macOS kernel test passed separately. A launchd trial of the RC kept master and ch reachable over both meshes and used the external exit past the original timeout. Disabling the exit restored the physical IP and cleared the routes. Linux ARM64 passed four real-agent exit tests and the privileged netns regression. The RC APK passed the dual-subnet UDP/ICMP test on an Android 37 ARM64 emulator. Verified Debian and pacman version ordering. Native Windows execution is covered by the hosted workflow and was not run on this Mac.
This commit is contained in:
1 parent
32aa73721a
commit
a189d0ad3e
28 files changed
+1698
-185
No files matched your search
+23
-13
@@ -101,14 +101,20 @@ is built from `pf` and `route`. The agent runs as root there.
|
||||
macOS forgets at reboot. The egress is the default route's interface **at the
|
||||
time the rules are applied**; after it changes (Wi-Fi to Ethernet) switch the
|
||||
offer off and on.
|
||||
- **Using:** `0.0.0.0/1` and `128.0.0.0/1` routes through the overlay interface
|
||||
with the local address of the exit network as their source,
|
||||
and a `pf` `route-to` rule that sends the agent's own traffic (matched by its
|
||||
user id, root) back out the physical interface, with translation to that
|
||||
interface's address. Anything else you run as root also bypasses the tunnel.
|
||||
IPv6 is blocked with rejecting `::/1` and `8000::/1` routes.
|
||||
- Not verified on a live host when this was written: run `tsng exit-node` and
|
||||
check `sudo pfctl -a com.apple/tsunagi-exit-utunN -s rules -s nat`.
|
||||
- When **using** an exit, ordinary IPv4 internet connections take the two
|
||||
split-default routes through the utun, with the local address of the selected
|
||||
network. More specific routes continue to reach their own networks.
|
||||
- Sockets already using the physical address need matching routes scoped to
|
||||
the uplink. Without them, macOS can reject a send before the packet reaches
|
||||
PF. For new TCP and UDP sockets, PF sends the agent's traffic out the uplink
|
||||
and preserves its source port. Replies to these tagged connections return
|
||||
through loopback after reverse NAT so macOS can deliver them to a socket
|
||||
whose local address belongs to the utun. This exemption matches the
|
||||
daemon's user ID, so it also applies to other processes running as root.
|
||||
IPv6 internet traffic is blocked with rejecting `::/1` and `8000::/1` routes.
|
||||
- To inspect an active exit, run `tsng exit-node` and
|
||||
`sudo pfctl -a com.apple/tsunagi-exit-utunN -vvsr`, using the daemon's utun
|
||||
number. The physical interface and the utun should both see transport packets.
|
||||
|
||||
## Windows
|
||||
|
||||
@@ -123,11 +129,15 @@ is built from `pf` and `route`. The agent runs as root there.
|
||||
off the tunnel *by destination*. `0.0.0.0/1` and `128.0.0.0/1` go through the
|
||||
overlay interface; a `/32` route with metric 7373 (the marker for "ours")
|
||||
through the physical default gateway is added for every address the agent
|
||||
talks to directly: verified direct paths of its connections, plus the relays
|
||||
it uses, resolved when the rules are applied. The set follows path changes. A
|
||||
newly authenticated connection supplies its direct paths immediately and the
|
||||
discovery tick refreshes them. Physical bypass routes exclude every active
|
||||
mesh subnet. Wintun can choose any local alias for the default route. For
|
||||
talks to directly, including verified connection paths and current relay
|
||||
servers. Existing LAN and other more specific routes keep their next hop.
|
||||
A newly authenticated connection supplies its direct paths immediately.
|
||||
After a disconnect, the agent keeps its last verified paths for up to two
|
||||
minutes to allow reconnection. It checks the physical gateway and relay
|
||||
DNS every 30 seconds while the exit is active. Recent DNS answers remain
|
||||
usable for up to two minutes after rotation or a failed lookup.
|
||||
Physical bypass routes exclude every active mesh subnet. Wintun can choose
|
||||
any local alias for the default route. For
|
||||
TCP, UDP and ICMP echo, the agent uses the exit network's address on the
|
||||
tunnel and restores replies to the address the Windows socket used.
|
||||
IPv6 is blackholed with `::/1` and `8000::/1` on the overlay interface,
|
||||
|
||||
Reference in new issue
Block a user