mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-15 10:49:18 +00:00
ipn/{ipnlocal,localapi},wgengine{,/magicsock}: plumb health.Tracker
Down to 25 health.Global users. After this remains controlclient & net/dns & wgengine/router. Updates #11874 Updates #4136 Change-Id: I6dd1856e3d9bf523bdd44b60fb3b8f7501d5dc0d Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
df8f40905b
commit
6d69fc137f
@@ -91,6 +91,7 @@ type Conn struct {
|
||||
testOnlyPacketListener nettype.PacketListener
|
||||
noteRecvActivity func(key.NodePublic) // or nil, see Options.NoteRecvActivity
|
||||
netMon *netmon.Monitor // or nil
|
||||
health *health.Tracker // or nil
|
||||
controlKnobs *controlknobs.Knobs // or nil
|
||||
|
||||
// ================================================================
|
||||
@@ -369,9 +370,13 @@ type Options struct {
|
||||
NoteRecvActivity func(key.NodePublic)
|
||||
|
||||
// NetMon is the network monitor to use.
|
||||
// With one, the portmapper won't be used.
|
||||
// If nil, the portmapper won't be used.
|
||||
NetMon *netmon.Monitor
|
||||
|
||||
// HealthTracker optionally specifies the health tracker to
|
||||
// report errors and warnings to.
|
||||
HealthTracker *health.Tracker
|
||||
|
||||
// ControlKnobs are the set of control knobs to use.
|
||||
// If nil, they're ignored and not updated.
|
||||
ControlKnobs *controlknobs.Knobs
|
||||
@@ -463,6 +468,7 @@ func NewConn(opts Options) (*Conn, error) {
|
||||
c.portMapper.SetGatewayLookupFunc(opts.NetMon.GatewayAndSelfIP)
|
||||
}
|
||||
c.netMon = opts.NetMon
|
||||
c.health = opts.HealthTracker
|
||||
c.onPortUpdate = opts.OnPortUpdate
|
||||
c.getPeerByKey = opts.PeerByKeyFunc
|
||||
|
||||
@@ -666,7 +672,7 @@ func (c *Conn) updateNetInfo(ctx context.Context) (*netcheck.Report, error) {
|
||||
// NOTE(andrew-d): I don't love that we're depending on the
|
||||
// health package here, but I'd rather do that and not store
|
||||
// the exact same state in two different places.
|
||||
GetLastDERPActivity: health.Global.GetDERPRegionReceivedTime,
|
||||
GetLastDERPActivity: c.health.GetDERPRegionReceivedTime,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -2471,7 +2477,7 @@ func (c *Conn) bindSocket(ruc *RebindingUDPConn, network string, curPortFate cur
|
||||
}
|
||||
ruc.setConnLocked(pconn, network, c.bind.BatchSize())
|
||||
if network == "udp4" {
|
||||
health.Global.SetUDP4Unbound(false)
|
||||
c.health.SetUDP4Unbound(false)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -2482,7 +2488,7 @@ func (c *Conn) bindSocket(ruc *RebindingUDPConn, network string, curPortFate cur
|
||||
// we get a link change and we can try binding again.
|
||||
ruc.setConnLocked(newBlockForeverConn(), "", c.bind.BatchSize())
|
||||
if network == "udp4" {
|
||||
health.Global.SetUDP4Unbound(true)
|
||||
c.health.SetUDP4Unbound(true)
|
||||
}
|
||||
return fmt.Errorf("failed to bind any ports (tried %v)", ports)
|
||||
}
|
||||
|
Reference in New Issue
Block a user