Documentation
¶
Overview ¶
Package fdbased provides the implementation 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.
Index ¶
Constants ¶
const BatchSize = 47
BatchSize is the number of packets to write in each syscall. It is 47 because when GVisorGSO is in use then a single 65KB TCP segment can get split into 46 segments of 1420 bytes and a single 216 byte segment.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// FDs is a set of FDs used to read/write packets.
FDs []int
// 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
// PacketDispatchMode specifies the type of inbound dispatcher to be
// used for this endpoint.
PacketDispatchMode PacketDispatchMode
// 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
// If MaxSyscallHeaderBytes is non-zero, it is the maximum number of bytes
// of struct iovec, msghdr, and mmsghdr that may be passed by each host
// system call.
MaxSyscallHeaderBytes int
// InterfaceIndex is the interface index of the underlying device.
InterfaceIndex int
// ProcessorsPerChannel is the number of goroutines used to handle packets
// from each FD.
ProcessorsPerChannel int
MultiPendingPackets bool
SendMsgX bool
}
Options specify the details about the fd-based endpoint to be created.
+stateify savable
type PacketDispatchMode ¶
type PacketDispatchMode int
PacketDispatchMode are the various supported methods of receiving and dispatching packets from the underlying FD.
const ( // Readv is the default dispatch mode and is the least performant of the // dispatch options but the one that is supported by all underlying FD // types. Readv PacketDispatchMode = iota // RecvMMsg enables use of recvmmsg() syscall instead of readv() to // read inbound packets. This reduces # of syscalls needed to process // packets. // // NOTE: recvmmsg() is only supported for sockets, so if the underlying // FD is not a socket then the code will still fall back to the readv() // path. RecvMMsg // PacketMMap enables use of PACKET_RX_RING to receive packets from the // NIC. PacketMMap requires that the underlying FD be an AF_PACKET. The // primary use-case for this is runsc which uses an AF_PACKET FD to // receive packets from the veth device. PacketMMap )
func (PacketDispatchMode) String ¶
func (p PacketDispatchMode) String() string