Version: v0.0.0-...-ba9fc6b Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2020 License: Apache-2.0 Imports: 7 Imported by: 0



Package wintun provides the implemention of data-link layer endpoints backed by boundary-preserving file descriptors (e.g., TUN devices, seqpacket/datagram sockets).

FD based endpoints can be used in the networking stack by calling New() to create a new endpoint, and then passing it as an argument to Stack.CreateNIC().

FD based endpoints can use more than one file descriptor to read incoming packets. If there are more than one FDs specified and the underlying FD is an AF_PACKET then the endpoint will enable FANOUT mode on the socket so that the host kernel will consistently hash the packets to the sockets. This ensures that packets for the same TCP streams are not reordered.

Similarly if more than one FD's are specified where the underlying FD is not AF_PACKET then it's the caller's responsibility to ensure that all inbound packets on the descriptors are consistently 5 tuple hashed to one of the descriptors to prevent TCP reordering.

Since netstack today does not compute 5 tuple hashes for outgoing packets we only use the first FD to write outbound packets. Once 5 tuple hashes for all outbound packets are available we will make use of all underlying FD's to write outbound packets.



This section is empty.


This section is empty.


func New

func New(opts *Options) (stack.LinkEndpoint, error)

New creates a new fd-based endpoint.

Makes fd non-blocking, but does not take ownership of fd, which must remain open for the lifetime of the returned endpoint (until after the endpoint has stopped being using and Wait returns).


type Options

type Options struct {
	// FDs is a set of FDs used to read/write packets.
	FDs io.ReadWriteCloser

	// MTU is the mtu to use for this endpoint.
	MTU uint32

	// EthernetHeader if true, indicates that the endpoint should read/write
	// ethernet frames instead of IP packets.
	EthernetHeader bool

	// ClosedFunc is a function to be called when an endpoint's peer (if
	// any) closes its end of the communication pipe.
	ClosedFunc func(*tcpip.Error)

	// Address is the link address for this endpoint. Only used if
	// EthernetHeader is true.
	Address tcpip.LinkAddress

	// SaveRestore if true, indicates that this NIC capability set should
	// include CapabilitySaveRestore
	SaveRestore bool

	// DisconnectOk if true, indicates that this NIC capability set should
	// include CapabilityDisconnectOk.
	DisconnectOk bool

	// SoftwareGSOEnabled indicates whether software GSO is enabled or not.
	SoftwareGSOEnabled bool

	// TXChecksumOffload if true, indicates that this endpoints capability
	// set should include CapabilityTXChecksumOffload.
	TXChecksumOffload bool

	// RXChecksumOffload if true, indicates that this endpoints capability
	// set should include CapabilityRXChecksumOffload.
	RXChecksumOffload bool

Options specify the details about the fd-based endpoint to be created.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL