tcpip

package
v0.0.0-...-0a9b7a7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0, MIT Imports: 18 Imported by: 478

Documentation

Overview

Package tcpip provides the interfaces and related types that users of the tcpip stack will use in order to create endpoints used to send and receive data over the network stack.

The starting point is the creation and configuration of a stack. A stack can be created by calling the New() function of the tcpip/stack/stack package; configuring a stack involves creating NICs (via calls to Stack.CreateNIC()), adding network addresses (via calls to Stack.AddProtocolAddress()), and setting a route table (via a call to Stack.SetRouteTable()).

Once a stack is configured, endpoints can be created by calling Stack.NewEndpoint(). Such endpoints can be used to send/receive data, connect to peers, listen for connections, accept connections, etc., depending on the transport protocol selected.

Index

Constants

View Source
const (
	// UseDefaultIPv4TTL is the IPv4TTLOption value that configures an endpoint to
	// use the default ttl currently configured by the IPv4 protocol (see
	// DefaultTTLOption).
	UseDefaultIPv4TTL = 0

	// UseDefaultIPv6HopLimit is the IPv6HopLimitOption value that configures an
	// endpoint to use the default hop limit currently configured by the IPv6
	// protocol (see DefaultTTLOption).
	UseDefaultIPv6HopLimit = -1
)
View Source
const (
	// LinkAddressSize is the size of a MAC address.
	LinkAddressSize = 6
)

Variables

View Source
var (
	IPv4Zero = []byte{0, 0, 0, 0}
	IPv6Zero = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
)

Known IP address.

View Source
var AsyncLoading sync.WaitGroup

AsyncLoading is the global barrier for asynchronous endpoint loading activities.

Functions

func AddDanglingEndpoint

func AddDanglingEndpoint(e Endpoint)

AddDanglingEndpoint adds a dangling endpoint.

func DeleteDanglingEndpoint

func DeleteDanglingEndpoint(e Endpoint)

DeleteDanglingEndpoint removes a dangling endpoint.

func InitStatCounters

func InitStatCounters(v reflect.Value)

InitStatCounters initializes v's fields with nil StatCounter fields to new StatCounters.

func ReleaseDanglingEndpoints

func ReleaseDanglingEndpoints()

ReleaseDanglingEndpoints clears out all all reference counted objects held by dangling endpoints.

Types

type ARPStats

type ARPStats struct {

	// PacketsReceived is the number of ARP packets received from the link layer.
	PacketsReceived *StatCounter

	// DisabledPacketsReceived is the number of ARP packets received from the link
	// layer when the ARP layer is disabled.
	DisabledPacketsReceived *StatCounter

	// MalformedPacketsReceived is the number of ARP packets that were dropped due
	// to being malformed.
	MalformedPacketsReceived *StatCounter

	// RequestsReceived is the number of ARP requests received.
	RequestsReceived *StatCounter

	// RequestsReceivedUnknownTargetAddress is the number of ARP requests that
	// were targeted to an interface different from the one it was received on.
	RequestsReceivedUnknownTargetAddress *StatCounter

	// OutgoingRequestInterfaceHasNoLocalAddressErrors is the number of failures
	// to send an ARP request because the interface has no network address
	// assigned to it.
	OutgoingRequestInterfaceHasNoLocalAddressErrors *StatCounter

	// OutgoingRequestBadLocalAddressErrors is the number of failures to send an
	// ARP request with a bad local address.
	OutgoingRequestBadLocalAddressErrors *StatCounter

	// OutgoingRequestsDropped is the number of ARP requests which failed to write
	// to a link-layer endpoint.
	OutgoingRequestsDropped *StatCounter

	// OutgoingRequestSent is the number of ARP requests successfully written to a
	// link-layer endpoint.
	OutgoingRequestsSent *StatCounter

	// RepliesReceived is the number of ARP replies received.
	RepliesReceived *StatCounter

	// OutgoingRepliesDropped is the number of ARP replies which failed to write
	// to a link-layer endpoint.
	OutgoingRepliesDropped *StatCounter

	// OutgoingRepliesSent is the number of ARP replies successfully written to a
	// link-layer endpoint.
	OutgoingRepliesSent *StatCounter
}

ARPStats collects ARP-specific stats.

+stateify savable

type AddMembershipOption

type AddMembershipOption MembershipOption

AddMembershipOption identifies a multicast group to join on some interface.

type Address

type Address struct {
	// contains filtered or unexported fields
}

Address is a byte slice cast as a string that represents the address of a network node. Or, in the case of unix endpoints, it may represent a path.

+stateify savable

func AddrFrom16

func AddrFrom16(addr [16]byte) Address

AddrFrom16 converts addr to an Address.

func AddrFrom16Slice

func AddrFrom16Slice(addr []byte) Address

AddrFrom16Slice converts addr to an Address. It panics if len(addr) != 16.

func AddrFrom4

func AddrFrom4(addr [4]byte) Address

AddrFrom4 converts addr to an Address.

func AddrFrom4Slice

func AddrFrom4Slice(addr []byte) Address

AddrFrom4Slice converts addr to an Address. It panics if len(addr) != 4.

func AddrFromSlice

func AddrFromSlice(addr []byte) Address

AddrFromSlice converts addr to an Address. It returns the Address zero value if len(addr) != 4 or 16.

func (Address) As16

func (a Address) As16() [16]byte

As16 returns a as a 16 byte array. It panics if the address length is not 16.

func (Address) As4

func (a Address) As4() [4]byte

As4 returns a as a 4 byte array. It panics if the address length is not 4.

func (*Address) AsSlice

func (a *Address) AsSlice() []byte

AsSlice returns a as a byte slice. Callers should be careful as it can return a window into existing memory.

+checkescape

func (Address) BitLen

func (a Address) BitLen() int

BitLen returns the length in bits of a.

func (Address) Equal

func (a Address) Equal(other Address) bool

Equal returns whether a and other are equal. It exists for use by the cmp library.

func (Address) Len

func (a Address) Len() int

Len returns the length in bytes of a.

func (Address) MatchingPrefix

func (a Address) MatchingPrefix(b Address) uint8

MatchingPrefix returns the matching prefix length in bits.

Panics if b and a have different lengths.

func (Address) String

func (a Address) String() string

String implements the fmt.Stringer interface.

func (Address) To4

func (a Address) To4() Address

To4 converts the IPv4 address to a 4-byte representation. If the address is not an IPv4 address, To4 returns the empty Address.

func (Address) Unspecified

func (a Address) Unspecified() bool

Unspecified returns true if the address is unspecified.

func (Address) WithPrefix

func (a Address) WithPrefix() AddressWithPrefix

WithPrefix returns the address with a prefix that represents a point subnet.

type AddressMask

type AddressMask struct {
	// contains filtered or unexported fields
}

AddressMask is a bitmask for an address.

+stateify savable

func MaskFrom

func MaskFrom(str string) AddressMask

MaskFrom returns a Mask based on str.

MaskFrom may allocate, and so should not be in hot paths.

func MaskFromBytes

func MaskFromBytes(bs []byte) AddressMask

MaskFromBytes returns a Mask based on bs.

func (*AddressMask) AsSlice

func (m *AddressMask) AsSlice() []byte

AsSlice returns a as a byte slice. Callers should be careful as it can return a window into existing memory.

func (AddressMask) BitLen

func (m AddressMask) BitLen() int

BitLen returns the length of the mask in bits.

func (AddressMask) Equal

func (m AddressMask) Equal(other AddressMask) bool

Equal returns whether m and other are equal. It exists for use by the cmp library.

func (AddressMask) Len

func (m AddressMask) Len() int

Len returns the length of the mask in bytes.

func (AddressMask) Prefix

func (m AddressMask) Prefix() int

Prefix returns the number of bits before the first host bit.

func (AddressMask) String

func (m AddressMask) String() string

String implements Stringer.

type AddressWithPrefix

type AddressWithPrefix struct {
	// Address is a network address.
	Address Address

	// PrefixLen is the subnet prefix length.
	PrefixLen int
}

AddressWithPrefix is an address with its subnet prefix length.

+stateify savable

func (AddressWithPrefix) String

func (a AddressWithPrefix) String() string

String implements the fmt.Stringer interface.

func (AddressWithPrefix) Subnet

func (a AddressWithPrefix) Subnet() Subnet

Subnet converts the address and prefix into a Subnet value and returns it.

type Clock

type Clock interface {
	// Now returns the current local time.
	Now() time.Time

	// NowMonotonic returns the current monotonic clock reading.
	NowMonotonic() MonotonicTime

	// AfterFunc waits for the duration to elapse and then calls f in its own
	// goroutine. It returns a Timer that can be used to cancel the call using
	// its Stop method.
	AfterFunc(d time.Duration, f func()) Timer
}

A Clock provides the current time and schedules work for execution.

Times returned by a Clock should always be used for application-visible time. Only monotonic times should be used for netstack internal timekeeping.

func NewStdClock

func NewStdClock() Clock

NewStdClock returns an instance of a clock that uses the time package.

type CongestionControlOption

type CongestionControlOption string

CongestionControlOption is used by SetSockOpt/GetSockOpt to set/get the current congestion control algorithm.

type CongestionControlState

type CongestionControlState int

CongestionControlState indicates the current congestion control state for TCP sender.

const (
	// Open indicates that the sender is receiving acks in order and
	// no loss or dupACK's etc have been detected.
	Open CongestionControlState = iota
	// RTORecovery indicates that an RTO has occurred and the sender
	// has entered an RTO based recovery phase.
	RTORecovery
	// FastRecovery indicates that the sender has entered FastRecovery
	// based on receiving nDupAck's. This state is entered only when
	// SACK is not in use.
	FastRecovery
	// SACKRecovery indicates that the sender has entered SACK based
	// recovery.
	SACKRecovery
	// Disorder indicates the sender either received some SACK blocks
	// or dupACK's.
	Disorder
)

type DefaultSocketOptionsHandler

type DefaultSocketOptionsHandler struct{}

DefaultSocketOptionsHandler is an embeddable type that implements no-op implementations for SocketOptionsHandler methods.

func (*DefaultSocketOptionsHandler) GetAcceptConn

func (*DefaultSocketOptionsHandler) GetAcceptConn() bool

GetAcceptConn implements SocketOptionsHandler.GetAcceptConn.

func (*DefaultSocketOptionsHandler) HasNIC

HasNIC implements SocketOptionsHandler.HasNIC.

func (*DefaultSocketOptionsHandler) LastError

func (*DefaultSocketOptionsHandler) LastError() Error

LastError implements SocketOptionsHandler.LastError.

func (*DefaultSocketOptionsHandler) OnCorkOptionSet

func (*DefaultSocketOptionsHandler) OnCorkOptionSet(bool)

OnCorkOptionSet implements SocketOptionsHandler.OnCorkOptionSet.

func (*DefaultSocketOptionsHandler) OnDelayOptionSet

func (*DefaultSocketOptionsHandler) OnDelayOptionSet(bool)

OnDelayOptionSet implements SocketOptionsHandler.OnDelayOptionSet.

func (*DefaultSocketOptionsHandler) OnKeepAliveSet

func (*DefaultSocketOptionsHandler) OnKeepAliveSet(bool)

OnKeepAliveSet implements SocketOptionsHandler.OnKeepAliveSet.

func (*DefaultSocketOptionsHandler) OnReuseAddressSet

func (*DefaultSocketOptionsHandler) OnReuseAddressSet(bool)

OnReuseAddressSet implements SocketOptionsHandler.OnReuseAddressSet.

func (*DefaultSocketOptionsHandler) OnReusePortSet

func (*DefaultSocketOptionsHandler) OnReusePortSet(bool)

OnReusePortSet implements SocketOptionsHandler.OnReusePortSet.

func (*DefaultSocketOptionsHandler) OnSetReceiveBufferSize

func (*DefaultSocketOptionsHandler) OnSetReceiveBufferSize(v, oldSz int64) (newSz int64, postSet func())

OnSetReceiveBufferSize implements SocketOptionsHandler.OnSetReceiveBufferSize.

func (*DefaultSocketOptionsHandler) OnSetSendBufferSize

func (*DefaultSocketOptionsHandler) OnSetSendBufferSize(v int64) (newSz int64)

OnSetSendBufferSize implements SocketOptionsHandler.OnSetSendBufferSize.

func (*DefaultSocketOptionsHandler) UpdateLastError

func (*DefaultSocketOptionsHandler) UpdateLastError(Error)

UpdateLastError implements SocketOptionsHandler.UpdateLastError.

func (*DefaultSocketOptionsHandler) WakeupWriters

func (*DefaultSocketOptionsHandler) WakeupWriters()

WakeupWriters implements SocketOptionsHandler.WakeupWriters.

type DefaultTTLOption

type DefaultTTLOption uint8

DefaultTTLOption is used by stack.(*Stack).NetworkProtocolOption to specify a default TTL.

type Endpoint

