hostinet

package
v0.0.0-...-8940ca0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0, MIT Imports: 38 Imported by: 0

Documentation

Overview

Package hostinet implements AF_INET and AF_INET6 sockets using the host's network stack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractHostInterfaces

func ExtractHostInterfaces(links []syscall.NetlinkMessage, addrs []syscall.NetlinkMessage, interfaces map[int32]*inet.Interface, interfaceAddrs map[int32][]inet.InterfaceAddr) error

ExtractHostInterfaces will populate an interface map and interfaceAddrs map with the results of the equivalent netlink messages.

func ExtractHostRoutes

func ExtractHostRoutes(routeMsgs []syscall.NetlinkMessage) ([]inet.Route, error)

ExtractHostRoutes populates the given routes slice with the data from the host route table.

Types

type Socket

type Socket struct {
	vfs.FileDescriptionDefaultImpl
	vfs.LockFD
	// We store metadata for hostinet sockets internally. Technically, we should
	// access metadata (e.g. through stat, chmod) on the host for correctness,
	// but this is not very useful for inet socket fds, which do not belong to a
	// concrete file anyway.
	vfs.DentryMetadataFileDescriptionImpl
	socket.SendReceiveTimeout
	// contains filtered or unexported fields
}

Socket implements socket.Socket (and by extension, vfs.FileDescriptionImpl) for host sockets.

+stateify savable

func (*Socket) Accept

func (s *Socket) Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (int32, linux.SockAddr, uint32, *syserr.Error)

Accept implements socket.Socket.Accept.

func (*Socket) Bind

func (s *Socket) Bind(_ *kernel.Task, sockaddr []byte) *syserr.Error

Bind implements socket.Socket.Bind.

func (*Socket) Connect

func (s *Socket) Connect(t *kernel.Task, sockaddr []byte, blocking bool) *syserr.Error

Connect implements socket.Socket.Connect.

func (*Socket) Epollable

func (s *Socket) Epollable() bool

Epollable implements FileDescriptionImpl.Epollable.

func (*Socket) EventRegister

func (s *Socket) EventRegister(e *waiter.Entry) error

EventRegister implements waiter.Waitable.EventRegister.

func (*Socket) EventUnregister

func (s *Socket) EventUnregister(e *waiter.Entry)

EventUnregister implements waiter.Waitable.EventUnregister.

func (*Socket) GetPeerName

func (s *Socket) GetPeerName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)

GetPeerName implements socket.Socket.GetPeerName.

func (*Socket) GetSockName

func (s *Socket) GetSockName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)

GetSockName implements socket.Socket.GetSockName.

func (*Socket) GetSockOpt

func (s *Socket) GetSockOpt(t *kernel.Task, level int, name int, optValAddr hostarch.Addr, outLen int) (marshal.Marshallable, *syserr.Error)

GetSockOpt implements socket.Socket.GetSockOpt.

func (*Socket) Ioctl

func (s *Socket) Ioctl(ctx context.Context, uio usermem.IO, args arch.SyscallArguments) (uintptr, error)

Ioctl implements vfs.FileDescriptionImpl.

func (*Socket) Listen

func (s *Socket) Listen(_ *kernel.Task, backlog int) *syserr.Error

Listen implements socket.Socket.Listen.

func (*Socket) PRead

func (s *Socket) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, opts vfs.ReadOptions) (int64, error)

PRead implements vfs.FileDescriptionImpl.PRead.

func (*Socket) PWrite

func (s *Socket) PWrite(ctx context.Context, dst usermem.IOSequence, offset int64, opts vfs.WriteOptions) (int64, error)

PWrite implements vfs.FileDescriptionImpl.

func (*Socket) Read

func (s *Socket) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)

Read implements vfs.FileDescriptionImpl.

func (*Socket) Readiness

func (s *Socket) Readiness(mask waiter.EventMask) waiter.EventMask

Readiness implements waiter.Waitable.Readiness.

func (*Socket) RecvMsg

func (s *Socket) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags int, haveDeadline bool, deadline ktime.Time, senderRequested bool, controlLen uint64) (int, int, linux.SockAddr, uint32, socket.ControlMessages, *syserr.Error)

RecvMsg implements socket.Socket.RecvMsg.

func (*Socket) Release

func (s *Socket) Release(ctx context.Context)

Release implements vfs.FileDescriptionImpl.Release.

func (*Socket) SendMsg

func (s *Socket) SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, haveDeadline bool, deadline ktime.Time, controlMessages socket.ControlMessages) (int, *syserr.Error)

SendMsg implements socket.Socket.SendMsg.

func (*Socket) SetSockOpt

func (s *Socket) SetSockOpt(t *kernel.Task, level int, name int, opt []byte) *syserr.Error

SetSockOpt implements socket.Socket.SetSockOpt.

func (*Socket) Shutdown

func (s *Socket) Shutdown(_ *kernel.Task, how int) *syserr.Error

Shutdown implements socket.Socket.Shutdown.

func (*Socket) State

func (s *Socket) State() uint32

State implements socket.Socket.State.

func (*Socket) StateFields

func (s *Socket) StateFields() []string

func (*Socket) StateLoad

func (s *Socket) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*Socket) StateSave

func (s *Socket) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Socket) StateTypeName

func (s *Socket) StateTypeName() string

func (*Socket) Type

