Copy TCP stats out when stack.Stats() is invoked.
Change-Id: Icddc6aa885d3b77f32ce0a33cd01542a09f55e65
diff --git a/tcpip/stack/stack.go b/tcpip/stack/stack.go
index d074529..8fd6e6d 100644
--- a/tcpip/stack/stack.go
+++ b/tcpip/stack/stack.go
@@ -151,6 +151,15 @@
UnknownNetworkEndpointRcvdPackets: atomic.LoadUint64(&s.stats.UnknownNetworkEndpointRcvdPackets),
MalformedRcvdPackets: atomic.LoadUint64(&s.stats.MalformedRcvdPackets),
DroppedPackets: atomic.LoadUint64(&s.stats.DroppedPackets),
+ TCP: TCPStats{
+ ActiveConnectionOpenings: atomic.LoadUint64(&s.stats.TCP.ActiveConnectionOpenings),
+ PassiveConnectionOpenings: atomic.LoadUint64(&s.stats.TCP.PassiveConnectionOpenings),
+ FailedConnectionAttempts: atomic.LoadUint64(&s.stats.TCP.FailedConnectionAttempts),
+ ValidSegmentsReceived: atomic.LoadUint64(&s.stats.TCP.ValidSegmentsReceived),
+ InvalidSegmentsReceived: atomic.LoadUint64(&s.stats.TCP.InvalidSegmentsReceived),
+ SegmentsSent: atomic.LoadUint64(&s.stats.TCP.SegmentsSent),
+ ResetsSent: atomic.LoadUint64(&s.stats.TCP.ResetsSent),
+ },
}
}
diff --git a/tcpip/tcpip.go b/tcpip/tcpip.go
index 029a6c7..2c44b1a 100644
--- a/tcpip/tcpip.go
+++ b/tcpip/tcpip.go
@@ -411,28 +411,31 @@
// DroppedPackets is the number of packets dropped due to full queues.
DroppedPackets uint64
- // TODO(stijlist): copy these TCP stats out when stack.Stats() is invoked.
- TCP struct {
- // ActiveConnectionOpenings is the number of connections opened successfully
- // via Connect.
- ActiveConnectionOpenings uint64
- // PassiveConnectionOpenings is the number of connections opened
- // successfully via Listen.
- PassiveConnectionOpenings uint64
- // FailedConnectionAttempts is the number of calls to Connect or Listen
- // (active and passive openings, respectively) that end in an error.
- FailedConnectionAttempts uint64
- // ValidSegmentsReceived is the number of TCP segments received that the
- // transport layer successfully parsed.
- ValidSegmentsReceived uint64
- // InvalidSegmentsReceived is the number of TCP segments received that
- // the transport layer could not parse.
- InvalidSegmentsReceived uint64
- // SegmentsSent is the number of TCP segments sent.
- SegmentsSent uint64
- // ResetsSent is the number of TCP resets sent.
- ResetsSent uint64
- }
+ // TCP breaks out TCP-specific stats.
+ TCP TCPStats
+}
+
+// TCPStats collects TCP-specific stats.
+type TCPStats struct {
+ // ActiveConnectionOpenings is the number of connections opened successfully
+ // via Connect.
+ ActiveConnectionOpenings uint64
+ // PassiveConnectionOpenings is the number of connections opened
+ // successfully via Listen.
+ PassiveConnectionOpenings uint64
+ // FailedConnectionAttempts is the number of calls to Connect or Listen
+ // (active and passive openings, respectively) that end in an error.
+ FailedConnectionAttempts uint64
+ // ValidSegmentsReceived is the number of TCP segments received that the
+ // transport layer successfully parsed.
+ ValidSegmentsReceived uint64
+ // InvalidSegmentsReceived is the number of TCP segments received that
+ // the transport layer could not parse.
+ InvalidSegmentsReceived uint64
+ // SegmentsSent is the number of TCP segments sent.
+ SegmentsSent uint64
+ // ResetsSent is the number of TCP resets sent.
+ ResetsSent uint64
}
// String implements the fmt.Stringer interface.