type Endpoint interface {
	// Close puts the endpoint in a closed state and frees all resources
	// associated with it. Close initiates the teardown process, the
	// Endpoint may not be fully closed when Close returns.
	Close()

	// Abort initiates an expedited endpoint teardown. As compared to
	// Close, Abort prioritizes closing the Endpoint quickly over cleanly.
	// Abort is best effort; implementing Abort with Close is acceptable.
	Abort()

	// Read reads data from the endpoint and optionally writes to dst.
	//
	// This method does not block if there is no data pending; in this case,
	// ErrWouldBlock is returned.
	//
	// If non-zero number of bytes are successfully read and written to dst, err
	// must be nil. Otherwise, if dst failed to write anything, ErrBadBuffer
	// should be returned.
	Read(io.Writer, ReadOptions) (ReadResult, Error)

	// Write writes data to the endpoint's peer. This method does not block if
	// the data cannot be written.
	//
	// Unlike io.Writer.Write, Endpoint.Write transfers ownership of any bytes
	// successfully written to the Endpoint. That is, if a call to
	// Write(SlicePayload{data}) returns (n, err), it may retain data[:n], and
	// the caller should not use data[:n] after Write returns.
	//
	// Note that unlike io.Writer.Write, it is not an error for Write to
	// perform a partial write (if n > 0, no error may be returned). Only
	// stream (TCP) Endpoints may return partial writes, and even then only
	// in the case where writing additional data would block. Other Endpoints
	// will either write the entire message or return an error.
	Write(Payloader, WriteOptions) (int64, Error)

	// Connect connects the endpoint to its peer. Specifying a NIC is
	// optional.
	//
	// There are three classes of return values:
	//	nil -- the attempt to connect succeeded.
	//	ErrConnectStarted/ErrAlreadyConnecting -- the connect attempt started
	//		but hasn't completed yet. In this case, the caller must call Connect
	//		or GetSockOpt(ErrorOption) when the endpoint becomes writable to
	//		get the actual result. The first call to Connect after the socket has
	//		connected returns nil. Calling connect again results in ErrAlreadyConnected.
	//	Anything else -- the attempt to connect failed.
	//
	// If address.Addr is empty, this means that Endpoint has to be
	// disconnected if this is supported, otherwise
	// ErrAddressFamilyNotSupported must be returned.
	Connect(address FullAddress) Error

	// Disconnect disconnects the endpoint from its peer.
	Disconnect() Error

	// Shutdown closes the read and/or write end of the endpoint connection
	// to its peer.
	Shutdown(flags ShutdownFlags) Error

	// Listen puts the endpoint in "listen" mode, which allows it to accept
	// new connections.
	Listen(backlog int) Error

	// Accept returns a new endpoint if a peer has established a connection
	// to an endpoint previously set to listen mode. This method does not
	// block if no new connections are available.
	//
	// The returned Queue is the wait queue for the newly created endpoint.
	//
	// If peerAddr is not nil then it is populated with the peer address of the
	// returned endpoint.
	Accept(peerAddr *FullAddress) (Endpoint, *waiter.Queue, Error)

	// Bind binds the endpoint to a specific local address and port.
	// Specifying a NIC is optional.
	Bind(address FullAddress) Error

	// GetLocalAddress returns the address to which the endpoint is bound.
	GetLocalAddress() (FullAddress, Error)

	// GetRemoteAddress returns the address to which the endpoint is
	// connected.
	GetRemoteAddress() (FullAddress, Error)

	// Readiness returns the current readiness of the endpoint. For example,
	// if waiter.EventIn is set, the endpoint is immediately readable.
	Readiness(mask waiter.EventMask) waiter.EventMask

	// SetSockOpt sets a socket option.
	SetSockOpt(opt SettableSocketOption) Error

	// SetSockOptInt sets a socket option, for simple cases where a value
	// has the int type.
	SetSockOptInt(opt SockOptInt, v int) Error

	// GetSockOpt gets a socket option.
	GetSockOpt(opt GettableSocketOption) Error

	// GetSockOptInt gets a socket option for simple cases where a return
	// value has the int type.
	GetSockOptInt(SockOptInt) (int, Error)

	// State returns a socket's lifecycle state. The returned value is
	// protocol-specific and is primarily used for diagnostics.
	State() uint32

	// ModerateRecvBuf should be called everytime data is copied to the user
	// space. This allows for dynamic tuning of recv buffer space for a
	// given socket.
	//
	// NOTE: This method is a no-op for sockets other than TCP.
	ModerateRecvBuf(copied int)

	// Info returns a copy to the transport endpoint info.
	Info() EndpointInfo

	// Stats returns a reference to the endpoint stats.
	Stats() EndpointStats

	// SetOwner sets the task owner to the endpoint owner.
	SetOwner(owner PacketOwner)

	// LastError clears and returns the last error reported by the endpoint.
	LastError() Error

	// SocketOptions returns the structure which contains all the socket
	// level options.
	SocketOptions() *SocketOptions
}

Endpoint is the interface implemented by transport protocols (e.g., tcp, udp) that exposes functionality like read, write, connect, etc. to users of the networking stack.

func GetDanglingEndpoints

func GetDanglingEndpoints() []Endpoint

GetDanglingEndpoints returns all dangling endpoints.

type EndpointInfo

type EndpointInfo interface {
	// IsEndpointInfo is an empty method to implement the tcpip.EndpointInfo
	// marker interface.
	IsEndpointInfo()
}

EndpointInfo is the interface implemented by each endpoint info struct.

type EndpointState

type EndpointState uint8

EndpointState represents the state of an endpoint.

type EndpointStats

type EndpointStats interface {
	// IsEndpointStats is an empty method to implement the tcpip.EndpointStats
	// marker interface.
	IsEndpointStats()
}

EndpointStats is the interface implemented by each endpoint stats struct.

type EndpointWithPreflight

type EndpointWithPreflight interface {
	// Prepares the endpoint for writes using the provided WriteOptions,
	// returning an error if the options were incompatible with the endpoint's
	// current state.
	Preflight(WriteOptions) Error
}

EndpointWithPreflight is the interface implemented by endpoints that need to expose the `Preflight` method for preparing the endpoint prior to calling `Write`.

type ErrAborted

type ErrAborted struct{}

ErrAborted indicates the operation was aborted.

+stateify savable

func (*ErrAborted) IgnoreStats

func (*ErrAborted) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrAborted) String

func (*ErrAborted) String() string

type ErrAddressFamilyNotSupported

type ErrAddressFamilyNotSupported struct{}

ErrAddressFamilyNotSupported indicates the operation does not support the given address family.

+stateify savable

func (*ErrAddressFamilyNotSupported) IgnoreStats

func (*ErrAddressFamilyNotSupported) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrAddressFamilyNotSupported) String

type ErrAlreadyBound

type ErrAlreadyBound struct{}

ErrAlreadyBound indicates the endpoint is already bound.

+stateify savable

func (*ErrAlreadyBound) IgnoreStats

func (*ErrAlreadyBound) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrAlreadyBound) String

func (*ErrAlreadyBound) String() string

type ErrAlreadyConnected

type ErrAlreadyConnected struct{}

ErrAlreadyConnected indicates the endpoint is already connected.

+stateify savable

func (*ErrAlreadyConnected) IgnoreStats

func (*ErrAlreadyConnected) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrAlreadyConnected) String

func (*ErrAlreadyConnected) String() string

type ErrAlreadyConnecting

type ErrAlreadyConnecting struct{}

ErrAlreadyConnecting indicates the endpoint is already connecting.

+stateify savable

func (*ErrAlreadyConnecting) IgnoreStats

func (*ErrAlreadyConnecting) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrAlreadyConnecting) String

func (*ErrAlreadyConnecting) String() string

type ErrBadAddress

type ErrBadAddress struct{}

ErrBadAddress indicates a bad address was provided.

+stateify savable

func (*ErrBadAddress) IgnoreStats

func (*ErrBadAddress) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrBadAddress) String

func (*ErrBadAddress) String() string

type ErrBadBuffer

type ErrBadBuffer struct{}

ErrBadBuffer indicates a bad buffer was provided.

+stateify savable

func (*ErrBadBuffer) IgnoreStats

func (*ErrBadBuffer) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrBadBuffer) String

func (*ErrBadBuffer) String() string

type ErrBadLocalAddress

type ErrBadLocalAddress struct{}

ErrBadLocalAddress indicates a bad local address was provided.

+stateify savable

func (*ErrBadLocalAddress) IgnoreStats

func (*ErrBadLocalAddress) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrBadLocalAddress) String

func (*ErrBadLocalAddress) String() string

type ErrBroadcastDisabled

type ErrBroadcastDisabled struct{}

ErrBroadcastDisabled indicates broadcast is not enabled on the endpoint.

+stateify savable

func (*ErrBroadcastDisabled) IgnoreStats

func (*ErrBroadcastDisabled) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrBroadcastDisabled) String

func (*ErrBroadcastDisabled) String() string

type ErrClosedForReceive

type ErrClosedForReceive struct{}

ErrClosedForReceive indicates the endpoint is closed for incoming data.

+stateify savable

func (*ErrClosedForReceive) IgnoreStats

func (*ErrClosedForReceive) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrClosedForReceive) String

func (*ErrClosedForReceive) String() string

type ErrClosedForSend

type ErrClosedForSend struct{}

ErrClosedForSend indicates the endpoint is closed for outgoing data.

+stateify savable

func (*ErrClosedForSend) IgnoreStats

func (*ErrClosedForSend) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrClosedForSend) String

func (*ErrClosedForSend) String() string

type ErrConnectStarted

type ErrConnectStarted struct{}

ErrConnectStarted indicates the endpoint is connecting asynchronously.

+stateify savable

func (*ErrConnectStarted) IgnoreStats

func (*ErrConnectStarted) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrConnectStarted) String

func (*ErrConnectStarted) String() string

type ErrConnectionAborted

type ErrConnectionAborted struct{}

ErrConnectionAborted indicates the connection was aborted.

+stateify savable

func (*ErrConnectionAborted) IgnoreStats

func (*ErrConnectionAborted) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrConnectionAborted) String

func (*ErrConnectionAborted) String() string

type ErrConnectionRefused

type ErrConnectionRefused struct{}

ErrConnectionRefused indicates the connection was refused.

+stateify savable

func (*ErrConnectionRefused) IgnoreStats

func (*ErrConnectionRefused) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrConnectionRefused) String

func (*ErrConnectionRefused) String() string

type ErrConnectionReset

type ErrConnectionReset struct{}

ErrConnectionReset indicates the connection was reset.

+stateify savable

func (*ErrConnectionReset) IgnoreStats

func (*ErrConnectionReset) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrConnectionReset) String

func (*ErrConnectionReset) String() string

type ErrDestinationRequired

type ErrDestinationRequired struct{}

ErrDestinationRequired indicates the operation requires a destination address, and one was not provided.

+stateify savable

func (*ErrDestinationRequired) IgnoreStats

func (*ErrDestinationRequired) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrDestinationRequired) String

func (*ErrDestinationRequired) String() string

type ErrDuplicateAddress

type ErrDuplicateAddress struct{}

ErrDuplicateAddress indicates the operation encountered a duplicate address.

+stateify savable

func (*ErrDuplicateAddress) IgnoreStats

func (*ErrDuplicateAddress) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrDuplicateAddress) String

func (*ErrDuplicateAddress) String() string

type ErrDuplicateNICID

type ErrDuplicateNICID struct{}

ErrDuplicateNICID indicates the operation encountered a duplicate NIC ID.

+stateify savable

func (*ErrDuplicateNICID) IgnoreStats

func (*ErrDuplicateNICID) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrDuplicateNICID) String

func (*ErrDuplicateNICID) String() string

type ErrHostDown

type ErrHostDown struct{}

ErrHostDown indicates that a destination host is down.

+stateify savable

func (*ErrHostDown) IgnoreStats

func (*ErrHostDown) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrHostDown) String

func (*ErrHostDown) String() string

type ErrHostUnreachable

type ErrHostUnreachable struct{}

ErrHostUnreachable indicates that a destination host could not be reached.

+stateify savable

func (*ErrHostUnreachable) IgnoreStats

func (*ErrHostUnreachable) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrHostUnreachable) String

func (*ErrHostUnreachable) String() string

type ErrInvalidEndpointState

type ErrInvalidEndpointState struct{}

ErrInvalidEndpointState indicates the endpoint is in an invalid state.

+stateify savable

func (*ErrInvalidEndpointState) IgnoreStats

func (*ErrInvalidEndpointState) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrInvalidEndpointState) String

func (*ErrInvalidEndpointState) String() string

type ErrInvalidNICID

type ErrInvalidNICID struct{}

ErrInvalidNICID indicates the operation used an invalid NIC ID.

+stateify savable

func (*ErrInvalidNICID) IgnoreStats

func (*ErrInvalidNICID) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrInvalidNICID) String

func (*ErrInvalidNICID) String() string

type ErrInvalidOptionValue

type ErrInvalidOptionValue struct{}

ErrInvalidOptionValue indicates an invalid option value was provided.

+stateify savable

func (*ErrInvalidOptionValue) IgnoreStats

func (*ErrInvalidOptionValue) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrInvalidOptionValue) String

func (*ErrInvalidOptionValue) String() string

type ErrInvalidPortRange

type ErrInvalidPortRange struct{}

ErrInvalidPortRange indicates an attempt to set an invalid port range.

+stateify savable

func (*ErrInvalidPortRange) IgnoreStats

func (*ErrInvalidPortRange) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrInvalidPortRange) String

func (*ErrInvalidPortRange) String() string

type ErrMalformedHeader

type ErrMalformedHeader struct{}

ErrMalformedHeader indicates the operation encountered a malformed header.

+stateify savable

func (*ErrMalformedHeader) IgnoreStats

func (*ErrMalformedHeader) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrMalformedHeader) String

func (*ErrMalformedHeader) String() string

type ErrMessageTooLong

type ErrMessageTooLong struct{}

ErrMessageTooLong indicates the operation encountered a message whose length exceeds the maximum permitted.

+stateify savable

func (*ErrMessageTooLong) IgnoreStats

func (*ErrMessageTooLong) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrMessageTooLong) String

func (*ErrMessageTooLong) String() string

type ErrMissingRequiredFields

type ErrMissingRequiredFields struct{}

ErrMissingRequiredFields indicates that a required field is missing.

+stateify savable

func (*ErrMissingRequiredFields) IgnoreStats

func (*ErrMissingRequiredFields) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrMissingRequiredFields) String

func (*ErrMissingRequiredFields) String() string

type ErrMulticastInputCannotBeOutput

type ErrMulticastInputCannotBeOutput struct{}

ErrMulticastInputCannotBeOutput indicates that an input interface matches an output interface in the same multicast route.

+stateify savable

func (*ErrMulticastInputCannotBeOutput) IgnoreStats

func (*ErrMulticastInputCannotBeOutput) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrMulticastInputCannotBeOutput) String

type ErrNetworkUnreachable

type ErrNetworkUnreachable struct{}

ErrNetworkUnreachable indicates the operation is not able to reach the destination network.

+stateify savable

func (*ErrNetworkUnreachable) IgnoreStats

func (*ErrNetworkUnreachable) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrNetworkUnreachable) String

func (*ErrNetworkUnreachable) String() string

type ErrNoBufferSpace

type ErrNoBufferSpace struct{}

ErrNoBufferSpace indicates no buffer space is available.

+stateify savable

func (*ErrNoBufferSpace) IgnoreStats

func (*ErrNoBufferSpace) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrNoBufferSpace) String

func (*ErrNoBufferSpace) String() string

type ErrNoNet

type ErrNoNet struct{}

ErrNoNet indicates that the host is not on the network.

+stateify savable

func (*ErrNoNet) IgnoreStats

func (*ErrNoNet) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrNoNet) String

func (*ErrNoNet) String() string

type ErrNoPortAvailable

type ErrNoPortAvailable struct{}

ErrNoPortAvailable indicates no port could be allocated for the operation.

+stateify savable

func (*ErrNoPortAvailable) IgnoreStats

func (*ErrNoPortAvailable) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrNoPortAvailable) String

func (*ErrNoPortAvailable) String() string

type ErrNoSuchFile

type ErrNoSuchFile struct{}

