control

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package control provides internal representations of socket control messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmsgsSpace

func CmsgsSpace(t *kernel.Task, cmsgs socket.ControlMessages) int

CmsgsSpace returns the number of bytes needed to fit the control messages represented in cmsgs.

func New

func New(t *kernel.Task, socketOrEndpoint any) transport.ControlMessages

New creates default control messages if needed.

func PackControlMessages

func PackControlMessages(t *kernel.Task, cmsgs socket.ControlMessages, buf []byte) []byte

PackControlMessages packs control messages into the given buffer.

We skip control messages specific to Unix domain sockets.

Note that some control messages may be truncated if they do not fit under the capacity of buf.

func PackCredentials

func PackCredentials(t *kernel.Task, creds SCMCredentials, buf []byte, flags int) ([]byte, int)

PackCredentials packs the credentials in the control message (or default credentials if none) into a buffer.

func PackHopLimit

func PackHopLimit(t *kernel.Task, hoplimit uint32, buf []byte) []byte

PackHopLimit packs an IPV6_HOPLIMIT socket control message.

func PackIPPacketInfo

func PackIPPacketInfo(t *kernel.Task, packetInfo *linux.ControlMessageIPPacketInfo, buf []byte) []byte

PackIPPacketInfo packs an IP_PKTINFO socket control message.

func PackIPv6PacketInfo

func PackIPv6PacketInfo(t *kernel.Task, packetInfo *linux.ControlMessageIPv6PacketInfo, buf []byte) []byte

PackIPv6PacketInfo packs an IPV6_PKTINFO socket control message.

func PackInq

func PackInq(t *kernel.Task, inq int32, buf []byte) []byte

PackInq packs a TCP_INQ socket control message.

func PackOriginalDstAddress

func PackOriginalDstAddress(t *kernel.Task, originalDstAddress linux.SockAddr, buf []byte) []byte

PackOriginalDstAddress packs an IP_RECVORIGINALDSTADDR socket control message.

func PackRights

func PackRights(t *kernel.Task, rights SCMRights, cloexec bool, buf []byte, flags int) ([]byte, int)

PackRights packs as many FDs as will fit into the unused capacity of buf.

func PackSockExtendedErr

func PackSockExtendedErr(t *kernel.Task, sockErr linux.SockErrCMsg, buf []byte) []byte

PackSockExtendedErr packs an IP*_RECVERR socket control message.

func PackTClass

func PackTClass(t *kernel.Task, tClass uint32, buf []byte) []byte

PackTClass packs an IPV6_TCLASS socket control message.

func PackTOS

func PackTOS(t *kernel.Task, tos uint8, buf []byte) []byte

PackTOS packs an IP_TOS socket control message.

func PackTTL

func PackTTL(t *kernel.Task, ttl uint32, buf []byte) []byte

PackTTL packs an IP_TTL socket control message.

func PackTimestamp

func PackTimestamp(t *kernel.Task, timestamp time.Time, buf []byte) []byte

PackTimestamp packs a SO_TIMESTAMP socket control message.

func Parse

func Parse(t *kernel.Task, socketOrEndpoint any, buf []byte, width uint) (socket.ControlMessages, error)

Parse parses a raw socket control message into portable objects. TODO(https://gvisor.dev/issue/7188): Parse is only called on raw cmsg that are used when sending a messages. We should fail with EINVAL when we find a non-sendable control messages (such as IP_RECVERR). And the function should be renamed to reflect that.

Types

type RightsFiles

type RightsFiles []*vfs.FileDescription

RightsFiles represents a SCM_RIGHTS socket control message. A reference is maintained for each vfs.FileDescription and is release either when an FD is created or when the Release method is called.

+stateify savable

func (*RightsFiles) Clone

Clone implements transport.RightsControlMessage.Clone.

func (*RightsFiles) Files

func (fs *RightsFiles) Files(ctx context.Context, max int) (RightsFiles, bool)

Files implements SCMRights.Files.

func (*RightsFiles) Release

func (fs *RightsFiles) Release(ctx context.Context)

Release implements transport.RightsControlMessage.Release.

type SCMCredentials

type SCMCredentials interface {
	transport.CredentialsControlMessage

	// Credentials returns properly namespaced values for the sender's pid, uid
	// and gid.
	Credentials(t *kernel.Task) (kernel.ThreadID, auth.UID, auth.GID)
}

SCMCredentials represents a SCM_CREDENTIALS socket control message.

func MakeCreds

func MakeCreds(t *kernel.Task) SCMCredentials

MakeCreds creates default SCMCredentials.

func NewSCMCredentials

func NewSCMCredentials(t *kernel.Task, cred linux.ControlMessageCredentials) (SCMCredentials, error)

NewSCMCredentials creates a new SCM_CREDENTIALS socket control message representation.

type SCMRights

type SCMRights interface {
	transport.RightsControlMessage

	// Files returns up to max RightsFiles.
	//
	// Returned files are consumed and ownership is transferred to the caller.
	// Subsequent calls to Files will return the next files.
	Files(ctx context.Context, max int) (rf RightsFiles, truncated bool)
}

SCMRights represents a SCM_RIGHTS socket control message.

+stateify savable

func NewSCMRights

func NewSCMRights(t *kernel.Task, fds []primitive.Int32) (SCMRights, error)

NewSCMRights creates a new SCM_RIGHTS socket control message representation using local sentry FDs.

Jump to

Keyboard shortcuts

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