mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-21 20:22:41 +09:00
magicsock,tstun: add gauges for the number of open queues and sockets (#22535)
Updates tailscale/corp#48168 Updates tailscale/corp#37878 Change-Id: I8bedbc5043dccf0a2aecd77dfb76899c6a6a6964 Signed-off-by: Alex Valiushko <alexvaliushko@tailscale.com>
This commit is contained in:
1 parent
8dc50105e4
commit
36780d60ef
4 files changed
+16
No files matched your search
@@ -87,6 +87,7 @@ func New(logf logger.Logf, tunName string) (tun.Device, string, error) {
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
metricQueues.Set(int64(len(tun.QueuesOf(dev))))
|
||||
if err := waitInterfaceUp(dev, 90*time.Second, logf); err != nil {
|
||||
dev.Close()
|
||||
return nil, "", err
|
||||
|
||||
@@ -1605,6 +1605,8 @@ func (t *Wrapper) SetConnectionCounter(fn netlogfunc.ConnectionCounter) {
|
||||
}
|
||||
|
||||
var (
|
||||
metricQueues = clientmetric.NewGauge("tstun_queues")
|
||||
|
||||
metricPacketIn = clientmetric.NewCounter("tstun_in_from_wg")
|
||||
metricPacketInDrop = clientmetric.NewCounter("tstun_in_from_wg_drop")
|
||||
metricPacketInDropFilter = clientmetric.NewCounter("tstun_in_from_wg_drop_filter")
|
||||
|
||||
@@ -3963,6 +3963,13 @@ func (c *Conn) bindSocket(ruc *RebindingUDPConn, network string, curPortFate cur
|
||||
// from the perspective of ruc receive functions.
|
||||
ruc.mu.Lock()
|
||||
defer ruc.mu.Unlock()
|
||||
defer func() {
|
||||
m := metricUDPSocketsIPv4
|
||||
if network == "udp6" {
|
||||
m = metricUDPSocketsIPv6
|
||||
}
|
||||
m.Set(int64(ruc.group.bound))
|
||||
}()
|
||||
|
||||
if c.closing.Load() {
|
||||
return net.ErrClosed
|
||||
@@ -4449,6 +4456,9 @@ var (
|
||||
metricNumPeers = clientmetric.NewGauge("magicsock_netmap_num_peers")
|
||||
metricNumDERPConns = clientmetric.NewGauge("magicsock_num_derp_conns")
|
||||
|
||||
metricUDPSocketsIPv4 = clientmetric.NewGauge("magicsock_udp_sockets_ipv4")
|
||||
metricUDPSocketsIPv6 = clientmetric.NewGauge("magicsock_udp_sockets_ipv6")
|
||||
|
||||
metricRebindCalls = clientmetric.NewCounter("magicsock_rebind_calls")
|
||||
metricReSTUNCalls = clientmetric.NewCounter("magicsock_restun_calls")
|
||||
metricUpdateEndpoints = clientmetric.NewCounter("magicsock_update_endpoints")
|
||||
|
||||
@@ -25,6 +25,9 @@ func TestUDPSockets(t *testing.T) {
|
||||
if got := ruc.group.bound; got != sockets {
|
||||
t.Fatalf("bound %d sockets, want %d", got, sockets)
|
||||
}
|
||||
if got := metricUDPSocketsIPv4.Value(); got != int64(sockets) {
|
||||
t.Errorf("metric reports %d sockets, want %d", got, sockets)
|
||||
}
|
||||
for i, pconn := range ruc.group.conns[:ruc.group.bound] {
|
||||
if got := uint16(pconn.LocalAddr().(*net.UDPAddr).Port); got != ruc.Port() {
|
||||
t.Errorf("socket %d bound to port %d, want %d", i, got, ruc.Port())
|
||||
|
||||
Reference in new issue
Block a user