ErrNoSuchFile is used to indicate that ENOENT should be returned the to calling application.

+stateify savable

func (*ErrNoSuchFile) IgnoreStats

func (*ErrNoSuchFile) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrNoSuchFile) String

func (*ErrNoSuchFile) String() string

type ErrNotConnected

type ErrNotConnected struct{}

ErrNotConnected indicates the endpoint is not connected.

+stateify savable

func (*ErrNotConnected) IgnoreStats

func (*ErrNotConnected) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrNotConnected) String

func (*ErrNotConnected) String() string

type ErrNotPermitted

type ErrNotPermitted struct{}

ErrNotPermitted indicates the operation is not permitted.

+stateify savable

func (*ErrNotPermitted) IgnoreStats

func (*ErrNotPermitted) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrNotPermitted) String

func (*ErrNotPermitted) String() string

type ErrNotSupported

type ErrNotSupported struct{}

ErrNotSupported indicates the operation is not supported.

+stateify savable

func (*ErrNotSupported) IgnoreStats

func (*ErrNotSupported) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrNotSupported) String

func (*ErrNotSupported) String() string

type ErrPortInUse

type ErrPortInUse struct{}

ErrPortInUse indicates the provided port is in use.

+stateify savable

func (*ErrPortInUse) IgnoreStats

func (*ErrPortInUse) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrPortInUse) String

func (*ErrPortInUse) String() string

type ErrQueueSizeNotSupported

type ErrQueueSizeNotSupported struct{}

ErrQueueSizeNotSupported indicates the endpoint does not allow queue size operation.

+stateify savable

func (*ErrQueueSizeNotSupported) IgnoreStats

func (*ErrQueueSizeNotSupported) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrQueueSizeNotSupported) String

func (*ErrQueueSizeNotSupported) String() string

type ErrSaveRejection

type ErrSaveRejection struct {
	Err error
}

ErrSaveRejection indicates a failed save due to unsupported networking state. This type of errors is only used for save logic.

func (*ErrSaveRejection) Error

func (e *ErrSaveRejection) Error() string

Error returns a sensible description of the save rejection error.

type ErrTimeout

type ErrTimeout struct{}

ErrTimeout indicates the operation timed out.

+stateify savable

func (*ErrTimeout) IgnoreStats

func (*ErrTimeout) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrTimeout) String

func (*ErrTimeout) String() string

type ErrUnknownDevice

type ErrUnknownDevice struct{}

ErrUnknownDevice indicates an unknown device identifier was provided.

+stateify savable

func (*ErrUnknownDevice) IgnoreStats

func (*ErrUnknownDevice) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrUnknownDevice) String

func (*ErrUnknownDevice) String() string

type ErrUnknownNICID

type ErrUnknownNICID struct{}

ErrUnknownNICID indicates an unknown NIC ID was provided.

+stateify savable

func (*ErrUnknownNICID) IgnoreStats

func (*ErrUnknownNICID) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrUnknownNICID) String

func (*ErrUnknownNICID) String() string

type ErrUnknownProtocol

type ErrUnknownProtocol struct{}

ErrUnknownProtocol indicates an unknown protocol was requested.

+stateify savable

func (*ErrUnknownProtocol) IgnoreStats

func (*ErrUnknownProtocol) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrUnknownProtocol) String

func (*ErrUnknownProtocol) String() string

type ErrUnknownProtocolOption

type ErrUnknownProtocolOption struct{}

ErrUnknownProtocolOption indicates an unknown protocol option was provided.

+stateify savable

func (*ErrUnknownProtocolOption) IgnoreStats

func (*ErrUnknownProtocolOption) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrUnknownProtocolOption) String

func (*ErrUnknownProtocolOption) String() string

type ErrWouldBlock

type ErrWouldBlock struct{}

ErrWouldBlock indicates the operation would block.

+stateify savable

func (*ErrWouldBlock) IgnoreStats

func (*ErrWouldBlock) IgnoreStats() bool

IgnoreStats implements Error.

func (*ErrWouldBlock) String

func (*ErrWouldBlock) String() string

type Error

type Error interface {

	// IgnoreStats indicates whether this error should be included in failure
	// counts in tcpip.Stats structs.
	IgnoreStats() bool

	fmt.Stringer
	// contains filtered or unexported methods
}

Error represents an error in the netstack error space.

The error interface is intentionally omitted to avoid loss of type information that would occur if these errors were passed as error.

func TranslateErrno

func TranslateErrno(e unix.Errno) Error

TranslateErrno translate an errno from the syscall package into a tcpip Error.

Valid, but unrecognized errnos will be translated to *ErrInvalidEndpointState (EINVAL). This includes the "zero" value.

type FullAddress

type FullAddress struct {
	// NIC is the ID of the NIC this address refers to.
	//
	// This may not be used by all endpoint types.
	NIC NICID

	// Addr is the network address.
	Addr Address

	// Port is the transport port.
	//
	// This may not be used by all endpoint types.
	Port uint16

	// LinkAddr is the link layer address.
	LinkAddr LinkAddress
}

FullAddress represents a full transport node address, as required by the Connect() and Bind() methods.

+stateify savable

type GetReceiveBufferLimits

type GetReceiveBufferLimits func(StackHandler) ReceiveBufferSizeOption

GetReceiveBufferLimits is used to get the send buffer size limits.

type GetSendBufferLimits

type GetSendBufferLimits func(StackHandler) SendBufferSizeOption

GetSendBufferLimits is used to get the send buffer size limits.

type GettableNetworkProtocolOption

type GettableNetworkProtocolOption interface {
	// contains filtered or unexported methods
}

GettableNetworkProtocolOption is a marker interface for network protocol options that may be queried.

type GettableSocketOption

type GettableSocketOption interface {
	// contains filtered or unexported methods
}

GettableSocketOption is a marker interface for socket options that may be queried.

type GettableTransportProtocolOption

type GettableTransportProtocolOption interface {
	// contains filtered or unexported methods
}

GettableTransportProtocolOption is a marker interface for transport protocol options that may be queried.

type ICMPStats

type ICMPStats struct {
	// V4 contains the ICMPv4-specifics stats.
	V4 ICMPv4Stats

	// V6 contains the ICMPv4-specifics stats.
	V6 ICMPv6Stats
}

ICMPStats collects ICMP-specific stats (both v4 and v6).

+stateify savable

type ICMPv4PacketStats

type ICMPv4PacketStats struct {

	// EchoRequest is the number of ICMPv4 echo packets counted.
	EchoRequest *StatCounter

	// EchoReply is the number of ICMPv4 echo reply packets counted.
	EchoReply *StatCounter

	// DstUnreachable is the number of ICMPv4 destination unreachable packets
	// counted.
	DstUnreachable *StatCounter

	// SrcQuench is the number of ICMPv4 source quench packets counted.
	SrcQuench *StatCounter

	// Redirect is the number of ICMPv4 redirect packets counted.
	Redirect *StatCounter

	// TimeExceeded is the number of ICMPv4 time exceeded packets counted.
	TimeExceeded *StatCounter

	// ParamProblem is the number of ICMPv4 parameter problem packets counted.
	ParamProblem *StatCounter

	// Timestamp is the number of ICMPv4 timestamp packets counted.
	Timestamp *StatCounter

	// TimestampReply is the number of ICMPv4 timestamp reply packets counted.
	TimestampReply *StatCounter

	// InfoRequest is the number of ICMPv4 information request packets counted.
	InfoRequest *StatCounter

	// InfoReply is the number of ICMPv4 information reply packets counted.
	InfoReply *StatCounter
}

ICMPv4PacketStats enumerates counts for all ICMPv4 packet types.

+stateify savable

type ICMPv4ReceivedPacketStats

type ICMPv4ReceivedPacketStats struct {
	ICMPv4PacketStats

	// Invalid is the number of invalid ICMPv4 packets received.
	Invalid *StatCounter
}

ICMPv4ReceivedPacketStats collects inbound ICMPv4-specific stats.

+stateify savable

type ICMPv4SentPacketStats

type ICMPv4SentPacketStats struct {
	ICMPv4PacketStats

	// Dropped is the number of ICMPv4 packets dropped due to link layer errors.
	Dropped *StatCounter

	// RateLimited is the number of ICMPv4 packets dropped due to rate limit being
	// exceeded.
	RateLimited *StatCounter
}

ICMPv4SentPacketStats collects outbound ICMPv4-specific stats.

+stateify savable

type ICMPv4Stats

type ICMPv4Stats struct {

	// PacketsSent contains statistics about sent packets.
	PacketsSent ICMPv4SentPacketStats

	// PacketsReceived contains statistics about received packets.
	PacketsReceived ICMPv4ReceivedPacketStats
}

ICMPv4Stats collects ICMPv4-specific stats.

+stateify savable

type ICMPv6Filter

type ICMPv6Filter struct {
	// DenyType indicates if an ICMP type should be blocked.
	//
	// The ICMPv6 type field is 8 bits so there are up to 256 different ICMPv6
	// types.
	DenyType [8]uint32
}

ICMPv6Filter specifies a filter for ICMPv6 types.

+stateify savable

func (*ICMPv6Filter) ShouldDeny

func (f *ICMPv6Filter) ShouldDeny(icmpType uint8) bool

ShouldDeny returns true iff the ICMPv6 Type should be denied.

type ICMPv6PacketStats

type ICMPv6PacketStats struct {

	// EchoRequest is the number of ICMPv6 echo request packets counted.
	EchoRequest *StatCounter

	// EchoReply is the number of ICMPv6 echo reply packets counted.
	EchoReply *StatCounter

	// DstUnreachable is the number of ICMPv6 destination unreachable packets
	// counted.
	DstUnreachable *StatCounter

	// PacketTooBig is the number of ICMPv6 packet too big packets counted.
	PacketTooBig *StatCounter

	// TimeExceeded is the number of ICMPv6 time exceeded packets counted.
	TimeExceeded *StatCounter

	// ParamProblem is the number of ICMPv6 parameter problem packets counted.
	ParamProblem *StatCounter

	// RouterSolicit is the number of ICMPv6 router solicit packets counted.
	RouterSolicit *StatCounter

	// RouterAdvert is the number of ICMPv6 router advert packets counted.
	RouterAdvert *StatCounter

	// NeighborSolicit is the number of ICMPv6 neighbor solicit packets counted.
	NeighborSolicit *StatCounter

	// NeighborAdvert is the number of ICMPv6 neighbor advert packets counted.
	NeighborAdvert *StatCounter

	// RedirectMsg is the number of ICMPv6 redirect message packets counted.
	RedirectMsg *StatCounter

	// MulticastListenerQuery is the number of Multicast Listener Query messages
	// counted.
	MulticastListenerQuery *StatCounter

	// MulticastListenerReport is the number of Multicast Listener Report messages
	// counted.
	MulticastListenerReport *StatCounter

	// MulticastListenerReportV2 is the number of Multicast Listener Report
	// messages counted.
	MulticastListenerReportV2 *StatCounter

	// MulticastListenerDone is the number of Multicast Listener Done messages
	// counted.
	MulticastListenerDone *StatCounter
}

ICMPv6PacketStats enumerates counts for all ICMPv6 packet types.

+stateify savable

type ICMPv6ReceivedPacketStats

type ICMPv6ReceivedPacketStats struct {
	ICMPv6PacketStats

	// Unrecognized is the number of ICMPv6 packets received that the transport
	// layer does not know how to parse.
	Unrecognized *StatCounter

	// Invalid is the number of invalid ICMPv6 packets received.
	Invalid *StatCounter

	// RouterOnlyPacketsDroppedByHost is the number of ICMPv6 packets dropped due
	// to being router-specific packets.
	RouterOnlyPacketsDroppedByHost *StatCounter
}

ICMPv6ReceivedPacketStats collects inbound ICMPv6-specific stats.

+stateify savable

type ICMPv6SentPacketStats

type ICMPv6SentPacketStats struct {
	ICMPv6PacketStats

	// Dropped is the number of ICMPv6 packets dropped due to link layer errors.
	Dropped *StatCounter

	// RateLimited is the number of ICMPv6 packets dropped due to rate limit being
	// exceeded.
	RateLimited *StatCounter
}

ICMPv6SentPacketStats collects outbound ICMPv6-specific stats.

+stateify savable

type ICMPv6Stats

type ICMPv6Stats struct {

	// PacketsSent contains statistics about sent packets.
	PacketsSent ICMPv6SentPacketStats

	// PacketsReceived contains statistics about received packets.
	PacketsReceived ICMPv6ReceivedPacketStats
}

ICMPv6Stats collects ICMPv6-specific stats.

+stateify savable

type IGMPPacketStats

type IGMPPacketStats struct {

	// MembershipQuery is the number of Membership Query messages counted.
	MembershipQuery *StatCounter

	// V1MembershipReport is the number of Version 1 Membership Report messages
	// counted.
	V1MembershipReport *StatCounter

	// V2MembershipReport is the number of Version 2 Membership Report messages
	// counted.
	V2MembershipReport *StatCounter

	// V3MembershipReport is the number of Version 3 Membership Report messages
	// counted.
	V3MembershipReport *StatCounter

	// LeaveGroup is the number of Leave Group messages counted.
	LeaveGroup *StatCounter
}

IGMPPacketStats enumerates counts for all IGMP packet types.

+stateify savable

type IGMPReceivedPacketStats

type IGMPReceivedPacketStats struct {
	IGMPPacketStats

	// Invalid is the number of invalid IGMP packets received.
	Invalid *StatCounter

	// ChecksumErrors is the number of IGMP packets dropped due to bad checksums.
	ChecksumErrors *StatCounter

	// Unrecognized is the number of unrecognized messages counted, these are
	// silently ignored for forward-compatibility.
	Unrecognized *StatCounter
}

IGMPReceivedPacketStats collects inbound IGMP-specific stats.

+stateify savable

type IGMPSentPacketStats

type IGMPSentPacketStats struct {
	IGMPPacketStats

	// Dropped is the number of IGMP packets dropped.
	Dropped *StatCounter
}

IGMPSentPacketStats collects outbound IGMP-specific stats.

+stateify savable

type IGMPStats

type IGMPStats struct {

	// PacketsSent contains statistics about sent packets.
	PacketsSent IGMPSentPacketStats

	// PacketsReceived contains statistics about received packets.
	PacketsReceived IGMPReceivedPacketStats
}

IGMPStats collects IGMP-specific stats.

+stateify savable

type IPForwardingStats

