mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-20 13:41:41 +00:00
cmd/stunstamp: add protocol context to timeout logs (#13422)
We started out with a single protocol & port, now it's many. Updates #cleanup Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
parent
0970615b1b
commit
a228d77f86
@ -380,27 +380,6 @@ type nodeMeta struct {
|
|||||||
|
|
||||||
type measureFn func(conn io.ReadWriteCloser, hostname string, dst netip.AddrPort) (rtt time.Duration, err error)
|
type measureFn func(conn io.ReadWriteCloser, hostname string, dst netip.AddrPort) (rtt time.Duration, err error)
|
||||||
|
|
||||||
// probe measures round trip time for the node described by meta over cf against
|
|
||||||
// dstPort. It may return a nil duration and nil error in the event of a
|
|
||||||
// timeout. A non-nil error indicates an unrecoverable or non-temporary error.
|
|
||||||
func probe(meta nodeMeta, cf *connAndMeasureFn, dstPort int) (*time.Duration, error) {
|
|
||||||
ua := &net.UDPAddr{
|
|
||||||
IP: net.IP(meta.addr.AsSlice()),
|
|
||||||
Port: dstPort,
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(rand.N(maxTXJitter)) // jitter across tx
|
|
||||||
rtt, err := cf.fn(cf.conn, meta.hostname, netip.AddrPortFrom(meta.addr, uint16(dstPort)))
|
|
||||||
if err != nil {
|
|
||||||
if isTemporaryOrTimeoutErr(err) {
|
|
||||||
log.Printf("temp error measuring RTT to %s(%s): %v", meta.hostname, ua.String(), err)
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &rtt, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// nodeMetaFromDERPMap parses the provided DERP map in order to update nodeMeta
|
// nodeMetaFromDERPMap parses the provided DERP map in order to update nodeMeta
|
||||||
// in the provided nodeMetaByAddr. It returns a slice of nodeMeta containing
|
// in the provided nodeMetaByAddr. It returns a slice of nodeMeta containing
|
||||||
// the nodes that are no longer seen in the DERP map, but were previously held
|
// the nodes that are no longer seen in the DERP map, but were previously held
|
||||||
@ -620,16 +599,24 @@ func probeNodes(nodeMetaByAddr map[netip.Addr]nodeMeta, stableConns map[stableCo
|
|||||||
},
|
},
|
||||||
at: at,
|
at: at,
|
||||||
}
|
}
|
||||||
rtt, err := probe(meta, cf, dstPort)
|
time.Sleep(rand.N(maxTXJitter)) // jitter across tx
|
||||||
|
addrPort := netip.AddrPortFrom(meta.addr, uint16(dstPort))
|
||||||
|
rtt, err := cf.fn(cf.conn, meta.hostname, addrPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if isTemporaryOrTimeoutErr(err) {
|
||||||
|
r.rtt = nil
|
||||||
|
log.Printf("%s: temp error measuring RTT to %s(%s): %v", protocol, meta.hostname, addrPort, err)
|
||||||
|
} else {
|
||||||
select {
|
select {
|
||||||
case <-doneCh:
|
case <-doneCh:
|
||||||
return
|
return
|
||||||
case errCh <- err:
|
case errCh <- fmt.Errorf("%s: %v", protocol, err):
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r.rtt = rtt
|
} else {
|
||||||
|
r.rtt = &rtt
|
||||||
|
}
|
||||||
select {
|
select {
|
||||||
case <-doneCh:
|
case <-doneCh:
|
||||||
case resultsCh <- r:
|
case resultsCh <- r:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user