Skip to content

libtailscale: force TUN update when underlying network interface changes - #892

Open
foxploit wants to merge 1 commit into
tailscale:mainfrom
foxploit:fix/underlying-network-interface-change
Open

foxploit wants to merge 1 commit into
tailscale:mainfrom
foxploit:fix/underlying-network-interface-change

Conversation

@foxploit

@foxploit foxploit commented Oct 8, 2026

Copy link
Copy Markdown

Fixes issue where VPN tunnel wouldn't recreate when default network changed (e.g. cellular → Wi-Fi) but DNS/routes remained identical.

The isConfigNonNilAndDifferent() check only compared router.Config and dns.OSConfig, missing interface changes. This caused traffic to keep routing through the old underlying interface (UnderlyingNetworks: Null).

Changes:

  • Track lastUnderlyingIface/appliedUnderlyingIface in backend with mutex
  • Update NetworkChanged() to record new interface
  • Check interface change in isConfigNonNilAndDifferent()
  • Record applied interface after successful updateTUN()
  • Reset on CloseTUNs()
  • Add unit test for interface change detection

Tested with log showing updateTUN executing on cellular→Wi-Fi transition instead of 'isConfigNonNilAndDifferent: no change to Routes or DNS, ignore'.

@foxploit
foxploit force-pushed the fix/underlying-network-interface-change branch from 3292ca2 to db84543 Compare October 8, 2026 18:57
Fixes issue where VPN tunnel wouldn't recreate when default network
changed (e.g. cellular → Wi-Fi) but DNS/routes remained identical.

The isConfigNonNilAndDifferent() check only compared router.Config and
dns.OSConfig, missing interface changes. This caused traffic to keep
routing through the old underlying interface (UnderlyingNetworks: Null).

Changes:
- Track lastUnderlyingIface/appliedUnderlyingIface in backend with mutex
- Update NetworkChanged() to record new interface
- Check interface change in isConfigNonNilAndDifferent()
- Record applied interface after successful updateTUN()
- Reset on CloseTUNs()
- Add unit test for interface change detection

Tested with log showing updateTUN executing on cellular→Wi-Fi transition
instead of 'isConfigNonNilAndDifferent: no change to Routes or DNS, ignore'.

Signed-off-by: foxploit <105010191+x0n3e@users.noreply.github.com>
@foxploit
foxploit force-pushed the fix/underlying-network-interface-change branch from db84543 to 8aafdd0 Compare October 8, 2026 18:59
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