type IPForwardingStats struct {

	// Unrouteable is the number of IP packets received which were dropped
	// because a route to their destination could not be constructed.
	Unrouteable *StatCounter

	// ExhaustedTTL is the number of IP packets received which were dropped
	// because their TTL was exhausted.
	ExhaustedTTL *StatCounter

	// InitializingSource is the number of IP packets which were dropped
	// because they contained a source address that may only be used on the local
	// network as part of initialization work.
	InitializingSource *StatCounter

	// LinkLocalSource is the number of IP packets which were dropped
	// because they contained a link-local source address.
	LinkLocalSource *StatCounter

	// LinkLocalDestination is the number of IP packets which were dropped
	// because they contained a link-local destination address.
	LinkLocalDestination *StatCounter

	// PacketTooBig is the number of IP packets which were dropped because they
	// were too big for the outgoing MTU.
	PacketTooBig *StatCounter

	// HostUnreachable is the number of IP packets received which could not be
	// successfully forwarded due to an unresolvable next hop.
	HostUnreachable *StatCounter

	// ExtensionHeaderProblem is the number of IP packets which were dropped
	// because of a problem encountered when processing an IPv6 extension
	// header.
	ExtensionHeaderProblem *StatCounter

	// UnexpectedMulticastInputInterface is the number of multicast packets that
	// were received on an interface that did not match the corresponding route's
	// expected input interface.
	UnexpectedMulticastInputInterface *StatCounter

	// UnknownOutputEndpoint is the number of packets that could not be forwarded
	// because the output endpoint could not be found.
	UnknownOutputEndpoint *StatCounter

	// NoMulticastPendingQueueBufferSpace is the number of multicast packets that
	// were dropped due to insufficient buffer space in the pending packet queue.
	NoMulticastPendingQueueBufferSpace *StatCounter

	// OutgoingDeviceNoBufferSpace is the number of packets that were dropped due
	// to insufficient space in the outgoing device.
	OutgoingDeviceNoBufferSpace *StatCounter

	// Errors is the number of IP packets received which could not be
	// successfully forwarded.
	Errors *StatCounter

	// OutgoingDeviceClosedForSend is the number of packets that were dropped due
	// to the outgoing device being closed for send.
	OutgoingDeviceClosedForSend *StatCounter
}

IPForwardingStats collects stats related to IP forwarding (both v4 and v6).

+stateify savable

type IPPacketInfo

type IPPacketInfo struct {
	// NIC is the ID of the NIC to be used.
	NIC NICID

	// LocalAddr is the local address.
	LocalAddr Address

	// DestinationAddr is the destination address found in the IP header.
	DestinationAddr Address
}

IPPacketInfo is the message structure for IP_PKTINFO.

+stateify savable

type IPStats

type IPStats struct {

	// PacketsReceived is the number of IP packets received from the link layer.
	PacketsReceived *StatCounter

	// ValidPacketsReceived is the number of valid IP packets that reached the IP
	// layer.
	ValidPacketsReceived *StatCounter

	// DisabledPacketsReceived is the number of IP packets received from the link
	// layer when the IP layer is disabled.
	DisabledPacketsReceived *StatCounter

	// InvalidDestinationAddressesReceived is the number of IP packets received
	// with an unknown or invalid destination address.
	InvalidDestinationAddressesReceived *StatCounter

	// InvalidSourceAddressesReceived is the number of IP packets received with a
	// source address that should never have been received on the wire.
	InvalidSourceAddressesReceived *StatCounter

	// PacketsDelivered is the number of incoming IP packets that are successfully
	// delivered to the transport layer.
	PacketsDelivered *StatCounter

	// PacketsSent is the number of IP packets sent via WritePacket.
	PacketsSent *StatCounter

	// OutgoingPacketErrors is the number of IP packets which failed to write to a
	// link-layer endpoint.
	OutgoingPacketErrors *StatCounter

	// MalformedPacketsReceived is the number of IP Packets that were dropped due
	// to the IP packet header failing validation checks.
	MalformedPacketsReceived *StatCounter

	// MalformedFragmentsReceived is the number of IP Fragments that were dropped
	// due to the fragment failing validation checks.
	MalformedFragmentsReceived *StatCounter

	// IPTablesPreroutingDropped is the number of IP packets dropped in the
	// Prerouting chain.
	IPTablesPreroutingDropped *StatCounter

	// IPTablesInputDropped is the number of IP packets dropped in the Input
	// chain.
	IPTablesInputDropped *StatCounter

	// IPTablesForwardDropped is the number of IP packets dropped in the Forward
	// chain.
	IPTablesForwardDropped *StatCounter

	// IPTablesOutputDropped is the number of IP packets dropped in the Output
	// chain.
	IPTablesOutputDropped *StatCounter

	// IPTablesPostroutingDropped is the number of IP packets dropped in the
	// Postrouting chain.
	IPTablesPostroutingDropped *StatCounter

	// TODO(https://gvisor.dev/issues/5529): Move the IPv4-only option stats out
	// of IPStats.
	// OptionTimestampReceived is the number of Timestamp options seen.
	OptionTimestampReceived *StatCounter

	// OptionRecordRouteReceived is the number of Record Route options seen.
	OptionRecordRouteReceived *StatCounter

	// OptionRouterAlertReceived is the number of Router Alert options seen.
	OptionRouterAlertReceived *StatCounter

	// OptionUnknownReceived is the number of unknown IP options seen.
	OptionUnknownReceived *StatCounter

	// Forwarding collects stats related to IP forwarding.
	Forwarding IPForwardingStats
}

IPStats collects IP-specific stats (both v4 and v6).

+stateify savable

type IPv6PacketInfo

type IPv6PacketInfo struct {
	Addr Address
	NIC  NICID
}

IPv6PacketInfo is the message structure for IPV6_PKTINFO.

+stateify savable

type IntegralStatCounterMap

type IntegralStatCounterMap struct {
	// contains filtered or unexported fields
}

IntegralStatCounterMap holds a map associating integral keys with StatCounters.

+stateify savable

func (*IntegralStatCounterMap) Get

Get returns the counter mapped by the provided key.

func (*IntegralStatCounterMap) Increment

func (m *IntegralStatCounterMap) Increment(key uint64)

Increment increments the counter associated with the provided key.

func (*IntegralStatCounterMap) Init

func (m *IntegralStatCounterMap) Init()

Init initializes the map.

func (*IntegralStatCounterMap) Keys

func (m *IntegralStatCounterMap) Keys() []uint64

Keys returns all keys present in the map.

type Job

type Job struct {
	// contains filtered or unexported fields
}

Job represents some work that can be scheduled for execution. The work can be safely cancelled when it fires at the same time some "related work" is being done.

The term "related work" is defined as some work that needs to be done while holding some lock that the timer must also hold while doing some work.

Note, it is not safe to copy a Job as its timer instance creates a closure over the address of the Job.

+stateify savable

func NewJob

func NewJob(c Clock, l sync.Locker, f func()) *Job

NewJob returns a new Job that can be used to schedule f to run in its own gorountine. l will be locked before calling f then unlocked after f returns.

var clock tcpip.StdClock
var mu sync.Mutex
message := "foo"
job := tcpip.NewJob(&clock, &mu, func() {
  fmt.Println(message)
})
job.Schedule(time.Second)

mu.Lock()
message = "bar"
mu.Unlock()

// Output: bar

f MUST NOT attempt to lock l.

l MUST be locked prior to calling the returned job's Cancel().

var clock tcpip.StdClock
var mu sync.Mutex
message := "foo"
job := tcpip.NewJob(&clock, &mu, func() {
  fmt.Println(message)
})
job.Schedule(time.Second)

mu.Lock()
job.Cancel()
mu.Unlock()

func (*Job) Cancel

func (j *Job) Cancel()

Cancel prevents the Job from executing if it has not executed already.

Cancel requires appropriate locking to be in place for any resources managed by the Job. If the Job is blocked on obtaining the lock when Cancel is called, it will early return.

Note, t will be modified.

j.locker MUST be locked.

func (*Job) Schedule

func (j *Job) Schedule(d time.Duration)

Schedule schedules the Job for execution after duration d. This can be called on cancelled or completed Jobs to schedule them again.

Schedule should be invoked only on unscheduled, cancelled, or completed Jobs. To be safe, callers should always call Cancel before calling Schedule.

Note, j will be modified.

type KeepaliveIdleOption

type KeepaliveIdleOption time.Duration

KeepaliveIdleOption is used by SetSockOpt/GetSockOpt to specify the time a connection must remain idle before the first TCP keepalive packet is sent. Once this time is reached, KeepaliveIntervalOption is used instead.

type KeepaliveIntervalOption

type KeepaliveIntervalOption time.Duration

KeepaliveIntervalOption is used by SetSockOpt/GetSockOpt to specify the interval between sending TCP keepalive packets.

type LimitedWriter

type LimitedWriter struct {
	W io.Writer
	N int64
}

A LimitedWriter writes to W but limits the amount of data copied to just N bytes. Each call to Write updates N to reflect the new amount remaining.

func (*LimitedWriter) Write

func (l *LimitedWriter) Write(p []byte) (int, error)

type LingerOption

type LingerOption struct {
	Enabled bool
	Timeout time.Duration
}

LingerOption is used by SetSockOpt/GetSockOpt to set/get the duration for which a socket lingers before returning from Close.

+marshal +stateify savable

type LinkAddress

type LinkAddress string

LinkAddress is a byte slice cast as a string that represents a link address. It is typically a 6-byte MAC address.

func GetRandMacAddr

func GetRandMacAddr() LinkAddress

GetRandMacAddr returns a mac address that can be used for local virtual devices.

func ParseMACAddress

func ParseMACAddress(s string) (LinkAddress, error)

ParseMACAddress parses an IEEE 802 address.

It must be in the format aa:bb:cc:dd:ee:ff or aa-bb-cc-dd-ee-ff.

func (LinkAddress) String

func (a LinkAddress) String() string

String implements the fmt.Stringer interface.

type LinkPacketInfo

type LinkPacketInfo struct {
	// Protocol is the NetworkProtocolNumber for the packet.
	Protocol NetworkProtocolNumber

	// PktType is used to indicate the destination of the packet.
	PktType PacketType
}

LinkPacketInfo holds Link layer information for a received packet.

+stateify savable

type LocalSockError

type LocalSockError struct {
	// contains filtered or unexported fields
}

LocalSockError is a socket error that originated from the local host.

+stateify savable

func (*LocalSockError) Code

func (*LocalSockError) Code() uint8

Code implements SockErrorCause.

func (*LocalSockError) Info

func (l *LocalSockError) Info() uint32

Info implements SockErrorCause.

func (*LocalSockError) Origin

func (*LocalSockError) Origin() SockErrOrigin

Origin implements SockErrorCause.

func (*LocalSockError) Type

func (*LocalSockError) Type() uint8

Type implements SockErrorCause.

type MembershipOption

type MembershipOption struct {
	NIC           NICID
	InterfaceAddr Address
	MulticastAddr Address
}

MembershipOption is used to identify a multicast membership on an interface.

type MonotonicTime

type MonotonicTime struct {
	// contains filtered or unexported fields
}

MonotonicTime is a monotonic clock reading.

+stateify savable

func MonotonicTimeInfinite

func MonotonicTimeInfinite() MonotonicTime

MonotonicTimeInfinite returns the monotonic timestamp as far away in the future as possible.

func (MonotonicTime) Add

Add returns the monotonic clock reading mt+d.

func (MonotonicTime) After

func (mt MonotonicTime) After(u MonotonicTime) bool

After reports whether the monotonic clock reading mt is after u.

func (MonotonicTime) Before

func (mt MonotonicTime) Before(u MonotonicTime) bool

Before reports whether the monotonic clock reading mt is before u.

func (MonotonicTime) Milliseconds

func (mt MonotonicTime) Milliseconds() int64

Milliseconds returns the time in milliseconds.

func (MonotonicTime) String

func (mt MonotonicTime) String() string

String implements Stringer.

func (MonotonicTime) Sub

Sub returns the duration mt-u. If the result exceeds the maximum (or minimum) value that can be stored in a Duration, the maximum (or minimum) duration will be returned. To compute t-d for a duration d, use t.Add(-d).

type MultiCounterStat

type MultiCounterStat struct {
	// contains filtered or unexported fields
}

A MultiCounterStat keeps track of two counters at once.

+stateify savable

func (*MultiCounterStat) Increment

func (m *MultiCounterStat) Increment()

Increment adds one to the counters.

func (*MultiCounterStat) IncrementBy

func (m *MultiCounterStat) IncrementBy(v uint64)

IncrementBy increments the counters by v.

func (*MultiCounterStat) Init

func (m *MultiCounterStat) Init(a, b *StatCounter)

Init sets both internal counters to point to a and b.

type MultiIntegralStatCounterMap

type MultiIntegralStatCounterMap struct {
	// contains filtered or unexported fields
}

A MultiIntegralStatCounterMap keeps track of two integral counter maps at once.

+stateify savable

func (*MultiIntegralStatCounterMap) Increment

func (m *MultiIntegralStatCounterMap) Increment(key uint64)

Increment increments the counter in each map corresponding to the provided key.

func (*MultiIntegralStatCounterMap) Init

Init sets the internal integral counter maps to point to a and b.

type MulticastInterfaceOption

type MulticastInterfaceOption struct {
	NIC           NICID
	InterfaceAddr Address
}

MulticastInterfaceOption is used by SetSockOpt/GetSockOpt to specify a default interface for multicast.

type NICID

type NICID int32

NICID is a number that uniquely identifies a NIC.

type NICNeighborStats

type NICNeighborStats struct {

	// UnreachableEntryLookups counts the number of lookups performed on an
	// entry in Unreachable state.
	UnreachableEntryLookups *StatCounter

	// DroppedConfirmationForNoninitiatedNeighbor counts the number of neighbor
	// responses that were dropped because they didn't match an entry in the
	// cache.
	DroppedConfirmationForNoninitiatedNeighbor *StatCounter

	// DroppedInvalidLinkAddressConfirmations counts the number of neighbor
	// responses that were ignored because they had an invalid source link-layer
	// address.
	DroppedInvalidLinkAddressConfirmations *StatCounter
}

NICNeighborStats holds metrics for the neighbor table.

+stateify savable

type NICPacketStats

type NICPacketStats struct {

	// Packets is the number of packets counted.
	Packets *StatCounter

	// Bytes is the number of bytes counted.
	Bytes *StatCounter
}

NICPacketStats holds basic packet statistics.

+stateify savable

type NICStats

