tailscale/net
Andrea Gottardo d9aeb30281
net/interfaces: handle iOS network transitions (#10680)
Updates #8022
Updates #6075

On iOS, we currently rely on delegated interface information to figure out the default route interface.  The NetworkExtension framework in iOS seems to set the delegate interface only once, upon the *creation* of the VPN tunnel. If a network transition (e.g. from Wi-Fi to Cellular) happens while the tunnel is connected, it will be ignored and we will still try to set Wi-Fi as the default route because the delegated interface is not getting updated as connectivity transitions.

Here we work around this on the Swift side with a NWPathMonitor instance that observes the interface name of the first currently satisfied network path. Our Swift code will call into `UpdateLastKnownDefaultRouteInterface`, so we can rely on that when it is set.

If for any reason the Swift machinery didn't work and we don't get any updates, here we also have some fallback logic: we try finding a hardcoded Wi-Fi interface called en0. If en0 is down, we fall back to cellular (pdp_ip0) as a last resort. This doesn't handle all edge cases like USB-Ethernet adapters or multiple Ethernet interfaces, but it is good enough to ensure connectivity isn't broken.

I tested this on iPhones and iPads running iOS 17.1 and it appears to work. Switching between different cellular plans on a dual SIM configuration also works (the interface name remains pdp_ip0).

Signed-off-by: Andrea Gottardo <andrea@tailscale.com>
2024-01-04 09:40:18 -08:00
..
art all: cleanup unused code, part 2 (#10670) 2023-12-21 17:40:03 -08:00
connstats net/connstats: exclude traffic with internal Tailscale service (#7904) 2023-04-17 14:24:29 -07:00
dns all: cleanup unused code, part 2 (#10670) 2023-12-21 17:40:03 -08:00
dnscache all: cleanup unused code, part 2 (#10670) 2023-12-21 17:40:03 -08:00
dnsfallback net/dnsfallback: add singleflight to recursive resolver 2023-11-15 13:57:49 -05:00
flowtrack all: update copyright and license headers 2023-01-27 15:36:29 -08:00
interfaces net/interfaces: handle iOS network transitions (#10680) 2024-01-04 09:40:18 -08:00
memnet net/memnet: export the network name (#9111) 2023-08-28 11:43:51 -07:00
netaddr all: update copyright and license headers 2023-01-27 15:36:29 -08:00
netcheck net/netcheck: use DERP frames as a signal for home region liveness 2023-12-13 16:33:46 -05:00
neterror net/neterror, wgengine/magicsock: use UDP GSO and GRO on Linux (#7791) 2023-04-04 16:32:16 -07:00
netkernelconf client/tailscale,ipn/{ipnlocal,localapi}: check UDP GRO config (#10071) 2023-11-09 11:34:41 -08:00
netknob all: update copyright and license headers 2023-01-27 15:36:29 -08:00
netmon all: cleanup unused code, part 2 (#10670) 2023-12-21 17:40:03 -08:00
netns net/{interfaces,netmon}: remove "interesting", EqualFiltered API 2023-08-29 11:57:30 -07:00
netstat net/{netns,netstat}: use new x/sys/cpu.IsBigEndian 2023-02-02 07:41:49 -08:00
netutil all: cleanup unused code, part 2 (#10670) 2023-12-21 17:40:03 -08:00
packet all: cleanup unused code, part 1 (#10661) 2023-12-20 14:50:30 -08:00
ping net/ping: fix ICMP echo code field to 0 2023-09-15 17:08:39 -07:00
portmapper net/portmapper: check returned epoch from PMP and PCP protocols 2024-01-03 14:17:50 -05:00
proxymux all: cleanup unused code, part 1 (#10661) 2023-12-20 14:50:30 -08:00
routetable all: cleanup unused code, part 2 (#10670) 2023-12-21 17:40:03 -08:00
socks5 net/socks5: add password auth support 2023-03-05 14:08:34 -08:00
sockstats net/dns: retry forwarder requests over TCP 2023-09-25 16:42:07 -04:00
speedtest all: update copyright and license headers 2023-01-27 15:36:29 -08:00
stun wgengine/magicsock, types/nettype, etc: finish ReadFromUDPAddrPort netip migration 2023-04-15 13:40:15 -07:00
tcpinfo net/tcpinfo: add package to allow fetching TCP information 2023-06-27 21:59:43 -04:00
tlsdial cmd/tailscale/cli: make netcheck run even if machine lacks TLS certs 2023-08-23 21:11:04 -07:00
tsaddr all: cleanup unused code, part 1 (#10661) 2023-12-20 14:50:30 -08:00
tsdial all: cleanup unused code, part 1 (#10661) 2023-12-20 14:50:30 -08:00
tshttpproxy net/tshttpproxy: don't proxy through ourselves 2023-03-29 17:09:45 -04:00
tstun all: cleanup unused code, part 2 (#10670) 2023-12-21 17:40:03 -08:00
wsconn net/wsconn: accept a remote addr string and plumb it through 2023-08-29 16:57:16 -07:00