feat(client): scope TAP interface MTU while running

The Windows client now sets the TAP IP-interface MTU to the relay-selected MTU
before it starts bridging frames. The override is scoped like the existing
metric and default-route guards, so the previous MTU is restored when the
client exits.

The route crate now exposes `InterfaceMtuSnapshot` and `ScopedInterfaceMtu`
around `MIB_IPINTERFACE_ROW.NlMtu`, reusing the same `GetIpInterfaceEntry` and
`SetIpInterfaceEntry` path already used for metrics and default-route policy.
IPv4 MTU setup is required for startup, while IPv6 MTU setup is best-effort to
match the existing IPv6 route-protection behavior.

This intentionally leaves TAP MAC configuration as fail-fast. TAP-Windows6 does
not expose a matching set-MAC IOCTL in the driver header, so that should remain
a separate design decision.

Test Plan:
- cargo fmt --check
- cargo test -p lanparty-client-route
- cargo test -p lanparty-client-win
- cargo clippy -p lanparty-client-route -p lanparty-client-win --all-targets
  -- -D warnings
- cargo check -p lanparty-client-route --target x86_64-pc-windows-gnu
- cargo test --workspace
- cargo clippy --workspace --all-targets -- -D warnings
- git diff --check
- cargo check -p lanparty-client-win --target x86_64-pc-windows-gnu
  (fails before this crate in ring: missing x86_64-w64-mingw32-gcc)

Refs: PLAN.md
This commit is contained in:
2026-05-21 20:00:58 +02:00
parent 0299190c42
commit 3e2648abc1
4 changed files with 212 additions and 46 deletions
+8 -7
View File
@@ -56,6 +56,7 @@ Windows route-table boundary:
- read-only best-route lookup for a relay destination IP
- selected source address, next hop, interface index/LUID, prefix, and metric
- interface index/LUID lookup from Windows network adapter GUIDs
- scoped IP interface MTU overrides with restore-on-drop behavior
- scoped IP interface metric overrides with restore-on-drop behavior
- scoped default-route suppression with restore-on-drop behavior
- scoped host-route pinning for the relay IP on the pre-TAP interface
@@ -141,10 +142,10 @@ verifies that the relay route still uses that pinned host route after TAP
activation, and then bridges Ethernet frames between the relay and the first
TAP-Windows6 adapter until shutdown.
`--virtual-mac` can still override the stored identity for manual testing. On
Windows it marks the TAP media connected and reports the driver MAC/MTU before
forwarding frames, along with the TAP interface index/LUID. The client applies
a scoped TAP interface metric and disables TAP default routes while it runs,
periodically rechecks that the relay route remains pinned, then restores the
previous route policy on exit. Until automatic TAP MAC/MTU configuration is
wired, startup fails before bridging if the driver-reported MAC or MTU does not
match the tunnel settings.
Windows it sets the TAP IP interface MTU to the relay-selected MTU, marks the
TAP media connected, and reports the driver MAC/MTU before forwarding frames,
along with the TAP interface index/LUID. The client applies a scoped TAP
interface metric and disables TAP default routes while it runs, periodically
rechecks that the relay route remains pinned, then restores the previous route
policy on exit. Until automatic TAP MAC configuration is wired, startup fails
before bridging if the driver-reported MAC does not match the tunnel identity.