type NICStats struct {

	// UnknownL3ProtocolRcvdPacketCounts records the number of packets received
	// for each unknown or unsupported network protocol number.
	UnknownL3ProtocolRcvdPacketCounts *IntegralStatCounterMap

	// UnknownL4ProtocolRcvdPacketCounts records the number of packets received
	// for each unknown or unsupported transport protocol number.
	UnknownL4ProtocolRcvdPacketCounts *IntegralStatCounterMap

	// MalformedL4RcvdPackets is the number of packets received by a NIC that
	// could not be delivered to a transport endpoint because the L4 header could
	// not be parsed.
	MalformedL4RcvdPackets *StatCounter

	// Tx contains statistics about transmitted packets.
	Tx NICPacketStats

	// TxPacketsDroppedNoBufferSpace is the number of packets dropepd due to the
	// NIC not having enough buffer space to send the packet.
	//
	// Packets may be dropped with a no buffer space error when the device TX
	// queue is full.
	TxPacketsDroppedNoBufferSpace *StatCounter

	// Rx contains statistics about received packets.
	Rx NICPacketStats

	// DisabledRx contains statistics about received packets on disabled NICs.
	DisabledRx NICPacketStats

	// Neighbor contains statistics about neighbor entries.
	Neighbor NICNeighborStats
}

NICStats holds NIC statistics.

+stateify savable

func (NICStats) FillIn

func (s NICStats) FillIn() NICStats

FillIn returns a copy of s with nil fields initialized to new StatCounters.

type NetworkProtocolNumber

type NetworkProtocolNumber uint32

NetworkProtocolNumber is the EtherType of a network protocol in an Ethernet frame.

See: https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml

type OriginalDestinationOption

type OriginalDestinationOption FullAddress

OriginalDestinationOption is used to get the original destination address and port of a redirected packet.

type PMTUDStrategy

type PMTUDStrategy int

PMTUDStrategy is the kind of PMTUD to perform.

const (
	// PMTUDiscoveryWant is a setting of the MTUDiscoverOption to use
	// per-route settings.
	PMTUDiscoveryWant PMTUDStrategy = iota

	// PMTUDiscoveryDont is a setting of the MTUDiscoverOption to disable
	// path MTU discovery.
	PMTUDiscoveryDont

	// PMTUDiscoveryDo is a setting of the MTUDiscoverOption to always do
	// path MTU discovery.
	PMTUDiscoveryDo

	// PMTUDiscoveryProbe is a setting of the MTUDiscoverOption to set DF
	// but ignore path MTU.
	PMTUDiscoveryProbe
)

type PacketOwner

type PacketOwner interface {
	// KUID returns KUID of the packet.
	KUID() uint32

	// KGID returns KGID of the packet.
	KGID() uint32
}

PacketOwner is used to get UID and GID of the packet.

type PacketType

type PacketType uint8

PacketType is used to indicate the destination of the packet.

const (
	// PacketHost indicates a packet addressed to the local host.
	PacketHost PacketType = iota

	// PacketOtherHost indicates an outgoing packet addressed to
	// another host caught by a NIC in promiscuous mode.
	PacketOtherHost

	// PacketOutgoing for a packet originating from the local host
	// that is looped back to a packet socket.
	PacketOutgoing

	// PacketBroadcast indicates a link layer broadcast packet.
	PacketBroadcast

	// PacketMulticast indicates a link layer multicast packet.
	PacketMulticast
)

type Payloader

type Payloader interface {
	io.Reader

	// Len returns the number of bytes of the unread portion of the
	// Reader.
	Len() int
}

Payloader is an interface that provides data.

This interface allows the endpoint to request the amount of data it needs based on internal buffers without exposing them.

type ProtocolAddress

type ProtocolAddress struct {
	// Protocol is the protocol of the address.
	Protocol NetworkProtocolNumber

	// AddressWithPrefix is a network address with its subnet prefix length.
	AddressWithPrefix AddressWithPrefix
}

ProtocolAddress is an address and the network protocol it is associated with.

+stateify savable

type ReadErrors

type ReadErrors struct {
	// ReadClosed is the number of received packet drops because the endpoint
	// was shutdown for read.
	ReadClosed StatCounter

	// InvalidEndpointState is the number of times we found the endpoint state
	// to be unexpected.
	InvalidEndpointState StatCounter

	// NotConnected is the number of times we tried to read but found that the
	// endpoint was not connected.
	NotConnected StatCounter
}

ReadErrors collects segment read errors from an endpoint read call.

+stateify savable

type ReadOptions

type ReadOptions struct {
	// Peek indicates whether this read is a peek.
	Peek bool

	// NeedRemoteAddr indicates whether to return the remote address, if
	// supported.
	NeedRemoteAddr bool

	// NeedLinkPacketInfo indicates whether to return the link-layer information,
	// if supported.
	NeedLinkPacketInfo bool
}

ReadOptions contains options for Endpoint.Read.

type ReadResult

type ReadResult struct {
	// Count is the number of bytes received and written to the buffer.
	Count int

	// Total is the number of bytes of the received packet. This can be used to
	// determine whether the read is truncated.
	Total int

	// ControlMessages is the control messages received.
	ControlMessages ReceivableControlMessages

	// RemoteAddr is the remote address if ReadOptions.NeedAddr is true.
	RemoteAddr FullAddress

	// LinkPacketInfo is the link-layer information of the received packet if
	// ReadOptions.NeedLinkPacketInfo is true.
	LinkPacketInfo LinkPacketInfo
}

ReadResult represents result for a successful Endpoint.Read.

type ReceivableControlMessages

type ReceivableControlMessages struct {
	// Timestamp is the time that the last packet used to create the read data
	// was received.
	Timestamp time.Time `state:".(int64)"`

	// HasInq indicates whether Inq is valid/set.
	HasInq bool

	// Inq is the number of bytes ready to be received.
	Inq int32

	// HasTOS indicates whether TOS is valid/set.
	HasTOS bool

	// TOS is the IPv4 type of service of the associated packet.
	TOS uint8

	// HasTTL indicates whether TTL is valid/set.
	HasTTL bool

	// TTL is the IPv4 Time To Live of the associated packet.
	TTL uint8

	// HasHopLimit indicates whether HopLimit is valid/set.
	HasHopLimit bool

	// HopLimit is the IPv6 Hop Limit of the associated packet.
	HopLimit uint8

	// HasTimestamp indicates whether Timestamp is valid/set.
	HasTimestamp bool

	// HasTClass indicates whether TClass is valid/set.
	HasTClass bool

	// TClass is the IPv6 traffic class of the associated packet.
	TClass uint32

	// HasIPPacketInfo indicates whether PacketInfo is set.
	HasIPPacketInfo bool

	// PacketInfo holds interface and address data on an incoming packet.
	PacketInfo IPPacketInfo

	// HasIPv6PacketInfo indicates whether IPv6PacketInfo is set.
	HasIPv6PacketInfo bool

	// IPv6PacketInfo holds interface and address data on an incoming packet.
	IPv6PacketInfo IPv6PacketInfo

	// HasOriginalDestinationAddress indicates whether OriginalDstAddress is
	// set.
	HasOriginalDstAddress bool

	// OriginalDestinationAddress holds the original destination address
	// and port of the incoming packet.
	OriginalDstAddress FullAddress

	// SockErr is the dequeued socket error on recvmsg(MSG_ERRQUEUE).
	SockErr *SockError
}

ReceivableControlMessages contains socket control messages that can be received.

+stateify savable

type ReceiveBufferSizeOption

type ReceiveBufferSizeOption struct {
	// Min is the minimum size for send buffer.
	Min int

	// Default is the default size for send buffer.
	Default int

	// Max is the maximum size for send buffer.
	Max int
}

ReceiveBufferSizeOption is used by stack.(Stack*).Option/SetOption to get/set the default, min and max receive buffer sizes.

+stateify savable

func GetStackReceiveBufferLimits

func GetStackReceiveBufferLimits(so StackHandler) ReceiveBufferSizeOption

GetStackReceiveBufferLimits is used to get default, min and max send buffer size.

type ReceiveErrors

type ReceiveErrors struct {
	// ReceiveBufferOverflow is the number of received packets dropped
	// due to the receive buffer being full.
	ReceiveBufferOverflow StatCounter

	// MalformedPacketsReceived is the number of incoming packets
	// dropped due to the packet header being in a malformed state.
	MalformedPacketsReceived StatCounter

	// ClosedReceiver is the number of received packets dropped because
	// of receiving endpoint state being closed.
	ClosedReceiver StatCounter

	// ChecksumErrors is the number of packets dropped due to bad checksums.
	ChecksumErrors StatCounter
}

ReceiveErrors collects packet receive errors within transport endpoint.

+stateify savable

type RemoveMembershipOption

type RemoveMembershipOption MembershipOption

RemoveMembershipOption identifies a multicast group to leave on some interface.

type Route

type Route struct {
	RouteEntry

	// Destination must contain the target address for this row to be viable.
	Destination Subnet

	// Gateway is the gateway to be used if this row is viable.
	Gateway Address

	// NIC is the id of the nic to be used if this row is viable.
	NIC NICID

	// SourceHint indicates a preferred source address to use when NICs
	// have multiple addresses.
	SourceHint Address

	// MTU is the maximum transmission unit to use for this route.
	// If MTU is 0, this field is ignored and the MTU of the NIC for which this route
	// is configured is used for egress packets.
	MTU uint32
}

Route is a row in the routing table. It specifies through which NIC (and gateway) sets of packets should be routed. A row is considered viable if the masked target address matches the destination address in the row.

+stateify savable

func (Route) Equal

func (r Route) Equal(to Route) bool

Equal returns true if the given Route is equal to this Route.

func (Route) String

func (r Route) String() string

String implements the fmt.Stringer interface.

type SendBufferSizeOption

type SendBufferSizeOption struct {
	// Min is the minimum size for send buffer.
	Min int

	// Default is the default size for send buffer.
	Default int

	// Max is the maximum size for send buffer.
	Max int
}

SendBufferSizeOption is used by stack.(Stack*).Option/SetOption to get/set the default, min and max send buffer sizes.

+stateify savable

func GetStackSendBufferLimits

func GetStackSendBufferLimits(so StackHandler) SendBufferSizeOption

GetStackSendBufferLimits is used to get default, min and max send buffer size.

type SendErrors

type SendErrors struct {
	// SendToNetworkFailed is the number of packets failed to be written to
	// the network endpoint.
	SendToNetworkFailed StatCounter

	// NoRoute is the number of times we failed to resolve IP route.
	NoRoute StatCounter
}

SendErrors collects packet send errors within the transport layer for an endpoint.

+stateify savable

type SendableControlMessages

type SendableControlMessages struct {
	// HasTTL indicates whether TTL is valid/set.
	HasTTL bool

	// TTL is the IPv4 Time To Live of the associated packet.
	TTL uint8

	// HasHopLimit indicates whether HopLimit is valid/set.
	HasHopLimit bool

	// HopLimit is the IPv6 Hop Limit of the associated packet.
	HopLimit uint8

	// HasIPv6PacketInfo indicates whether IPv6PacketInfo is set.
	HasIPv6PacketInfo bool

	// IPv6PacketInfo holds interface and address data on an incoming packet.
	IPv6PacketInfo IPv6PacketInfo
}

SendableControlMessages contains socket control messages that can be written.

+stateify savable

type SettableNetworkProtocolOption

type SettableNetworkProtocolOption interface {
	// contains filtered or unexported methods
}

SettableNetworkProtocolOption is a marker interface for network protocol options that may be set.

type SettableSocketOption

type SettableSocketOption interface {
	// contains filtered or unexported methods
}

SettableSocketOption is a marker interface for socket options that may be configured.

type SettableTransportProtocolOption

type SettableTransportProtocolOption interface {
	// contains filtered or unexported methods
}

SettableTransportProtocolOption is a marker interface for transport protocol options that may be set.

type ShutdownFlags

type ShutdownFlags int

ShutdownFlags represents flags that can be passed to the Shutdown() method of the Endpoint interface.

const (
	ShutdownRead ShutdownFlags = 1 << iota
	ShutdownWrite
)

Values of the flags that can be passed to the Shutdown() method. They can be OR'ed together.

type SliceWriter

type SliceWriter []byte

SliceWriter implements io.Writer for slices.

func (*SliceWriter) Write

func (s *SliceWriter) Write(b []byte) (int, error)

Write implements io.Writer.Write.

type SockErrOrigin

type SockErrOrigin uint8

SockErrOrigin represents the constants for error origin.

const (
	// SockExtErrorOriginNone represents an unknown error origin.
	SockExtErrorOriginNone SockErrOrigin = iota

	// SockExtErrorOriginLocal indicates a local error.
	SockExtErrorOriginLocal

	// SockExtErrorOriginICMP indicates an IPv4 ICMP error.
	SockExtErrorOriginICMP

	// SockExtErrorOriginICMP6 indicates an IPv6 ICMP error.
	SockExtErrorOriginICMP6
)

func (SockErrOrigin) IsICMPErr

func (origin SockErrOrigin) IsICMPErr() bool

IsICMPErr indicates if the error originated from an ICMP error.

type SockError

type SockError struct {

	// Err is the error caused by the errant packet.
	Err Error
	// Cause is the detailed cause of the error.
	Cause SockErrorCause

	// Payload is the errant packet's payload.
	Payload *buffer.View
	// Dst is the original destination address of the errant packet.
	Dst FullAddress
	// Offender is the original sender address of the errant packet.
	Offender FullAddress
	// NetProto is the network protocol being used to transmit the packet.
	NetProto NetworkProtocolNumber
	// contains filtered or unexported fields
}

SockError represents a queue entry in the per-socket error queue.

+stateify savable

type SockErrorCause

type SockErrorCause interface {
	// Origin is the source of the error.
	Origin() SockErrOrigin

	// Type is the origin specific type of error.
	Type() uint8

	// Code is the origin and type specific error code.
	Code() uint8

	// Info is any extra information about the error.
	Info() uint32
}

SockErrorCause is the cause of a socket error.

type SockOptInt

type SockOptInt int

SockOptInt represents socket options which values have the int type.

