mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-30 11:18:33 +00:00
derp: add more derp stats for dropped and received packets
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
c02f4b5a1f
commit
6cd81d5d1f
@ -39,8 +39,9 @@ type Server struct {
|
|||||||
logf logger.Logf
|
logf logger.Logf
|
||||||
|
|
||||||
// Counters:
|
// Counters:
|
||||||
packetsSent int64
|
packetsSent, bytesSent int64
|
||||||
bytesSent int64
|
packetsRecv, bytesRecv int64
|
||||||
|
packetsDropped int64
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
closed bool
|
closed bool
|
||||||
@ -221,6 +222,7 @@ func (s *Server) accept(nc net.Conn, brw *bufio.ReadWriter) error {
|
|||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
|
||||||
if dst == nil {
|
if dst == nil {
|
||||||
|
atomic.AddInt64(&s.packetsDropped, 1)
|
||||||
s.logf("derp: %s: client %x: dropping packet for unknown %x", nc.RemoteAddr(), c.key, dstKey)
|
s.logf("derp: %s: client %x: dropping packet for unknown %x", nc.RemoteAddr(), c.key, dstKey)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -351,6 +353,8 @@ func (s *Server) recvPacket(ctx context.Context, br *bufio.Reader, frameLen uint
|
|||||||
if _, err := io.ReadFull(br, contents); err != nil {
|
if _, err := io.ReadFull(br, contents); err != nil {
|
||||||
return key.Public{}, nil, err
|
return key.Public{}, nil, err
|
||||||
}
|
}
|
||||||
|
atomic.AddInt64(&s.packetsRecv, 1)
|
||||||
|
atomic.AddInt64(&s.bytesRecv, int64(len(contents)))
|
||||||
return dstKey, contents, nil
|
return dstKey, contents, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,6 +426,9 @@ func (s *Server) Stats() *ServerStats {
|
|||||||
TotalAccepts: s.accepts,
|
TotalAccepts: s.accepts,
|
||||||
PacketsSent: atomic.LoadInt64(&s.packetsSent),
|
PacketsSent: atomic.LoadInt64(&s.packetsSent),
|
||||||
BytesSent: atomic.LoadInt64(&s.bytesSent),
|
BytesSent: atomic.LoadInt64(&s.bytesSent),
|
||||||
|
PacketsReceived: atomic.LoadInt64(&s.packetsRecv),
|
||||||
|
BytesReceived: atomic.LoadInt64(&s.bytesRecv),
|
||||||
|
PacketsDropped: atomic.LoadInt64(&s.packetsDropped),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,4 +459,7 @@ type ServerStats struct {
|
|||||||
TotalAccepts int64 `json:"totalAccepts"`
|
TotalAccepts int64 `json:"totalAccepts"`
|
||||||
PacketsSent int64 `json:"packetsSent"`
|
PacketsSent int64 `json:"packetsSent"`
|
||||||
BytesSent int64 `json:"bytesSent"`
|
BytesSent int64 `json:"bytesSent"`
|
||||||
|
PacketsReceived int64 `json:"packetsReceived"`
|
||||||
|
BytesReceived int64 `json:"bytessReceived"`
|
||||||
|
PacketsDropped int64 `json:"packetsDropped"`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user