tailscale/net
Andrew Dunham c4ccdd1bd1 net/interfaces: ensure we return valid 'self' IP in LikelyHomeRouterIP
Before this fix, LikelyHomeRouterIP could return a 'self' IP that
doesn't correspond to the gateway address, since it picks the first
private address when iterating over the set interfaces as the 'self' IP,
without checking that the address corresponds with the
previously-detected gateway.

This behaviour was introduced by accident in aaf2df7, where we deleted
the following code:

    for _, prefix := range privatev4s {
        if prefix.Contains(gateway) && prefix.Contains(ip) {
            myIP = ip
            ok = true
            return
        }
    }

Other than checking that 'gateway' and 'ip' were private IP addresses
(which were correctly replaced with a call to the netip.Addr.IsPrivate
method), it also implicitly checked that both 'gateway' and 'ip' were a
part of the *same* prefix, and thus likely to be the same interface.

Restore that behaviour by explicitly checking pfx.Contains(gateway),
which, given that the 'ip' variable is derived from our prefix 'pfx',
ensures that the 'self' IP will correspond to the returned 'gateway'.

Fixes #10466

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: Iddd2ee70cefb9fb40071986fefeace9ca2441ee6
2023-12-05 10:29:37 -05:00
..
art net/art: allow non-pointers as values 2023-08-17 10:43:18 -07:00
connstats net/connstats: exclude traffic with internal Tailscale service (#7904) 2023-04-17 14:24:29 -07:00
dns net/dns: use an additional registry setting to disable dynamic DNS updates for our interface on Windows 2023-12-04 09:10:35 -08:00
dnscache net/dnscache: remove completed TODO 2023-11-01 10:55:47 -07: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: ensure we return valid 'self' IP in LikelyHomeRouterIP 2023-12-05 10:29:37 -05: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,wgengine/magicsock: reduce coupling between netcheck and magicsock 2023-08-11 10:08:21 -07: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 net/netmon: log when the gateway/self IP changes 2023-09-12 17:48:29 -04: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 cmd/tailscale: refactor shared utility methods 2023-08-09 08:59:10 -07:00
packet net/packet: split off checksum munging into different pkg 2023-10-11 14:25:58 -07:00
ping net/ping: fix ICMP echo code field to 0 2023-09-15 17:08:39 -07:00
portmapper net/portmapper: avoid alloc in getUPnPErrorsMetric 2023-10-26 03:02:27 +02:00
proxymux all: update copyright and license headers 2023-01-27 15:36:29 -08:00
routetable net/routetable: include unknown flags in the routetable doctor output 2023-02-10 15:54:31 -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 types/netmap: remove NetworkMap.{Addresses,MachineStatus} 2023-09-18 17:08:11 +01:00
tsdial types/netmap: remove NetworkMap.{Addresses,MachineStatus} 2023-09-18 17:08:11 +01:00
tshttpproxy net/tshttpproxy: don't proxy through ourselves 2023-03-29 17:09:45 -04:00
tstun cmd/tailscaled,net/tstun: fix data race on start-up in TUN mode 2023-10-14 08:54:30 -07:00
wsconn net/wsconn: accept a remote addr string and plumb it through 2023-08-29 16:57:16 -07:00