diff options
| author | Mihai Parparita <mihai@tailscale.com> | 2023-04-17 16:01:41 -0700 |
|---|---|---|
| committer | Mihai Parparita <mihai.parparita@gmail.com> | 2023-04-20 15:46:01 -0700 |
| commit | 7330aa593e3701cb193ceff0bc26eda3bc62df83 (patch) | |
| tree | d76ab14868a92aa799dbb2119502b7ee267f06dd /control/controlhttp | |
| parent | 7f17e04a5a7952f9c1ed0e23b799a21a124a5a51 (diff) | |
| download | tailscale-7330aa593e3701cb193ceff0bc26eda3bc62df83.tar.xz tailscale-7330aa593e3701cb193ceff0bc26eda3bc62df83.zip | |
all: avoid repeated default interface lookups
On some platforms (notably macOS and iOS) we look up the default
interface to bind outgoing connections to. This is both duplicated
work and results in logspam when the default interface is not available
(i.e. when a phone has no connectivity, we log an error and thus cause
more things that we will try to upload and fail).
Fixed by passing around a netmon.Monitor to more places, so that we can
use its cached interface state.
Fixes #7850
Updates #7621
Signed-off-by: Mihai Parparita <mihai@tailscale.com>
Diffstat (limited to 'control/controlhttp')
| -rw-r--r-- | control/controlhttp/client.go | 4 | ||||
| -rw-r--r-- | control/controlhttp/constants.go | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/control/controlhttp/client.go b/control/controlhttp/client.go index 02b5a7821..d04aac518 100644 --- a/control/controlhttp/client.go +++ b/control/controlhttp/client.go @@ -389,13 +389,15 @@ func (a *Dialer) tryURLUpgrade(ctx context.Context, u *url.URL, addr netip.Addr, SingleHostStaticResult: []netip.Addr{addr}, SingleHost: u.Hostname(), Logf: a.Logf, // not a.logf method; we want to propagate nil-ness + NetMon: a.NetMon, } } else { dns = &dnscache.Resolver{ Forward: dnscache.Get().Forward, - LookupIPFallback: dnsfallback.Lookup(a.logf), + LookupIPFallback: dnsfallback.MakeLookupFunc(a.logf, a.NetMon), UseLastGood: true, Logf: a.Logf, // not a.logf method; we want to propagate nil-ness + NetMon: a.NetMon, } } diff --git a/control/controlhttp/constants.go b/control/controlhttp/constants.go index 045eeba7f..a58ee5374 100644 --- a/control/controlhttp/constants.go +++ b/control/controlhttp/constants.go @@ -9,6 +9,7 @@ import ( "time" "tailscale.com/net/dnscache" + "tailscale.com/net/netmon" "tailscale.com/tailcfg" "tailscale.com/types/key" "tailscale.com/types/logger" @@ -70,6 +71,8 @@ type Dialer struct { // dropped. Logf logger.Logf + NetMon *netmon.Monitor + // DialPlan, if set, contains instructions from the control server on // how to connect to it. If present, we will try the methods in this // plan before falling back to DNS. |
