summaryrefslogtreecommitdiffhomepage
path: root/control/controlknobs/controlknobs.go
diff options
context:
space:
mode:
authorAndrew Dunham <andrew@du.nham.ca>2023-12-05 09:44:32 -0500
committerAndrew Dunham <andrew@du.nham.ca>2023-12-05 10:29:37 -0500
commitc4ccdd1bd10a134471c46042f779e8576c3a4ed5 (patch)
tree7ead618d7f0930a81a0b328a895c3a078956e865 /control/controlknobs/controlknobs.go
parent6b083a8ddfcfac43f93bd180356b262fcbcdc280 (diff)
downloadtailscale-c4ccdd1bd10a134471c46042f779e8576c3a4ed5.tar.xz
tailscale-c4ccdd1bd10a134471c46042f779e8576c3a4ed5.zip
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
Diffstat (limited to 'control/controlknobs/controlknobs.go')
0 files changed, 0 insertions, 0 deletions