const (
	// KeepaliveCountOption is used by SetSockOptInt/GetSockOptInt to
	// specify the number of un-ACKed TCP keepalives that will be sent
	// before the connection is closed.
	KeepaliveCountOption SockOptInt = iota

	// IPv4TOSOption is used by SetSockOptInt/GetSockOptInt to specify TOS
	// for all subsequent outgoing IPv4 packets from the endpoint.
	IPv4TOSOption

	// IPv6TrafficClassOption is used by SetSockOptInt/GetSockOptInt to
	// specify TOS for all subsequent outgoing IPv6 packets from the
	// endpoint.
	IPv6TrafficClassOption

	// MaxSegOption is used by SetSockOptInt/GetSockOptInt to set/get the
	// current Maximum Segment Size(MSS) value as specified using the
	// TCP_MAXSEG option.
	MaxSegOption

	// MTUDiscoverOption is used to set/get the path MTU discovery setting.
	//
	// NOTE: Setting this option to any other value than PMTUDiscoveryDont
	// is not supported and will fail as such, and getting this option will
	// always return PMTUDiscoveryDont.
	MTUDiscoverOption

	// MulticastTTLOption is used by SetSockOptInt/GetSockOptInt to control
	// the default TTL value for multicast messages. The default is 1.
	MulticastTTLOption

	// ReceiveQueueSizeOption is used in GetSockOptInt to specify that the
	// number of unread bytes in the input buffer should be returned.
	ReceiveQueueSizeOption

	// SendQueueSizeOption is used in GetSockOptInt to specify that the
	// number of unread bytes in the output buffer should be returned.
	SendQueueSizeOption

	// IPv4TTLOption is used by SetSockOptInt/GetSockOptInt to control the default
	// TTL value for unicast messages.
	//
	// The default is configured by DefaultTTLOption. A UseDefaultIPv4TTL value
	// configures the endpoint to use the default.
	IPv4TTLOption

	// IPv6HopLimitOption is used by SetSockOptInt/GetSockOptInt to control the
	// default hop limit value for unicast messages.
	//
	// The default is configured by DefaultTTLOption. A UseDefaultIPv6HopLimit
	// value configures the endpoint to use the default.
	IPv6HopLimitOption

	// TCPSynCountOption is used by SetSockOptInt/GetSockOptInt to specify
	// the number of SYN retransmits that TCP should send before aborting
	// the attempt to connect. It cannot exceed 255.
	//
	// NOTE: This option is currently only stubbed out and is no-op.
	TCPSynCountOption

	// TCPWindowClampOption is used by SetSockOptInt/GetSockOptInt to bound
	// the size of the advertised window to this value.
	//
	// NOTE: This option is currently only stubed out and is a no-op
	TCPWindowClampOption

	// IPv6Checksum is used to request the stack to populate and validate the IPv6
	// checksum for transport level headers.
	IPv6Checksum
)

type SocketDetachFilterOption

type SocketDetachFilterOption int

SocketDetachFilterOption is used by SetSockOpt to detach a previously attached classic BPF filter on a given endpoint.

type SocketOptions

type SocketOptions struct {
	// contains filtered or unexported fields
}

SocketOptions contains all the variables which store values for SOL_SOCKET, SOL_IP, SOL_IPV6 and SOL_TCP level options.

+stateify savable

func (*SocketOptions) DequeueErr

func (so *SocketOptions) DequeueErr() *SockError

DequeueErr dequeues a socket extended error from the error queue and returns it. Returns nil if queue is empty.

func (*SocketOptions) GetAcceptConn

func (so *SocketOptions) GetAcceptConn() bool

GetAcceptConn gets value for SO_ACCEPTCONN option.

func (*SocketOptions) GetBindToDevice

func (so *SocketOptions) GetBindToDevice() int32

GetBindToDevice gets value for SO_BINDTODEVICE option.

func (*SocketOptions) GetBroadcast

func (so *SocketOptions) GetBroadcast() bool

GetBroadcast gets value for SO_BROADCAST option.

func (*SocketOptions) GetCorkOption

func (so *SocketOptions) GetCorkOption() bool

GetCorkOption gets value for TCP_CORK option.

func (*SocketOptions) GetDelayOption

func (so *SocketOptions) GetDelayOption() bool

GetDelayOption gets inverted value for TCP_NODELAY option.

func (*SocketOptions) GetExperimentOptionValue

func (so *SocketOptions) GetExperimentOptionValue() uint16

GetExperimentOptionValue gets value for the experiment IP option header.

func (*SocketOptions) GetHeaderIncluded

func (so *SocketOptions) GetHeaderIncluded() bool

GetHeaderIncluded gets value for IP_HDRINCL option.

func (*SocketOptions) GetIPv4RecvError

func (so *SocketOptions) GetIPv4RecvError() bool

GetIPv4RecvError gets value for IP_RECVERR option.

func (*SocketOptions) GetIPv6ReceivePacketInfo

func (so *SocketOptions) GetIPv6ReceivePacketInfo() bool

GetIPv6ReceivePacketInfo gets value for IPV6_RECVPKTINFO option.

func (*SocketOptions) GetIPv6RecvError

func (so *SocketOptions) GetIPv6RecvError() bool

GetIPv6RecvError gets value for IPV6_RECVERR option.

func (*SocketOptions) GetKeepAlive

func (so *SocketOptions) GetKeepAlive() bool

GetKeepAlive gets value for SO_KEEPALIVE option.

func (*SocketOptions) GetLastError

func (so *SocketOptions) GetLastError() Error

GetLastError gets value for SO_ERROR option.

func (*SocketOptions) GetLinger

func (so *SocketOptions) GetLinger() LingerOption

GetLinger gets value for SO_LINGER option.

func (*SocketOptions) GetMulticastLoop

func (so *SocketOptions) GetMulticastLoop() bool

GetMulticastLoop gets value for IP_MULTICAST_LOOP option.

func (*SocketOptions) GetNoChecksum

func (so *SocketOptions) GetNoChecksum() bool

GetNoChecksum gets value for SO_NO_CHECK option.

func (*SocketOptions) GetOutOfBandInline

func (*SocketOptions) GetOutOfBandInline() bool

GetOutOfBandInline gets value for SO_OOBINLINE option.

func (*SocketOptions) GetPassCred

func (so *SocketOptions) GetPassCred() bool

GetPassCred gets value for SO_PASSCRED option.

func (*SocketOptions) GetQuickAck

func (so *SocketOptions) GetQuickAck() bool

GetQuickAck gets value for TCP_QUICKACK option.

func (*SocketOptions) GetRcvlowat

func (so *SocketOptions) GetRcvlowat() int32

GetRcvlowat gets value for SO_RCVLOWAT option.

func (*SocketOptions) GetReceiveBufferSize

func (so *SocketOptions) GetReceiveBufferSize() int64

GetReceiveBufferSize gets value for SO_RCVBUF option.

func (*SocketOptions) GetReceiveHopLimit

func (so *SocketOptions) GetReceiveHopLimit() bool

GetReceiveHopLimit gets value for IP_RECVHOPLIMIT option.

func (*SocketOptions) GetReceiveOriginalDstAddress

func (so *SocketOptions) GetReceiveOriginalDstAddress() bool

GetReceiveOriginalDstAddress gets value for IP(V6)_RECVORIGDSTADDR option.

func (*SocketOptions) GetReceivePacketInfo

func (so *SocketOptions) GetReceivePacketInfo() bool

GetReceivePacketInfo gets value for IP_PKTINFO option.

func (*SocketOptions) GetReceiveTClass

func (so *SocketOptions) GetReceiveTClass() bool

GetReceiveTClass gets value for IPV6_RECVTCLASS option.

func (*SocketOptions) GetReceiveTOS

func (so *SocketOptions) GetReceiveTOS() bool

GetReceiveTOS gets value for IP_RECVTOS option.

func (*SocketOptions) GetReceiveTTL

func (so *SocketOptions) GetReceiveTTL() bool

GetReceiveTTL gets value for IP_RECVTTL option.

func (*SocketOptions) GetReuseAddress

func (so *SocketOptions) GetReuseAddress() bool

GetReuseAddress gets value for SO_REUSEADDR option.

func (*SocketOptions) GetReusePort

func (so *SocketOptions) GetReusePort() bool

GetReusePort gets value for SO_REUSEPORT option.

func (*SocketOptions) GetSendBufferSize

func (so *SocketOptions) GetSendBufferSize() int64

GetSendBufferSize gets value for SO_SNDBUF option.

func (*SocketOptions) GetV6Only

func (so *SocketOptions) GetV6Only() bool

GetV6Only gets value for IPV6_V6ONLY option.

func (*SocketOptions) InitHandler

func (so *SocketOptions) InitHandler(handler SocketOptionsHandler, stack StackHandler, getSendBufferLimits GetSendBufferLimits, getReceiveBufferLimits GetReceiveBufferLimits)

InitHandler initializes the handler. This must be called before using the socket options utility.

func (*SocketOptions) PeekErr

func (so *SocketOptions) PeekErr() *SockError

PeekErr returns the error in the front of the error queue. Returns nil if the error queue is empty.

func (*SocketOptions) QueueErr

func (so *SocketOptions) QueueErr(err *SockError)

QueueErr inserts the error at the back of the error queue.

Preconditions: so.GetIPv4RecvError() or so.GetIPv6RecvError() is true.

func (*SocketOptions) QueueLocalErr

func (so *SocketOptions) QueueLocalErr(err Error, net NetworkProtocolNumber, info uint32, dst FullAddress, payload *buffer.View)

QueueLocalErr queues a local error onto the local queue.

func (*SocketOptions) ReceiveBufferLimits

func (so *SocketOptions) ReceiveBufferLimits() (min, max int64)

ReceiveBufferLimits returns the [min, max) range of allowable receive buffer sizes.

func (*SocketOptions) SendBufferLimits

func (so *SocketOptions) SendBufferLimits() (min, max int64)

SendBufferLimits returns the [min, max) range of allowable send buffer sizes.

func (*SocketOptions) SetBindToDevice

func (so *SocketOptions) SetBindToDevice(bindToDevice int32) Error

SetBindToDevice sets value for SO_BINDTODEVICE option. If bindToDevice is zero, the socket device binding is removed.

func (*SocketOptions) SetBroadcast

func (so *SocketOptions) SetBroadcast(v bool)

SetBroadcast sets value for SO_BROADCAST option.

func (*SocketOptions) SetCorkOption

func (so *SocketOptions) SetCorkOption(v bool)

SetCorkOption sets value for TCP_CORK option.

func (*SocketOptions) SetDelayOption

func (so *SocketOptions) SetDelayOption(v bool)

SetDelayOption sets inverted value for TCP_NODELAY option.

func (*SocketOptions) SetExperimentOptionValue

func (so *SocketOptions) SetExperimentOptionValue(v uint16)

SetExperimentOptionValue sets the value for the experiment IP option header.

func (*SocketOptions) SetHeaderIncluded

func (so *SocketOptions) SetHeaderIncluded(v bool)

SetHeaderIncluded sets value for IP_HDRINCL option.

func (*SocketOptions) SetIPv4RecvError

func (so *SocketOptions) SetIPv4RecvError(v bool)

SetIPv4RecvError sets value for IP_RECVERR option.

func (*SocketOptions) SetIPv6ReceivePacketInfo

func (so *SocketOptions) SetIPv6ReceivePacketInfo(v bool)

SetIPv6ReceivePacketInfo sets value for IPV6_RECVPKTINFO option.

func (*SocketOptions) SetIPv6RecvError

func (so *SocketOptions) SetIPv6RecvError(v bool)

SetIPv6RecvError sets value for IPV6_RECVERR option.

func (*SocketOptions) SetKeepAlive

func (so *SocketOptions) SetKeepAlive(v bool)

SetKeepAlive sets value for SO_KEEPALIVE option.

func (*SocketOptions) SetLastError

func (so *SocketOptions) SetLastError(err Error)

SetLastError sets the last error for a socket.

func (*SocketOptions) SetLinger

func (so *SocketOptions) SetLinger(linger LingerOption)

SetLinger sets value for SO_LINGER option.

func (*SocketOptions) SetMulticastLoop

func (so *SocketOptions) SetMulticastLoop(v bool)

SetMulticastLoop sets value for IP_MULTICAST_LOOP option.

func (*SocketOptions) SetNoChecksum

func (so *SocketOptions) SetNoChecksum(v bool)

SetNoChecksum sets value for SO_NO_CHECK option.

func (*SocketOptions) SetOutOfBandInline

func (*SocketOptions) SetOutOfBandInline(bool)

SetOutOfBandInline sets value for SO_OOBINLINE option. We currently do not support disabling this option.

func (*SocketOptions) SetPassCred

func (so *SocketOptions) SetPassCred(v bool)

SetPassCred sets value for SO_PASSCRED option.

func (*SocketOptions) SetQuickAck

func (so *SocketOptions) SetQuickAck(v bool)

SetQuickAck sets value for TCP_QUICKACK option.

func (*SocketOptions) SetRcvlowat

func (so *SocketOptions) SetRcvlowat(rcvlowat int32) Error

SetRcvlowat sets value for SO_RCVLOWAT option.

func (*SocketOptions) SetReceiveBufferSize

func (so *SocketOptions) SetReceiveBufferSize(receiveBufferSize int64, notify bool)

SetReceiveBufferSize sets the value of the SO_RCVBUF option, optionally notifying the owning endpoint.

func (*SocketOptions) SetReceiveHopLimit

func (so *SocketOptions) SetReceiveHopLimit(v bool)

SetReceiveHopLimit sets value for IP_RECVHOPLIMIT option.

func (*SocketOptions) SetReceiveOriginalDstAddress

func (so *SocketOptions) SetReceiveOriginalDstAddress(v bool)

SetReceiveOriginalDstAddress sets value for IP(V6)_RECVORIGDSTADDR option.

func (*SocketOptions) SetReceivePacketInfo

func (so *SocketOptions) SetReceivePacketInfo(v bool)

SetReceivePacketInfo sets value for IP_PKTINFO option.

func (*SocketOptions) SetReceiveTClass

func (so *SocketOptions) SetReceiveTClass(v bool)

SetReceiveTClass sets value for IPV6_RECVTCLASS option.

func (*SocketOptions) SetReceiveTOS

func (so *SocketOptions) SetReceiveTOS(v bool)

SetReceiveTOS sets value for IP_RECVTOS option.

func (*SocketOptions) SetReceiveTTL

func (so *SocketOptions) SetReceiveTTL(v bool)

SetReceiveTTL sets value for IP_RECVTTL option.

func (*SocketOptions) SetReuseAddress

func (so *SocketOptions) SetReuseAddress(v bool)

SetReuseAddress sets value for SO_REUSEADDR option.

func (*SocketOptions) SetReusePort

func (so *SocketOptions) SetReusePort(v bool)

SetReusePort sets value for SO_REUSEPORT option.

func (*SocketOptions) SetSendBufferSize

func (so *SocketOptions) SetSendBufferSize(sendBufferSize int64, notify bool)

SetSendBufferSize sets value for SO_SNDBUF option. notify indicates if the stack handler should be invoked to set the send buffer size.

