summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/tcp/testing
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/tcpip/transport/tcp/testing')
-rw-r--r--pkg/tcpip/transport/tcp/testing/context/context.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/pkg/tcpip/transport/tcp/testing/context/context.go b/pkg/tcpip/transport/tcp/testing/context/context.go
index c46af4b8b..5b25534f4 100644
--- a/pkg/tcpip/transport/tcp/testing/context/context.go
+++ b/pkg/tcpip/transport/tcp/testing/context/context.go
@@ -205,9 +205,11 @@ func (c *Context) Stack() *stack.Stack {
// CheckNoPacketTimeout verifies that no packet is received during the time
// specified by wait.
func (c *Context) CheckNoPacketTimeout(errMsg string, wait time.Duration) {
+ c.t.Helper()
+
select {
case <-c.linkEP.C:
- c.t.Fatalf(errMsg)
+ c.t.Fatal(errMsg)
case <-time.After(wait):
}
@@ -290,9 +292,7 @@ func (c *Context) SendICMPPacket(typ header.ICMPv4Type, code uint8, p1, p2 []byt
copy(icmp[header.ICMPv4MinimumSize+len(p1):], p2)
// Inject packet.
- var views [1]buffer.View
- vv := buf.ToVectorisedView(views)
- c.linkEP.Inject(ipv4.ProtocolNumber, &vv)
+ c.linkEP.Inject(ipv4.ProtocolNumber, buf.ToVectorisedView())
}
// BuildSegment builds a TCP segment based on the given Headers and payload.
@@ -337,23 +337,19 @@ func (c *Context) BuildSegment(payload []byte, h *Headers) buffer.VectorisedView
t.SetChecksum(^t.CalculateChecksum(xsum, length))
// Inject packet.
- var views [1]buffer.View
- vv := buf.ToVectorisedView(views)
-
- return vv
+ return buf.ToVectorisedView()
}
// SendSegment sends a TCP segment that has already been built and written to a
// buffer.VectorisedView.
-func (c *Context) SendSegment(s *buffer.VectorisedView) {
+func (c *Context) SendSegment(s buffer.VectorisedView) {
c.linkEP.Inject(ipv4.ProtocolNumber, s)
}
// SendPacket builds and sends a TCP segment(with the provided payload & TCP
// headers) in an IPv4 packet via the link layer endpoint.
func (c *Context) SendPacket(payload []byte, h *Headers) {
- vv := c.BuildSegment(payload, h)
- c.linkEP.Inject(ipv4.ProtocolNumber, &vv)
+ c.linkEP.Inject(ipv4.ProtocolNumber, c.BuildSegment(payload, h))
}
// SendAck sends an ACK packet.
@@ -496,9 +492,7 @@ func (c *Context) SendV6Packet(payload []byte, h *Headers) {
t.SetChecksum(^t.CalculateChecksum(xsum, length))
// Inject packet.
- var views [1]buffer.View
- vv := buf.ToVectorisedView(views)
- c.linkEP.Inject(ipv6.ProtocolNumber, &vv)
+ c.linkEP.Inject(ipv6.ProtocolNumber, buf.ToVectorisedView())
}
// CreateConnected creates a connected TCP endpoint.