You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
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
6 months ago
..
art net/art: allow non-pointers as values 10 months ago
connstats net/connstats: exclude traffic with internal Tailscale service (#7904) 1 year ago
dns net/dns: use an additional registry setting to disable dynamic DNS updates for our interface on Windows 6 months ago
dnscache net/dnscache: remove completed TODO 7 months ago
dnsfallback net/dnsfallback: add singleflight to recursive resolver 7 months ago
flowtrack all: update copyright and license headers 1 year ago
interfaces net/interfaces: ensure we return valid 'self' IP in LikelyHomeRouterIP 6 months ago
memnet net/memnet: export the network name (#9111) 9 months ago
netaddr all: update copyright and license headers 1 year ago
netcheck net/netcheck,wgengine/magicsock: reduce coupling between netcheck and magicsock 10 months ago
neterror net/neterror, wgengine/magicsock: use UDP GSO and GRO on Linux (#7791) 1 year ago
netkernelconf client/tailscale,ipn/{ipnlocal,localapi}: check UDP GRO config (#10071) 7 months ago
netknob all: update copyright and license headers 1 year ago
netmon net/netmon: log when the gateway/self IP changes 9 months ago
netns net/{interfaces,netmon}: remove "interesting", EqualFiltered API 9 months ago
netstat net/{netns,netstat}: use new x/sys/cpu.IsBigEndian 1 year ago
netutil cmd/tailscale: refactor shared utility methods 10 months ago
packet net/packet: split off checksum munging into different pkg 8 months ago
ping net/ping: fix ICMP echo code field to 0 9 months ago
portmapper net/portmapper: avoid alloc in getUPnPErrorsMetric 7 months ago
proxymux all: update copyright and license headers 1 year ago
routetable net/routetable: include unknown flags in the routetable doctor output 1 year ago
socks5 net/socks5: add password auth support 1 year ago
sockstats net/dns: retry forwarder requests over TCP 8 months ago
speedtest all: update copyright and license headers 1 year ago
stun wgengine/magicsock, types/nettype, etc: finish ReadFromUDPAddrPort netip migration 1 year ago
tcpinfo net/tcpinfo: add package to allow fetching TCP information 11 months ago
tlsdial cmd/tailscale/cli: make netcheck run even if machine lacks TLS certs 9 months ago
tsaddr types/netmap: remove NetworkMap.{Addresses,MachineStatus} 9 months ago
tsdial types/netmap: remove NetworkMap.{Addresses,MachineStatus} 9 months ago
tshttpproxy net/tshttpproxy: don't proxy through ourselves 1 year ago
tstun cmd/tailscaled,net/tstun: fix data race on start-up in TUN mode 8 months ago
wsconn net/wsconn: accept a remote addr string and plumb it through 9 months ago