Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/tcpip/transport/udp/forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ func NewForwarder(s *stack.Stack, handler ForwarderHandler) *Forwarder {
// This function is expected to be passed as an argument to the
// stack.SetTransportProtocolHandler function.
func (f *Forwarder) HandlePacket(id stack.TransportEndpointID, pkt *stack.PacketBuffer) bool {
return f.handler(&ForwarderRequest{
r := &ForwarderRequest{
stack: f.stack,
id: id,
pkt: pkt.Clone(),
})
}
// The forwarder handler is synchronous, so the cloned packet only needs
// to outlive the handler call. Release it on every return path.
defer r.pkt.DecRef()
return f.handler(r)
}

// ForwarderRequest represents a session request received by the forwarder and
Expand Down