net/connstats: enforce maximum number of connections (#6760)
The Tailscale logging service has a hard limit on the maximum log message size that can be accepted. We want to ensure that netlog messages never exceed this limit otherwise a client cannot transmit logs. Move the goroutine for periodically dumping netlog messages from wgengine/netlog to net/connstats. This allows net/connstats to manage when it dumps messages, either based on time or by size. Updates tailscale/corp#8427 Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
@@ -135,7 +135,7 @@ func runDERPAndStun(t *testing.T, logf logger.Logf, l nettype.PacketListener, st
|
||||
type magicStack struct {
|
||||
privateKey key.NodePrivate
|
||||
epCh chan []tailcfg.Endpoint // endpoint updates produced by this peer
|
||||
stats connstats.Statistics // per-connection statistics
|
||||
stats *connstats.Statistics // per-connection statistics
|
||||
conn *Conn // the magicsock itself
|
||||
tun *tuntest.ChannelTUN // TUN device to send/receive packets
|
||||
tsTun *tstun.Wrapper // wrapped tun that implements filtering and wgengine hooks
|
||||
@@ -1053,11 +1053,15 @@ func testTwoDevicePing(t *testing.T, d *devices) {
|
||||
}
|
||||
}
|
||||
|
||||
m1.conn.SetStatistics(&m1.stats)
|
||||
m2.conn.SetStatistics(&m2.stats)
|
||||
m1.stats = connstats.NewStatistics(0, 0, nil)
|
||||
defer m1.stats.Shutdown(context.Background())
|
||||
m1.conn.SetStatistics(m1.stats)
|
||||
m2.stats = connstats.NewStatistics(0, 0, nil)
|
||||
defer m2.stats.Shutdown(context.Background())
|
||||
m2.conn.SetStatistics(m2.stats)
|
||||
|
||||
checkStats := func(t *testing.T, m *magicStack, wantConns []netlogtype.Connection) {
|
||||
_, stats := m.stats.Extract()
|
||||
_, stats := m.stats.TestExtract()
|
||||
for _, conn := range wantConns {
|
||||
if _, ok := stats[conn]; ok {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user