Files
tailscale/net
Kabir Sikand bed57dc353 net/tstun: count forwarded traffic per advertised subnet route
Wires the per-route counters into the three packet-path chokepoints that
already decode every packet for network flow logging, but independently of
it, so counting works with flow logging off.

Direction is assigned from the subnet router's point of view: packets written
into the TUN are heading into the subnet (tx), while packets read out toward a
tailnet peer are coming back from it (rx). The Read path reuses the
already-decoded packet rather than parsing it again.

Counting is off until SetSubnetRoutes supplies routes, so non-routers and
nodes that have not opted in pay only a nil atomic load per packet.

Only traffic with exactly one Tailscale endpoint is counted, which excludes
the node's own tailnet traffic; addresses outside every advertised route are
skipped, which excludes exit node traffic.

Updates tailscale/corp#45684

Change-Id: Ib22fc164ab059378804710fc5a2387c87d514e0d
Signed-off-by: Kabir Sikand <[email protected]>
2026-07-29 02:00:05 +00:00
..
2026-07-10 17:39:16 -07:00