summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/udp
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@google.com>2018-09-12 21:57:04 -0700
committerShentubot <shentubot@google.com>2018-09-12 21:57:55 -0700
commitd689f8422fd55f74f6fc677f33b2bbf3720de89e (patch)
tree729ba29346fa74ac4a413f6f619d9e85ceb0ae78 /pkg/tcpip/transport/udp
parent5adb3468d4de249df055d641e01ce6582b3a9388 (diff)
Always pass buffer.VectorisedView by value
PiperOrigin-RevId: 212757571 Change-Id: I04200df9e45c21eb64951cd2802532fa84afcb1a
Diffstat (limited to 'pkg/tcpip/transport/udp')
-rw-r--r--pkg/tcpip/transport/udp/endpoint.go7
-rw-r--r--pkg/tcpip/transport/udp/protocol.go2
-rw-r--r--pkg/tcpip/transport/udp/udp_test.go8
3 files changed, 6 insertions, 11 deletions
diff --git a/pkg/tcpip/transport/udp/endpoint.go b/pkg/tcpip/transport/udp/endpoint.go
index 5de518a55..e9337a88e 100644
--- a/pkg/tcpip/transport/udp/endpoint.go
+++ b/pkg/tcpip/transport/udp/endpoint.go
@@ -362,8 +362,7 @@ func (e *endpoint) Write(p tcpip.Payload, opts tcpip.WriteOptions) (uintptr, *tc
ttl = e.multicastTTL
}
- vv := buffer.NewVectorisedView(len(v), []buffer.View{v})
- if err := sendUDP(route, vv, e.id.LocalPort, dstPort, ttl); err != nil {
+ if err := sendUDP(route, buffer.View(v).ToVectorisedView(), e.id.LocalPort, dstPort, ttl); err != nil {
return 0, err
}
return uintptr(len(v)), nil
@@ -843,7 +842,7 @@ func (e *endpoint) Readiness(mask waiter.EventMask) waiter.EventMask {
// HandlePacket is called by the stack when new packets arrive to this transport
// endpoint.
-func (e *endpoint) HandlePacket(r *stack.Route, id stack.TransportEndpointID, vv *buffer.VectorisedView) {
+func (e *endpoint) HandlePacket(r *stack.Route, id stack.TransportEndpointID, vv buffer.VectorisedView) {
// Get the header then trim it from the view.
hdr := header.UDP(vv.First())
if int(hdr.Length()) > vv.Size() {
@@ -892,5 +891,5 @@ func (e *endpoint) HandlePacket(r *stack.Route, id stack.TransportEndpointID, vv
}
// HandleControlPacket implements stack.TransportEndpoint.HandleControlPacket.
-func (e *endpoint) HandleControlPacket(id stack.TransportEndpointID, typ stack.ControlType, extra uint32, vv *buffer.VectorisedView) {
+func (e *endpoint) HandleControlPacket(id stack.TransportEndpointID, typ stack.ControlType, extra uint32, vv buffer.VectorisedView) {
}
diff --git a/pkg/tcpip/transport/udp/protocol.go b/pkg/tcpip/transport/udp/protocol.go
index dabc5bd13..1334fec8a 100644
--- a/pkg/tcpip/transport/udp/protocol.go
+++ b/pkg/tcpip/transport/udp/protocol.go
@@ -62,7 +62,7 @@ func (*protocol) ParsePorts(v buffer.View) (src, dst uint16, err *tcpip.Error) {
// HandleUnknownDestinationPacket handles packets targeted at this protocol but
// that don't match any existing endpoint.
-func (p *protocol) HandleUnknownDestinationPacket(*stack.Route, stack.TransportEndpointID, *buffer.VectorisedView) bool {
+func (p *protocol) HandleUnknownDestinationPacket(*stack.Route, stack.TransportEndpointID, buffer.VectorisedView) bool {
return true
}
diff --git a/pkg/tcpip/transport/udp/udp_test.go b/pkg/tcpip/transport/udp/udp_test.go
index 6d7a737bd..46110c8ff 100644
--- a/pkg/tcpip/transport/udp/udp_test.go
+++ b/pkg/tcpip/transport/udp/udp_test.go
@@ -204,9 +204,7 @@ func (c *testContext) sendV6Packet(payload []byte, h *headers) {
u.SetChecksum(^u.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())
}
func (c *testContext) sendPacket(payload []byte, h *headers) {
@@ -245,9 +243,7 @@ func (c *testContext) sendPacket(payload []byte, h *headers) {
u.SetChecksum(^u.CalculateChecksum(xsum, length))
// Inject packet.
- var views [1]buffer.View
- vv := buf.ToVectorisedView(views)
- c.linkEP.Inject(ipv4.ProtocolNumber, &vv)
+ c.linkEP.Inject(ipv4.ProtocolNumber, buf.ToVectorisedView())
}
func newPayload() []byte {