func (*SocketOptions) SetV6Only

func (so *SocketOptions) SetV6Only(v bool)

SetV6Only sets value for IPV6_V6ONLY option.

Preconditions: the backing TCP or UDP endpoint must be in initial state.

type SocketOptionsHandler

type SocketOptionsHandler interface {
	// OnReuseAddressSet is invoked when SO_REUSEADDR is set for an endpoint.
	OnReuseAddressSet(v bool)

	// OnReusePortSet is invoked when SO_REUSEPORT is set for an endpoint.
	OnReusePortSet(v bool)

	// OnKeepAliveSet is invoked when SO_KEEPALIVE is set for an endpoint.
	OnKeepAliveSet(v bool)

	// OnDelayOptionSet is invoked when TCP_NODELAY is set for an endpoint.
	// Note that v will be the inverse of TCP_NODELAY option.
	OnDelayOptionSet(v bool)

	// OnCorkOptionSet is invoked when TCP_CORK is set for an endpoint.
	OnCorkOptionSet(v bool)

	// LastError is invoked when SO_ERROR is read for an endpoint.
	LastError() Error

	// UpdateLastError updates the endpoint specific last error field.
	UpdateLastError(err Error)

	// HasNIC is invoked to check if the NIC is valid for SO_BINDTODEVICE.
	HasNIC(v int32) bool

	// OnSetSendBufferSize is invoked when the send buffer size for an endpoint is
	// changed. The handler is invoked with the new value for the socket send
	// buffer size. It also returns the newly set value.
	OnSetSendBufferSize(v int64) (newSz int64)

	// OnSetReceiveBufferSize is invoked by SO_RCVBUF and SO_RCVBUFFORCE. The
	// handler can optionally return a callback which will be called after
	// the buffer size is updated to newSz.
	OnSetReceiveBufferSize(v, oldSz int64) (newSz int64, postSet func())

	// WakeupWriters is invoked when the send buffer size for an endpoint is
	// changed. The handler notifies the writers if the send buffer size is
	// increased with setsockopt(2) for TCP endpoints.
	WakeupWriters()

	// GetAcceptConn returns true if the socket is a TCP socket and is in
	// listening state.
	GetAcceptConn() bool
}

SocketOptionsHandler holds methods that help define endpoint specific behavior for socket level socket options. These must be implemented by endpoints to get notified when socket level options are set.

type StackHandler

type StackHandler interface {
	// Option allows retrieving stack wide options.
	Option(option any) Error

	// TransportProtocolOption allows retrieving individual protocol level
	// option values.
	TransportProtocolOption(proto TransportProtocolNumber, option GettableTransportProtocolOption) Error
}

StackHandler holds methods to access the stack options. These must be implemented by the stack.

type StatCounter

type StatCounter struct {
	// contains filtered or unexported fields
}

A StatCounter keeps track of a statistic.

+stateify savable

func (*StatCounter) Decrement

func (s *StatCounter) Decrement()

Decrement minuses one to the counter.

func (*StatCounter) Increment

func (s *StatCounter) Increment()

Increment adds one to the counter.

func (*StatCounter) IncrementBy

func (s *StatCounter) IncrementBy(v uint64)

IncrementBy increments the counter by v.

func (*StatCounter) String

func (s *StatCounter) String() string

func (*StatCounter) Value

func (s *StatCounter) Value() uint64

Value returns the current value of the counter.

type Stats

type Stats struct {

	// DroppedPackets is the number of packets dropped at the transport layer.
	DroppedPackets *StatCounter

	// NICs is an aggregation of every NIC's statistics. These should not be
	// incremented using this field, but using the relevant NIC multicounters.
	NICs NICStats

	// ICMP is an aggregation of every NetworkEndpoint's ICMP statistics (both v4
	// and v6). These should not be incremented using this field, but using the
	// relevant NetworkEndpoint ICMP multicounters.
	ICMP ICMPStats

	// IGMP is an aggregation of every NetworkEndpoint's IGMP statistics. These
	// should not be incremented using this field, but using the relevant
	// NetworkEndpoint IGMP multicounters.
	IGMP IGMPStats

	// IP is an aggregation of every NetworkEndpoint's IP statistics. These should
	// not be incremented using this field, but using the relevant NetworkEndpoint
	// IP multicounters.
	IP IPStats

	// ARP is an aggregation of every NetworkEndpoint's ARP statistics. These
	// should not be incremented using this field, but using the relevant
	// NetworkEndpoint ARP multicounters.
	ARP ARPStats

	// TCP holds TCP-specific stats.
	TCP TCPStats

	// UDP holds UDP-specific stats.
	UDP UDPStats
}

Stats holds statistics about the networking stack.

+stateify savable

func (Stats) FillIn

func (s Stats) FillIn() Stats

FillIn returns a copy of s with nil fields initialized to new StatCounters.

type Subnet

type Subnet struct {
	// contains filtered or unexported fields
}

Subnet is a subnet defined by its address and mask.

+stateify savable

func NewSubnet

func NewSubnet(a Address, m AddressMask) (Subnet, error)

NewSubnet creates a new Subnet, checking that the address and mask are the same length.

func (*Subnet) Bits

func (s *Subnet) Bits() (ones int, zeros int)

Bits returns the number of ones (network bits) and zeros (host bits) in the subnet mask.

func (*Subnet) Broadcast

func (s *Subnet) Broadcast() Address

Broadcast returns the subnet's broadcast address.

func (*Subnet) Contains

func (s *Subnet) Contains(a Address) bool

Contains returns true iff the address is of the same length and matches the subnet address and mask.

func (Subnet) Equal

func (s Subnet) Equal(o Subnet) bool

Equal returns true if this Subnet is equal to the given Subnet.

func (*Subnet) ID

func (s *Subnet) ID() Address

ID returns the subnet ID.

func (*Subnet) IsBroadcast

func (s *Subnet) IsBroadcast(address Address) bool

IsBroadcast returns true if the address is considered a broadcast address.

func (*Subnet) Mask

func (s *Subnet) Mask() AddressMask

Mask returns the subnet mask.

func (*Subnet) Prefix

func (s *Subnet) Prefix() int

Prefix returns the number of bits before the first host bit.

func (Subnet) String

func (s Subnet) String() string

String implements Stringer.

type TCPAlwaysUseSynCookies

type TCPAlwaysUseSynCookies bool

TCPAlwaysUseSynCookies indicates unconditional usage of syncookies.

type TCPAvailableCongestionControlOption

type TCPAvailableCongestionControlOption string

TCPAvailableCongestionControlOption is the supported congestion control algorithms for TCP

type TCPDeferAcceptOption

type TCPDeferAcceptOption time.Duration

TCPDeferAcceptOption is used by SetSockOpt/GetSockOpt to allow a accept to return a completed connection only when there is data to be read. This usually means the listening socket will drop the final ACK for a handshake till the specified timeout until a segment with data arrives.

type TCPDelayEnabled

type TCPDelayEnabled bool

TCPDelayEnabled enables/disables Nagle's algorithm in TCP.

type TCPInfoOption

type TCPInfoOption struct {
	// RTT is the smoothed round trip time.
	RTT time.Duration

	// RTTVar is the round trip time variation.
	RTTVar time.Duration

	// RTO is the retransmission timeout for the endpoint.
	RTO time.Duration

	// State is the current endpoint protocol state.
	State EndpointState

	// CcState is the congestion control state.
	CcState CongestionControlState

	// SndCwnd is the congestion window, in packets.
	SndCwnd uint32

	// SndSsthresh is the threshold between slow start and congestion
	// avoidance.
	SndSsthresh uint32

	// ReorderSeen indicates if reordering is seen in the endpoint.
	ReorderSeen bool
}

TCPInfoOption is used by GetSockOpt to expose TCP statistics.

type TCPLingerTimeoutOption

type TCPLingerTimeoutOption time.Duration

TCPLingerTimeoutOption is used by SetSockOpt/GetSockOpt to set/get the maximum duration for which a socket lingers in the TCP_FIN_WAIT_2 state before being marked closed.

type TCPMaxRTOOption

type TCPMaxRTOOption time.Duration

TCPMaxRTOOption is use by SetSockOpt/GetSockOpt to allow overriding default MaxRTO used by the Stack.

type TCPMaxRetriesOption

type TCPMaxRetriesOption uint64

TCPMaxRetriesOption is used by SetSockOpt/GetSockOpt to set/get the maximum number of retransmits after which we time out the connection.

type TCPMinRTOOption

type TCPMinRTOOption time.Duration

TCPMinRTOOption is use by SetSockOpt/GetSockOpt to allow overriding default MinRTO used by the Stack.

type TCPModerateReceiveBufferOption

type TCPModerateReceiveBufferOption bool

TCPModerateReceiveBufferOption enables/disables receive buffer moderation for TCP.

type TCPReceiveBufferSizeRangeOption

type TCPReceiveBufferSizeRangeOption struct {
	Min     int
	Default int
	Max     int
}

TCPReceiveBufferSizeRangeOption is the receive buffer size range for TCP.

+stateify savable

type TCPRecovery

type TCPRecovery int32

TCPRecovery is the loss deteoction algorithm used by TCP.

const (
	// TCPRACKLossDetection indicates RACK is used for loss detection and
	// recovery.
	TCPRACKLossDetection TCPRecovery = 1 << iota

	// TCPRACKStaticReoWnd indicates the reordering window should not be
	// adjusted when DSACK is received.
	TCPRACKStaticReoWnd

	// TCPRACKNoDupTh indicates RACK should not consider the classic three
	// duplicate acknowledgements rule to mark the segments as lost. This
	// is used when reordering is not detected.
	TCPRACKNoDupTh
)

type TCPSACKEnabled

type TCPSACKEnabled bool

TCPSACKEnabled the SACK option for TCP.

See: https://tools.ietf.org/html/rfc2018.

type TCPSendBufferSizeRangeOption

type TCPSendBufferSizeRangeOption struct {
	Min     int
	Default int
	Max     int
}

TCPSendBufferSizeRangeOption is the send buffer size range for TCP.

+stateify savable

type TCPStats

type TCPStats struct {
	// ActiveConnectionOpenings is the number of connections opened
	// successfully via Connect.
	ActiveConnectionOpenings *StatCounter

	// PassiveConnectionOpenings is the number of connections opened
	// successfully via Listen.
	PassiveConnectionOpenings *StatCounter

	// CurrentEstablished is the number of TCP connections for which the
	// current state is ESTABLISHED.
	CurrentEstablished *StatCounter

	// CurrentConnected is the number of TCP connections that
	// are in connected state.
	CurrentConnected *StatCounter

	// EstablishedResets is the number of times TCP connections have made
	// a direct transition to the CLOSED state from either the
	// ESTABLISHED state or the CLOSE-WAIT state.
	EstablishedResets *StatCounter

	// EstablishedClosed is the number of times established TCP connections
	// made a transition to CLOSED state.
	EstablishedClosed *StatCounter

	// EstablishedTimedout is the number of times an established connection
	// was reset because of keep-alive time out.
	EstablishedTimedout *StatCounter

	// ListenOverflowSynDrop is the number of times the listen queue overflowed
	// and a SYN was dropped.
	ListenOverflowSynDrop *StatCounter

	// ListenOverflowAckDrop is the number of times the final ACK
	// in the handshake was dropped due to overflow.
	ListenOverflowAckDrop *StatCounter

	// ListenOverflowCookieSent is the number of times a SYN cookie was sent.
	ListenOverflowSynCookieSent *StatCounter

	// ListenOverflowSynCookieRcvd is the number of times a valid SYN
	// cookie was received.
	ListenOverflowSynCookieRcvd *StatCounter

	// ListenOverflowInvalidSynCookieRcvd is the number of times an invalid SYN cookie
	// was received.
	ListenOverflowInvalidSynCookieRcvd *StatCounter

	// FailedConnectionAttempts is the number of calls to Connect or Listen
	// (active and passive openings, respectively) that end in an error.
	FailedConnectionAttempts *StatCounter

	// ValidSegmentsReceived is the number of TCP segments received that
	// the transport layer successfully parsed.
	ValidSegmentsReceived *StatCounter

	// InvalidSegmentsReceived is the number of TCP segments received that
	// the transport layer could not parse.
	InvalidSegmentsReceived *StatCounter

	// SegmentsSent is the number of TCP segments sent.
	SegmentsSent *StatCounter

	// SegmentSendErrors is the number of TCP segments failed to be sent.
	SegmentSendErrors *StatCounter

	// ResetsSent is the number of TCP resets sent.
	ResetsSent *StatCounter

	// ResetsReceived is the number of TCP resets received.
	ResetsReceived *StatCounter

	// Retransmits is the number of TCP segments retransmitted.
	Retransmits *StatCounter

	// FastRecovery is the number of times Fast Recovery was used to
	// recover from packet loss.
	FastRecovery *StatCounter

	// SACKRecovery is the number of times SACK Recovery was used to
	// recover from packet loss.
	SACKRecovery *StatCounter

	// TLPRecovery is the number of times recovery was accomplished by the tail
	// loss probe.
	TLPRecovery *StatCounter

	// SlowStartRetransmits is the number of segments retransmitted in slow
	// start.
	SlowStartRetransmits *StatCounter

	// FastRetransmit is the number of segments retransmitted in fast
	// recovery.
	FastRetransmit *StatCounter

	// Timeouts is the number of times the RTO expired.
	Timeouts *StatCounter

	// ChecksumErrors is the number of segments dropped due to bad checksums.
	ChecksumErrors *StatCounter

	// FailedPortReservations is the number of times TCP failed to reserve
	// a port.
	FailedPortReservations *StatCounter

	// SegmentsAckedWithDSACK is the number of segments acknowledged with
	// DSACK.
	SegmentsAckedWithDSACK *StatCounter

	// SpuriousRecovery is the number of times the connection entered loss
	// recovery spuriously.
	SpuriousRecovery *StatCounter

	// SpuriousRTORecovery is the number of spurious RTOs.
	SpuriousRTORecovery *StatCounter

	// ForwardMaxInFlightDrop is the number of connection requests that are
	// dropped due to exceeding the maximum number of in-flight connection
	// requests.
	ForwardMaxInFlightDrop *StatCounter
}

TCPStats collects TCP-specific stats.

+stateify savable

type TCPSynRetriesOption

type TCPSynRetriesOption uint8

TCPSynRetriesOption is used by SetSockOpt/GetSockOpt to specify stack-wide default for number of times SYN is retransmitted before aborting a connect.

type TCPTimeWaitReuseOption

type TCPTimeWaitReuseOption uint8