func (s *Socket) Type() (family int, skType linux.SockType, protocol int)

Type implements socket.Socket.Type.

func (*Socket) Write

func (s *Socket) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error)

Write implements vfs.FileDescriptionImpl.

type Stack

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

Stack implements inet.Stack for host sockets.

func NewStack

func NewStack() *Stack

NewStack returns an empty Stack containing no configuration.

func (*Stack) AddInterfaceAddr

func (*Stack) AddInterfaceAddr(int32, inet.InterfaceAddr) error

AddInterfaceAddr implements inet.Stack.AddInterfaceAddr.

func (*Stack) CleanupEndpoints

func (*Stack) CleanupEndpoints() []stack.TransportEndpoint

CleanupEndpoints implements inet.Stack.CleanupEndpoints.

func (*Stack) Configure

func (s *Stack) Configure() error

Configure sets up the stack using the current state of the host network.

func (*Stack) Destroy

func (*Stack) Destroy()

Destroy implements inet.Stack.Destroy.

func (*Stack) GROTimeout

func (s *Stack) GROTimeout(NICID int32) (time.Duration, error)

GROTimeout implements inet.Stack.GROTimeout.

func (*Stack) InterfaceAddrs

func (s *Stack) InterfaceAddrs() map[int32][]inet.InterfaceAddr

InterfaceAddrs implements inet.Stack.InterfaceAddrs.

func (*Stack) Interfaces

func (s *Stack) Interfaces() map[int32]inet.Interface

Interfaces implements inet.Stack.Interfaces.

func (*Stack) Pause

func (*Stack) Pause()

Pause implements inet.Stack.Pause.

func (*Stack) PortRange

func (*Stack) PortRange() (uint16, uint16)

PortRange implements inet.Stack.PortRange.

func (*Stack) RegisteredEndpoints

func (*Stack) RegisteredEndpoints() []stack.TransportEndpoint

RegisteredEndpoints implements inet.Stack.RegisteredEndpoints.

func (*Stack) RemoveInterface

func (*Stack) RemoveInterface(int32) error

RemoveInterface implements inet.Stack.RemoveInterface.

func (*Stack) RemoveInterfaceAddr

func (*Stack) RemoveInterfaceAddr(int32, inet.InterfaceAddr) error

RemoveInterfaceAddr implements inet.Stack.RemoveInterfaceAddr.

func (*Stack) RestoreCleanupEndpoints

func (*Stack) RestoreCleanupEndpoints([]stack.TransportEndpoint)

RestoreCleanupEndpoints implements inet.Stack.RestoreCleanupEndpoints.

func (*Stack) Resume

func (*Stack) Resume()

Resume implements inet.Stack.Resume.

func (*Stack) RouteTable

func (s *Stack) RouteTable() []inet.Route

RouteTable implements inet.Stack.RouteTable.

func (*Stack) SetForwarding

func (*Stack) SetForwarding(tcpip.NetworkProtocolNumber, bool) error

SetForwarding implements inet.Stack.SetForwarding.

func (*Stack) SetGROTimeout

func (s *Stack) SetGROTimeout(NICID int32, timeout time.Duration) error

SetGROTimeout implements inet.Stack.SetGROTimeout.

func (*Stack) SetPortRange

func (*Stack) SetPortRange(uint16, uint16) error

SetPortRange implements inet.Stack.SetPortRange.

func (*Stack) SetTCPReceiveBufferSize

func (*Stack) SetTCPReceiveBufferSize(inet.TCPBufferSize) error

SetTCPReceiveBufferSize implements inet.Stack.SetTCPReceiveBufferSize.

func (*Stack) SetTCPRecovery

func (*Stack) SetTCPRecovery(inet.TCPLossRecovery) error

SetTCPRecovery implements inet.Stack.SetTCPRecovery.

func (*Stack) SetTCPSACKEnabled

func (*Stack) SetTCPSACKEnabled(bool) error

SetTCPSACKEnabled implements inet.Stack.SetTCPSACKEnabled.

func (*Stack) SetTCPSendBufferSize

func (*Stack) SetTCPSendBufferSize(inet.TCPBufferSize) error

SetTCPSendBufferSize implements inet.Stack.SetTCPSendBufferSize.

func (*Stack) Statistics

func (s *Stack) Statistics(stat any, arg string) error

Statistics implements inet.Stack.Statistics.

func (*Stack) SupportsIPv6

func (s *Stack) SupportsIPv6() bool

SupportsIPv6 implements inet.Stack.SupportsIPv6.

func (*Stack) TCPReceiveBufferSize

func (s *Stack) TCPReceiveBufferSize() (inet.TCPBufferSize, error)

TCPReceiveBufferSize implements inet.Stack.TCPReceiveBufferSize.

func (*Stack) TCPRecovery

func (s *Stack) TCPRecovery() (inet.TCPLossRecovery, error)

TCPRecovery implements inet.Stack.TCPRecovery.

func (*Stack) TCPSACKEnabled

func (s *Stack) TCPSACKEnabled() (bool, error)

TCPSACKEnabled implements inet.Stack.TCPSACKEnabled.

func (*Stack) TCPSendBufferSize

func (s *Stack) TCPSendBufferSize() (inet.TCPBufferSize, error)

TCPSendBufferSize implements inet.Stack.TCPSendBufferSize.

Jump to

Keyboard shortcuts

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