Skip to content
This repository was archived by the owner on May 20, 2020. It is now read-only.
This repository was archived by the owner on May 20, 2020. It is now read-only.

udp.ForwarderRequest.CreateEndpoint doesn't set endpoint.effectiveNetProtos #27

@neex

Description

@neex

The endpoint returned by udp.ForwarderRequest.CreateEndpoint doesn't have effectiveNetProtos filled (it's nil).

Maybe I'm missing something and I should do some initialization by hand?

There're two things that make me think this is not true:

  1. Endpoints returned by tcp.ForwarderRequest.CreateEndpoint have their effectiveNetProtos set.
  2. A test that uses udp.Forwarder at https://github.com/google/gvisor/blob/master/pkg/tcpip/adapters/gonet/gonet_test.go#L354 doesn't do anything more than CreateEndpoint.

Missing effectiveNetProtos means that such endpoint won't be closed correctly: while stack.RegisterTransportEndpoint is called with hardcoded netProtos in ForwarderRequest.CreateEndpoints, the UnregisterTransportEndpoint in endpoint.Close is called with netprotos == nil.

This means that the code as simple as

...
	var wq waiter.Queue
	f := udp.NewForwarder(s, func(r *udp.ForwarderRequest) {
		if zalupa, err := r.CreateEndpoint(&wq); err == nil {
			log.Printf("Packet received: %v", r.ID())
			zalupa.Close()
		}
	})
	s.SetTransportProtocolHandler(udp.ProtocolNumber, f.HandlePacket)
...

misses new packets if the source port is reused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions