diff options
author | Tamir Duberstein <tamird@google.com> | 2018-09-12 21:57:04 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-09-12 21:57:55 -0700 |
commit | d689f8422fd55f74f6fc677f33b2bbf3720de89e (patch) | |
tree | 729ba29346fa74ac4a413f6f619d9e85ceb0ae78 /pkg/tcpip/transport/tcp/testing/context | |
parent | 5adb3468d4de249df055d641e01ce6582b3a9388 (diff) |
Always pass buffer.VectorisedView by value
PiperOrigin-RevId: 212757571
Change-Id: I04200df9e45c21eb64951cd2802532fa84afcb1a
Diffstat (limited to 'pkg/tcpip/transport/tcp/testing/context')
-rw-r--r-- | pkg/tcpip/transport/tcp/testing/context/context.go | 22 |
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. |