Documentation ¶
Overview ¶
Package epsocket provides an implementation of the socket.Socket interface that is backed by a tcpip.Endpoint.
It does not depend on any particular endpoint implementation, and thus can be used to expose certain endpoints to the sentry while leaving others out, for example, TCP endpoints and Unix-domain endpoints.
Lock ordering: netstack => mm: ioSequencePayload copies user memory inside tcpip.Endpoint.Write(). Netstack is allowed to (and does) hold locks during this operation.
Index ¶
- func ConvertAddress(family int, addr tcpip.FullAddress) (interface{}, uint32)
- func ConvertShutdown(how int) (tcpip.ShutdownFlags, *syserr.Error)
- func GetAddress(sfamily int, addr []byte) (tcpip.FullAddress, *syserr.Error)
- func GetSockOpt(t *kernel.Task, s socket.Socket, ep commonEndpoint, family int, ...) (interface{}, *syserr.Error)
- func GetTransportProtocol(stype unix.SockType, protocol int) (tcpip.TransportProtocolNumber, *syserr.Error)
- func Ioctl(ctx context.Context, ep commonEndpoint, io usermem.IO, ...) (uintptr, error)
- func New(t *kernel.Task, family int, skType unix.SockType, queue *waiter.Queue, ...) *fs.File
- func SetSockOpt(t *kernel.Task, s socket.Socket, ep commonEndpoint, level int, name int, ...) *syserr.Error
- type SocketOperations
- func (s *SocketOperations) Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (kdefs.FD, interface{}, uint32, *syserr.Error)
- func (s *SocketOperations) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error
- func (s *SocketOperations) Connect(t *kernel.Task, sockaddr []byte, blocking bool) *syserr.Error
- func (s *SocketOperations) GetPeerName(t *kernel.Task) (interface{}, uint32, *syserr.Error)
- func (s *SocketOperations) GetSockName(t *kernel.Task) (interface{}, uint32, *syserr.Error)
- func (s *SocketOperations) GetSockOpt(t *kernel.Task, level, name, outLen int) (interface{}, *syserr.Error)
- func (s *SocketOperations) Ioctl(ctx context.Context, io usermem.IO, args arch.SyscallArguments) (uintptr, error)
- func (s *SocketOperations) Listen(t *kernel.Task, backlog int) *syserr.Error
- func (s *SocketOperations) Read(ctx context.Context, _ *fs.File, dst usermem.IOSequence, _ int64) (int64, error)
- func (s *SocketOperations) Readiness(mask waiter.EventMask) waiter.EventMask
- func (s *SocketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags int, haveDeadline bool, ...) (n int, senderAddr interface{}, senderAddrLen uint32, ...)
- func (s *SocketOperations) Release()
- func (s *SocketOperations) SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, ...) (int, *syserr.Error)
- func (s *SocketOperations) SetSockOpt(t *kernel.Task, level int, name int, optVal []byte) *syserr.Error
- func (s *SocketOperations) Shutdown(t *kernel.Task, how int) *syserr.Error
- func (s *SocketOperations) Write(ctx context.Context, _ *fs.File, src usermem.IOSequence, _ int64) (int64, error)
- type Stack
- func (s *Stack) InterfaceAddrs() map[int32][]inet.InterfaceAddr
- func (s *Stack) Interfaces() map[int32]inet.Interface
- func (s *Stack) SetTCPReceiveBufferSize(size inet.TCPBufferSize) error
- func (s *Stack) SetTCPSACKEnabled(enabled bool) error
- func (s *Stack) SetTCPSendBufferSize(size inet.TCPBufferSize) error
- func (s *Stack) SupportsIPv6() bool
- func (s *Stack) TCPReceiveBufferSize() (inet.TCPBufferSize, error)
- func (s *Stack) TCPSACKEnabled() (bool, error)
- func (s *Stack) TCPSendBufferSize() (inet.TCPBufferSize, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertAddress ¶
func ConvertAddress(family int, addr tcpip.FullAddress) (interface{}, uint32)
ConvertAddress converts the given address to a native format.
func ConvertShutdown ¶
func ConvertShutdown(how int) (tcpip.ShutdownFlags, *syserr.Error)
ConvertShutdown converts Linux shutdown flags into tcpip shutdown flags.
func GetAddress ¶
GetAddress reads an sockaddr struct from the given address and converts it to the FullAddress format. It supports AF_UNIX, AF_INET and AF_INET6 addresses.
func GetSockOpt ¶
func GetSockOpt(t *kernel.Task, s socket.Socket, ep commonEndpoint, family int, skType unix.SockType, level, name, outLen int) (interface{}, *syserr.Error)
GetSockOpt can be used to implement the linux syscall getsockopt(2) for sockets backed by a commonEndpoint.
func GetTransportProtocol ¶
func GetTransportProtocol(stype unix.SockType, protocol int) (tcpip.TransportProtocolNumber, *syserr.Error)
GetTransportProtocol figures out transport protocol. Currently only TCP, UDP, and ICMP are supported.
func Ioctl ¶
func Ioctl(ctx context.Context, ep commonEndpoint, io usermem.IO, args arch.SyscallArguments) (uintptr, error)
Ioctl implements fs.FileOperations.Ioctl for sockets backed by a commonEndpoint.
Types ¶
type SocketOperations ¶
type SocketOperations struct { socket.ReceiveTimeout fsutil.PipeSeek `state:"nosave"` fsutil.NotDirReaddir `state:"nosave"` fsutil.NoFsync `state:"nosave"` fsutil.NoopFlush `state:"nosave"` fsutil.NoMMap `state:"nosave"` *waiter.Queue Endpoint tcpip.Endpoint // contains filtered or unexported fields }
SocketOperations encapsulates all the state needed to represent a network stack endpoint in the kernel context.
func (*SocketOperations) Accept ¶
func (s *SocketOperations) Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (kdefs.FD, interface{}, uint32, *syserr.Error)
Accept implements the linux syscall accept(2) for sockets backed by tcpip.Endpoint.
func (*SocketOperations) Bind ¶
Bind implements the linux syscall bind(2) for sockets backed by tcpip.Endpoint.
func (*SocketOperations) Connect ¶
Connect implements the linux syscall connect(2) for sockets backed by tpcip.Endpoint.
func (*SocketOperations) GetPeerName ¶
GetPeerName implements the linux syscall getpeername(2) for sockets backed by tcpip.Endpoint.
func (*SocketOperations) GetSockName ¶
GetSockName implements the linux syscall getsockname(2) for sockets backed by tcpip.Endpoint.
func (*SocketOperations) GetSockOpt ¶
func (s *SocketOperations) GetSockOpt(t *kernel.Task, level, name, outLen int) (interface{}, *syserr.Error)
GetSockOpt implements the linux syscall getsockopt(2) for sockets backed by tcpip.Endpoint.
func (*SocketOperations) Ioctl ¶
func (s *SocketOperations) Ioctl(ctx context.Context, io usermem.IO, args arch.SyscallArguments) (uintptr, error)
Ioctl implements fs.FileOperations.Ioctl.
func (*SocketOperations) Listen ¶
Listen implements the linux syscall listen(2) for sockets backed by tcpip.Endpoint.
func (*SocketOperations) Read ¶
func (s *SocketOperations) Read(ctx context.Context, _ *fs.File, dst usermem.IOSequence, _ int64) (int64, error)
Read implements fs.FileOperations.Read.
func (*SocketOperations) Readiness ¶
func (s *SocketOperations) Readiness(mask waiter.EventMask) waiter.EventMask
Readiness returns a mask of ready events for socket s.
func (*SocketOperations) RecvMsg ¶
func (s *SocketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags int, haveDeadline bool, deadline ktime.Time, senderRequested bool, controlDataLen uint64) (n int, senderAddr interface{}, senderAddrLen uint32, controlMessages socket.ControlMessages, err *syserr.Error)
RecvMsg implements the linux syscall recvmsg(2) for sockets backed by tcpip.Endpoint.
func (*SocketOperations) Release ¶
func (s *SocketOperations) Release()
Release implements fs.FileOperations.Release.
func (*SocketOperations) SendMsg ¶
func (s *SocketOperations) SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, controlMessages socket.ControlMessages) (int, *syserr.Error)
SendMsg implements the linux syscall sendmsg(2) for sockets backed by tcpip.Endpoint.
func (*SocketOperations) SetSockOpt ¶
func (s *SocketOperations) SetSockOpt(t *kernel.Task, level int, name int, optVal []byte) *syserr.Error
SetSockOpt implements the linux syscall setsockopt(2) for sockets backed by tcpip.Endpoint.
type Stack ¶
Stack implements inet.Stack for netstack/tcpip/stack.Stack.
func (*Stack) InterfaceAddrs ¶
func (s *Stack) InterfaceAddrs() map[int32][]inet.InterfaceAddr
InterfaceAddrs implements inet.Stack.InterfaceAddrs.
func (*Stack) Interfaces ¶
Interfaces implements inet.Stack.Interfaces.
func (*Stack) SetTCPReceiveBufferSize ¶
func (s *Stack) SetTCPReceiveBufferSize(size inet.TCPBufferSize) error
SetTCPReceiveBufferSize implements inet.Stack.SetTCPReceiveBufferSize.
func (*Stack) SetTCPSACKEnabled ¶
SetTCPSACKEnabled implements inet.Stack.SetTCPSACKEnabled.
func (*Stack) SetTCPSendBufferSize ¶
func (s *Stack) SetTCPSendBufferSize(size inet.TCPBufferSize) error
SetTCPSendBufferSize implements inet.Stack.SetTCPSendBufferSize.
func (*Stack) SupportsIPv6 ¶
SupportsIPv6 implements Stack.SupportsIPv6.
func (*Stack) TCPReceiveBufferSize ¶
func (s *Stack) TCPReceiveBufferSize() (inet.TCPBufferSize, error)
TCPReceiveBufferSize implements inet.Stack.TCPReceiveBufferSize.
func (*Stack) TCPSACKEnabled ¶
TCPSACKEnabled implements inet.Stack.TCPSACKEnabled.
func (*Stack) TCPSendBufferSize ¶
func (s *Stack) TCPSendBufferSize() (inet.TCPBufferSize, error)
TCPSendBufferSize implements inet.Stack.TCPSendBufferSize.