Skip to content

Commit ff1b35e

Browse files
authored
net/connstats: exclude traffic with internal Tailscale service (tailscale#7904)
Exclude traffic with 100.100.100.100 (for IPv4) and with fd7a:115c:a1e0::53 (for IPv6) since this traffic with the Tailscale service running locally on the node. This traffic never left the node. It also happens to be a high volume amount of traffic since DNS requests occur over UDP with each request coming from a unique port, thus resulting in many discrete traffic flows. Fixes tailscale/corp#10554 Signed-off-by: Joe Tsai <joetsai@digital-static.net>
1 parent 9a655a1 commit ff1b35e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

net/connstats/stats.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"golang.org/x/sync/errgroup"
1515
"tailscale.com/net/packet"
16+
"tailscale.com/net/tsaddr"
1617
"tailscale.com/types/netlogtype"
1718
)
1819

@@ -92,6 +93,11 @@ func (s *Statistics) UpdateRxVirtual(b []byte) {
9293
s.updateVirtual(b, true)
9394
}
9495

96+
var (
97+
tailscaleServiceIPv4 = tsaddr.TailscaleServiceIP()
98+
tailscaleServiceIPv6 = tsaddr.TailscaleServiceIPv6()
99+
)
100+
95101
func (s *Statistics) updateVirtual(b []byte, receive bool) {
96102
var p packet.Parsed
97103
p.Decode(b)
@@ -100,6 +106,15 @@ func (s *Statistics) updateVirtual(b []byte, receive bool) {
100106
conn.Src, conn.Dst = conn.Dst, conn.Src
101107
}
102108

109+
// Network logging is defined as traffic between two Tailscale nodes.
110+
// Traffic with the internal Tailscale service is not with another node
111+
// and should not be logged. It also happens to be a high volume
112+
// amount of discrete traffic flows (e.g., DNS lookups).
113+
switch conn.Dst.Addr() {
114+
case tailscaleServiceIPv4, tailscaleServiceIPv6:
115+
return
116+
}
117+
103118
s.mu.Lock()
104119
defer s.mu.Unlock()
105120
cnts, found := s.virtual[conn]

0 commit comments

Comments
 (0)