TCPTimeWaitReuseOption is used stack.(*Stack).TransportProtocolOption to specify if the stack can reuse the port bound by an endpoint in TIME-WAIT for new connections when it is safe from protocol viewpoint.

const (
	// TCPTimeWaitReuseDisabled indicates reuse of port bound by endpoints in TIME-WAIT cannot
	// be reused for new connections.
	TCPTimeWaitReuseDisabled TCPTimeWaitReuseOption = iota

	// TCPTimeWaitReuseGlobal indicates reuse of port bound by endpoints in TIME-WAIT can
	// be reused for new connections irrespective of the src/dest addresses.
	TCPTimeWaitReuseGlobal

	// TCPTimeWaitReuseLoopbackOnly indicates reuse of port bound by endpoint in TIME-WAIT can
	// only be reused if the connection was a connection over loopback. i.e. src/dest addresses
	// are loopback addresses.
	TCPTimeWaitReuseLoopbackOnly
)

type TCPTimeWaitTimeoutOption

type TCPTimeWaitTimeoutOption time.Duration

TCPTimeWaitTimeoutOption is used by SetSockOpt/GetSockOpt to set/get the maximum duration for which a socket lingers in the TIME_WAIT state before being marked closed.

type TCPUserTimeoutOption

type TCPUserTimeoutOption time.Duration

TCPUserTimeoutOption is used by SetSockOpt/GetSockOpt to specify a user specified timeout for a given TCP connection. See: RFC5482 for details.

type Timer

type Timer interface {
	// Stop prevents the Timer from firing. It returns true if the call stops the
	// timer, false if the timer has already expired or been stopped.
	//
	// If Stop returns false, then the timer has already expired and the function
	// f of Clock.AfterFunc(d, f) has been started in its own goroutine; Stop
	// does not wait for f to complete before returning. If the caller needs to
	// know whether f is completed, it must coordinate with f explicitly.
	Stop() bool

	// Reset changes the timer to expire after duration d.
	//
	// Reset should be invoked only on stopped or expired timers. If the timer is
	// known to have expired, Reset can be used directly. Otherwise, the caller
	// must coordinate with the function f of Clock.AfterFunc(d, f).
	Reset(d time.Duration)
}

Timer represents a single event. A Timer must be created with Clock.AfterFunc.

func NewStdTimer

func NewStdTimer(t *time.Timer) Timer

NewStdTimer returns a Timer implemented with the time package.

type TransportEndpointStats

type TransportEndpointStats struct {
	// PacketsReceived is the number of successful packet receives.
	PacketsReceived StatCounter

	// PacketsSent is the number of successful packet sends.
	PacketsSent StatCounter

	// ReceiveErrors collects packet receive errors within transport layer.
	ReceiveErrors ReceiveErrors

	// ReadErrors collects packet read errors from an endpoint read call.
	ReadErrors ReadErrors

	// SendErrors collects packet send errors within the transport layer.
	SendErrors SendErrors

	// WriteErrors collects packet write errors from an endpoint write call.
	WriteErrors WriteErrors
}

TransportEndpointStats collects statistics about the endpoint.

+stateify savable

func (*TransportEndpointStats) Clone

Clone clones a copy of the TransportEndpointStats into dst by atomically reading each field.

func (*TransportEndpointStats) IsEndpointStats

func (*TransportEndpointStats) IsEndpointStats()

IsEndpointStats is an empty method to implement the tcpip.EndpointStats marker interface.

type TransportProtocolNumber

type TransportProtocolNumber uint32

TransportProtocolNumber is the number of a transport protocol.

type UDPStats

type UDPStats struct {
	// PacketsReceived is the number of UDP datagrams received via
	// HandlePacket.
	PacketsReceived *StatCounter

	// UnknownPortErrors is the number of incoming UDP datagrams dropped
	// because they did not have a known destination port.
	UnknownPortErrors *StatCounter

	// ReceiveBufferErrors is the number of incoming UDP datagrams dropped
	// due to the receiving buffer being in an invalid state.
	ReceiveBufferErrors *StatCounter

	// MalformedPacketsReceived is the number of incoming UDP datagrams
	// dropped due to the UDP header being in a malformed state.
	MalformedPacketsReceived *StatCounter

	// PacketsSent is the number of UDP datagrams sent via sendUDP.
	PacketsSent *StatCounter

	// PacketSendErrors is the number of datagrams failed to be sent.
	PacketSendErrors *StatCounter

	// ChecksumErrors is the number of datagrams dropped due to bad checksums.
	ChecksumErrors *StatCounter
}

UDPStats collects UDP-specific stats.

+stateify savable

type WriteErrors

type WriteErrors struct {
	// WriteClosed is the number of packet drops because the endpoint
	// was shutdown for write.
	WriteClosed StatCounter

	// InvalidEndpointState is the number of times we found the endpoint state
	// to be unexpected.
	InvalidEndpointState StatCounter

	// InvalidArgs is the number of times invalid input arguments were
	// provided for endpoint Write call.
	InvalidArgs StatCounter
}

WriteErrors collects packet write errors from an endpoint write call.

+stateify savable

type WriteOptions

type WriteOptions struct {
	// If To is not nil, write to the given address instead of the endpoint's
	// peer.
	To *FullAddress

	// More has the same semantics as Linux's MSG_MORE.
	More bool

	// EndOfRecord has the same semantics as Linux's MSG_EOR.
	EndOfRecord bool

	// Atomic means that all data fetched from Payloader must be written to the
	// endpoint. If Atomic is false, then data fetched from the Payloader may be
	// discarded if available endpoint buffer space is insufficient.
	Atomic bool

	// ControlMessages contains optional overrides used when writing a packet.
	ControlMessages SendableControlMessages
}

WriteOptions contains options for Endpoint.Write.

Directories

Path Synopsis
adapters
gonet
Package gonet provides a Go net package compatible wrapper for a tcpip stack.
Package gonet provides a Go net package compatible wrapper for a tcpip stack.
Package checker provides helper functions to check networking packets for validity.
Package checker provides helper functions to check networking packets for validity.
Package checksum provides the implementation of the encoding and decoding of network protocol headers.
Package checksum provides the implementation of the encoding and decoding of network protocol headers.
Package faketime provides a fake clock that implements tcpip.Clock interface.
Package faketime provides a fake clock that implements tcpip.Clock interface.
hash
jenkins
Package jenkins implements Jenkins's one_at_a_time, non-cryptographic hash functions created by by Bob Jenkins.
Package jenkins implements Jenkins's one_at_a_time, non-cryptographic hash functions created by by Bob Jenkins.
Package header provides the implementation of the encoding and decoding of network protocol headers.
Package header provides the implementation of the encoding and decoding of network protocol headers.
parse
Package parse provides utilities to parse packets.
Package parse provides utilities to parse packets.
internal
tcp
Package tcp contains internal type definitions that are not expected to be used by anyone else outside pkg/tcpip.
Package tcp contains internal type definitions that are not expected to be used by anyone else outside pkg/tcpip.
link
channel
Package channel provides the implementation of channel-based data-link layer endpoints.
Package channel provides the implementation of channel-based data-link layer endpoints.
ethernet
Package ethernet provides an implementation of an ethernet link endpoint that wraps an inner link endpoint.
Package ethernet provides an implementation of an ethernet link endpoint that wraps an inner link endpoint.
fdbased
Package fdbased provides the implementation of data-link layer endpoints backed by boundary-preserving file descriptors (e.g., TUN devices, seqpacket/datagram sockets).
Package fdbased provides the implementation of data-link layer endpoints backed by boundary-preserving file descriptors (e.g., TUN devices, seqpacket/datagram sockets).
loopback
Package loopback provides the implementation of loopback data-link layer endpoints.
Package loopback provides the implementation of loopback data-link layer endpoints.
muxed
Package muxed provides a muxed link endpoints.
Package muxed provides a muxed link endpoints.
nested
Package nested provides helpers to implement the pattern of nested stack.LinkEndpoints.
Package nested provides helpers to implement the pattern of nested stack.LinkEndpoints.
packetsocket
Package packetsocket provides a link endpoint that enables delivery of incoming and outgoing packets to any interested packet sockets.
Package packetsocket provides a link endpoint that enables delivery of incoming and outgoing packets to any interested packet sockets.
pipe
Package pipe provides the implementation of pipe-like data-link layer endpoints.
Package pipe provides the implementation of pipe-like data-link layer endpoints.
qdisc/fifo
Package fifo provides the implementation of FIFO queuing discipline that queues all outbound packets and asynchronously dispatches them to the lower link endpoint in the order that they were queued.
Package fifo provides the implementation of FIFO queuing discipline that queues all outbound packets and asynchronously dispatches them to the lower link endpoint in the order that they were queued.
sharedmem
Package sharedmem provides the implementation of data-link layer endpoints backed by shared memory.
Package sharedmem provides the implementation of data-link layer endpoints backed by shared memory.
sharedmem/pipe
Package pipe implements a shared memory ring buffer on which a single reader and a single writer can operate (read/write) concurrently.
Package pipe implements a shared memory ring buffer on which a single reader and a single writer can operate (read/write) concurrently.
sharedmem/queue
Package queue provides the implementation of transmit and receive queues based on shared memory ring buffers.
Package queue provides the implementation of transmit and receive queues based on shared memory ring buffers.
sniffer
Package sniffer provides the implementation of data-link layer endpoints that wrap another endpoint and logs inbound and outbound packets.
Package sniffer provides the implementation of data-link layer endpoints that wrap another endpoint and logs inbound and outbound packets.
stopfd
Package stopfd provides an type that can be used to signal the stop of a dispatcher.
Package stopfd provides an type that can be used to signal the stop of a dispatcher.
tun
Package tun contains methods to open TAP and TUN devices.
Package tun contains methods to open TAP and TUN devices.
veth
Package veth provides the implementation of virtual ethernet device pair.
Package veth provides the implementation of virtual ethernet device pair.
waitable
Package waitable provides the implementation of data-link layer endpoints that wrap other endpoints, and can wait for inflight calls to WritePacket or DeliverNetworkPacket to finish (and new ones to be prevented).
Package waitable provides the implementation of data-link layer endpoints that wrap other endpoints, and can wait for inflight calls to WritePacket or DeliverNetworkPacket to finish (and new ones to be prevented).
xdp
Package xdp provides link layer endpoints backed by AF_XDP sockets.
Package xdp provides link layer endpoints backed by AF_XDP sockets.
network
arp
Package arp implements the ARP network protocol.
Package arp implements the ARP network protocol.
hash
Package hash contains utility functions for hashing.
Package hash contains utility functions for hashing.
internal/fragmentation
Package fragmentation contains the implementation of IP fragmentation.
Package fragmentation contains the implementation of IP fragmentation.
internal/ip
Package ip holds IPv4/IPv6 common utilities.
Package ip holds IPv4/IPv6 common utilities.
internal/multicast
Package multicast contains utilities for supporting multicast routing.
Package multicast contains utilities for supporting multicast routing.
internal/testutil
Package testutil defines types and functions used to test Network Layer functionality such as IP fragmentation.
Package testutil defines types and functions used to test Network Layer functionality such as IP fragmentation.
ipv4
Package ipv4 contains the implementation of the ipv4 network protocol.
Package ipv4 contains the implementation of the ipv4 network protocol.
ipv6
Package ipv6 contains the implementation of the ipv6 network protocol.
Package ipv6 contains the implementation of the ipv6 network protocol.
Package nftables provides the interface to process packets through a netfilter (nf) ruleset and maintain/modify the ruleset accordingly.
Package nftables provides the interface to process packets through a netfilter (nf) ruleset and maintain/modify the ruleset accordingly.
Package ports provides PortManager that manages allocating, reserving and releasing ports.
Package ports provides PortManager that manages allocating, reserving and releasing ports.
Package prependable defines a buffer that grows backwards.
Package prependable defines a buffer that grows backwards.
sample
tun_tcp_connect
This sample creates a stack with TCP and IPv4 protocols on top of a TUN device, and connects to a peer.
This sample creates a stack with TCP and IPv4 protocols on top of a TUN device, and connects to a peer.
tun_tcp_echo
This sample creates a stack with TCP and IPv4 protocols on top of a TUN device, and listens on a port.
This sample creates a stack with TCP and IPv4 protocols on top of a TUN device, and listens on a port.
Package seqnum defines the types and methods for TCP sequence numbers such that they fit in 32-bit words and work properly when overflows occur.
Package seqnum defines the types and methods for TCP sequence numbers such that they fit in 32-bit words and work properly when overflows occur.
Package stack provides the glue between networking protocols and the consumers of the networking stack.
Package stack provides the glue between networking protocols and the consumers of the networking stack.
gro
Package gro implements generic receive offload.
Package gro implements generic receive offload.
tests
utils
Package utils holds common testing utilities for tcpip.
Package utils holds common testing utilities for tcpip.
Package testutil provides helper functions for netstack unit tests.
Package testutil provides helper functions for netstack unit tests.
Package transport supports transport protocols.
Package transport supports transport protocols.
icmp
Package icmp contains the implementation of the ICMP and IPv6-ICMP transport protocols for use in ping.
Package icmp contains the implementation of the ICMP and IPv6-ICMP transport protocols for use in ping.
internal/network
Package network provides facilities to support tcpip.Endpoints that operate at the network layer or above.
Package network provides facilities to support tcpip.Endpoints that operate at the network layer or above.
internal/noop
Package noop contains an endpoint that implements all tcpip.Endpoint functions as noops.
Package noop contains an endpoint that implements all tcpip.Endpoint functions as noops.
packet
Package packet provides the implementation of packet sockets (see packet(7)).
Package packet provides the implementation of packet sockets (see packet(7)).
raw
Package raw provides the implementation of raw sockets (see raw(7)).
Package raw provides the implementation of raw sockets (see raw(7)).
tcp
Package tcp contains the implementation of the TCP transport protocol.
Package tcp contains the implementation of the TCP transport protocol.
tcp/test/e2e
Package e2e contains definitions common to all e2e tcp tests.
Package e2e contains definitions common to all e2e tcp tests.
tcp/testing/context
Package context provides a test context for use in tcp tests.
Package context provides a test context for use in tcp tests.
tcpconntrack
Package tcpconntrack implements a TCP connection tracking object.
Package tcpconntrack implements a TCP connection tracking object.
testing/context
Package context provides a context used by datagram-based network endpoints tests.
Package context provides a context used by datagram-based network endpoints tests.
udp
Package udp contains the implementation of the UDP transport protocol.
Package udp contains the implementation of the UDP transport protocol.

Jump to

Keyboard shortcuts

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