Documentation ¶
Overview ¶
Package transport contains the implementation of Unix endpoints.
Index ¶
- Constants
- func NewPair(ctx context.Context, stype linux.SockType, uid uniqueid.Provider) (Endpoint, Endpoint)
- type Address
- type BoundEndpoint
- type BoundSocketFD
- type ConnectedEndpoint
- type ConnectingEndpoint
- type ControlMessages
- func (c *ControlMessages) Clone() ControlMessages
- func (c *ControlMessages) Empty() bool
- func (c *ControlMessages) Release(ctx context.Context)
- func (c *ControlMessages) StateFields() []string
- func (c *ControlMessages) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (c *ControlMessages) StateSave(stateSinkObject state.Sink)
- func (c *ControlMessages) StateTypeName() string
- type Credentialer
- type CredentialsControlMessage
- type Endpoint
- type HostBoundEndpoint
- type HostConnectedEndpoint
- func (c *HostConnectedEndpoint) CloseNotify()
- func (c *HostConnectedEndpoint) CloseRecv()
- func (c *HostConnectedEndpoint) CloseSend()
- func (c *HostConnectedEndpoint) CloseUnread()
- func (c *HostConnectedEndpoint) EventUpdate() error
- func (c *HostConnectedEndpoint) GetLocalAddress() (Address, tcpip.Error)
- func (c *HostConnectedEndpoint) IsRecvClosed() bool
- func (c *HostConnectedEndpoint) IsSendClosed() bool
- func (c *HostConnectedEndpoint) Passcred() bool
- func (c *HostConnectedEndpoint) Readable() bool
- func (c *HostConnectedEndpoint) Recv(ctx context.Context, data [][]byte, args RecvArgs) (RecvOutput, bool, *syserr.Error)
- func (c *HostConnectedEndpoint) RecvMaxQueueSize() int64
- func (c *HostConnectedEndpoint) RecvNotify()
- func (c *HostConnectedEndpoint) RecvQueuedSize() int64
- func (c *HostConnectedEndpoint) Release(ctx context.Context)
- func (c *HostConnectedEndpoint) Send(ctx context.Context, data [][]byte, controlMessages ControlMessages, ...) (int64, bool, *syserr.Error)
- func (c *HostConnectedEndpoint) SendMaxQueueSize() int64
- func (c *HostConnectedEndpoint) SendNotify()
- func (c *HostConnectedEndpoint) SendQueuedSize() int64
- func (c *HostConnectedEndpoint) SetReceiveBufferSize(v int64) (newSz int64)
- func (c *HostConnectedEndpoint) SetSendBufferSize(v int64) (newSz int64)
- func (c *HostConnectedEndpoint) SockType() linux.SockType
- func (c *HostConnectedEndpoint) StateFields() []string
- func (c *HostConnectedEndpoint) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (c *HostConnectedEndpoint) StateSave(stateSinkObject state.Sink)
- func (c *HostConnectedEndpoint) StateTypeName() string
- func (c *HostConnectedEndpoint) Writable() bool
- type HostConnectedEndpointRefs
- func (r *HostConnectedEndpointRefs) DecRef(destroy func())
- func (r *HostConnectedEndpointRefs) IncRef()
- func (r *HostConnectedEndpointRefs) InitRefs()
- func (r *HostConnectedEndpointRefs) LeakMessage() string
- func (r *HostConnectedEndpointRefs) LogRefs() bool
- func (r *HostConnectedEndpointRefs) ReadRefs() int64
- func (r *HostConnectedEndpointRefs) RefType() string
- func (r *HostConnectedEndpointRefs) StateFields() []string
- func (r *HostConnectedEndpointRefs) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (r *HostConnectedEndpointRefs) StateSave(stateSinkObject state.Sink)
- func (r *HostConnectedEndpointRefs) StateTypeName() string
- func (r *HostConnectedEndpointRefs) TryIncRef() bool
- type Receiver
- type RecvArgs
- type RecvOutput
- type RightsControlMessage
- type SCMConnectedEndpoint
- func (e *SCMConnectedEndpoint) Init() error
- func (e *SCMConnectedEndpoint) Release(ctx context.Context)
- func (e *SCMConnectedEndpoint) StateFields() []string
- func (e *SCMConnectedEndpoint) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (e *SCMConnectedEndpoint) StateSave(stateSinkObject state.Sink)
- func (e *SCMConnectedEndpoint) StateTypeName() string
- type SCMRights
- type UnixSocketOpts
Constants ¶
const HostConnectedEndpointenableLogging = false
enableLogging indicates whether reference-related events should be logged (with stack traces). This is false by default and should only be set to true for debugging purposes, as it can generate an extremely large amount of output and drastically degrade performance.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Address ¶
type Address struct {
Addr string
}
Address is a unix socket address.
+stateify savable
func (*Address) StateFields ¶
func (*Address) StateTypeName ¶
type BoundEndpoint ¶
type BoundEndpoint interface { // BidirectionalConnect establishes a bi-directional connection between two // unix endpoints in an all-or-nothing manner. If an error occurs during // connecting, the state of neither endpoint should be modified. // // In order for an endpoint to establish such a bidirectional connection // with a BoundEndpoint, the endpoint calls the BidirectionalConnect method // on the BoundEndpoint and sends a representation of itself (the // ConnectingEndpoint) and a callback (returnConnect) to receive the // connection information (Receiver and ConnectedEndpoint) upon a // successful connect. The callback should only be called on a successful // connect. // // For a connection attempt to be successful, the ConnectingEndpoint must // be unconnected and not listening and the BoundEndpoint whose // BidirectionalConnect method is being called must be listening. // // This method will return syserr.ErrConnectionRefused on endpoints with a // type that isn't SockStream or SockSeqpacket. BidirectionalConnect(ctx context.Context, ep ConnectingEndpoint, returnConnect func(Receiver, ConnectedEndpoint), opts UnixSocketOpts) *syserr.Error // UnidirectionalConnect establishes a write-only connection to a unix // endpoint. // // An endpoint which calls UnidirectionalConnect and supports it itself must // not hold its own lock when calling UnidirectionalConnect. // // This method will return syserr.ErrConnectionRefused on a non-SockDgram // endpoint. UnidirectionalConnect(ctx context.Context, opts UnixSocketOpts) (ConnectedEndpoint, *syserr.Error) // Passcred returns whether or not the SO_PASSCRED socket option is // enabled on this end. Passcred() bool // Release releases any resources held by the BoundEndpoint. It must be // called before dropping all references to a BoundEndpoint returned by a // function. Release(ctx context.Context) }
A BoundEndpoint is a unix endpoint that can be connected to.
type BoundSocketFD ¶
type BoundSocketFD interface { // Close closes the socket FD. Close(ctx context.Context) // NotificationFD is a host FD that can be used to notify when new clients // connect to the socket. NotificationFD() int32 // Listen is analogous to listen(2). Listen(ctx context.Context, backlog int32) error // Accept is analogous to accept(2). Accept(ctx context.Context) (int, error) }
BoundSocketFD is an interface that wraps a socket FD that was bind(2)-ed. It allows to listen and accept on that socket.
type ConnectedEndpoint ¶
type ConnectedEndpoint interface { // Passcred implements Endpoint.Passcred. Passcred() bool // GetLocalAddress implements Endpoint.GetLocalAddress. GetLocalAddress() (Address, tcpip.Error) // Send sends a single message. This method does not block. // // notify indicates if SendNotify should be called. // // syserr.ErrWouldBlock can be returned along with a partial write if // the caller should block to send the rest of the data. Send(ctx context.Context, data [][]byte, c ControlMessages, from Address) (n int64, notify bool, err *syserr.Error) // SendNotify notifies the ConnectedEndpoint of a successful Send. This // must not be called while holding any endpoint locks. SendNotify() // CloseSend prevents the sending of additional Messages. // // After CloseSend is call, CloseNotify must also be called. CloseSend() // CloseNotify notifies the ConnectedEndpoint of send being closed. This // must not be called while holding any endpoint locks. CloseNotify() // IsSendClosed returns true if transmission of additional messages is closed. IsSendClosed() bool // Writable returns if messages should be attempted to be sent. This // includes when write has been shutdown. Writable() bool // EventUpdate lets the ConnectedEndpoint know that event registrations // have changed. EventUpdate() error // SendQueuedSize returns the total amount of data currently queued for // sending. SendQueuedSize should return -1 if the operation isn't // supported. SendQueuedSize() int64 // SendMaxQueueSize returns maximum value for SendQueuedSize. // SendMaxQueueSize should return -1 if the operation isn't supported. SendMaxQueueSize() int64 // Release releases any resources owned by the ConnectedEndpoint. It should // be called before dropping all references to a ConnectedEndpoint. Release(ctx context.Context) // CloseUnread sets the fact that this end is closed with unread data to // the peer socket. CloseUnread() // SetSendBufferSize is called when the endpoint's send buffer size is // changed. SetSendBufferSize(v int64) (newSz int64) }
A ConnectedEndpoint is an Endpoint that can be used to send Messages.
type ConnectingEndpoint ¶
type ConnectingEndpoint interface { // ID returns the endpoint's globally unique identifier. This identifier // must be used to determine locking order if more than one endpoint is // to be locked in the same codepath. The endpoint with the smaller // identifier must be locked before endpoints with larger identifiers. ID() uint64 // Passcred implements socket.Credentialer.Passcred. Passcred() bool // Type returns the socket type, typically either SockStream or // SockSeqpacket. The connection attempt must be aborted if this // value doesn't match the BoundEndpoint's type. Type() linux.SockType // GetLocalAddress returns the bound path. GetLocalAddress() (Address, tcpip.Error) // Connected returns true iff the ConnectingEndpoint is in the connected // state. ConnectingEndpoints can only be connected to a single endpoint, // so the connection attempt must be aborted if this returns true. Connected() bool // ListeningLocked returns true iff the ConnectingEndpoint is in the // listening state. ConnectingEndpoints cannot make connections while // listening, so the connection attempt must be aborted if this returns // true. ListeningLocked() bool // WaiterQueue returns a pointer to the endpoint's waiter queue. WaiterQueue() *waiter.Queue // contains filtered or unexported methods }
A ConnectingEndpoint is a connectioned unix endpoint that is attempting to establish a bidirectional connection with a BoundEndpoint.
type ControlMessages ¶
type ControlMessages struct { // Rights is a control message containing FDs. Rights RightsControlMessage // Credentials is a control message containing Unix credentials. Credentials CredentialsControlMessage }
A ControlMessages represents a collection of socket control messages.
+stateify savable
func (*ControlMessages) Clone ¶
func (c *ControlMessages) Clone() ControlMessages
Clone clones both the credentials and the rights.
func (*ControlMessages) Empty ¶
func (c *ControlMessages) Empty() bool
Empty returns true iff the ControlMessages does not contain either credentials or rights.
func (*ControlMessages) Release ¶
func (c *ControlMessages) Release(ctx context.Context)
Release releases both the credentials and the rights.
func (*ControlMessages) StateFields ¶
func (c *ControlMessages) StateFields() []string
func (*ControlMessages) StateLoad ¶
func (c *ControlMessages) StateLoad(ctx context.Context, stateSourceObject state.Source)
+checklocksignore
func (*ControlMessages) StateSave ¶
func (c *ControlMessages) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*ControlMessages) StateTypeName ¶
func (c *ControlMessages) StateTypeName() string
type Credentialer ¶
type Credentialer interface { // Passcred returns whether or not the SO_PASSCRED socket option is // enabled on this end. Passcred() bool // ConnectedPasscred returns whether or not the SO_PASSCRED socket option // is enabled on the connected end. ConnectedPasscred() bool }
A Credentialer is a socket or endpoint that supports the SO_PASSCRED socket option.
type CredentialsControlMessage ¶
type CredentialsControlMessage interface { // Equals returns true iff the two messages are equal. Equals(CredentialsControlMessage) bool }
A CredentialsControlMessage is a control message containing Unix credentials.
type Endpoint ¶
type Endpoint interface { Credentialer waiter.Waitable // Close puts the endpoint in a closed state and frees all resources // associated with it. Close(ctx context.Context) // RecvMsg reads data and a control message from the endpoint. This method // does not block if there is no data pending. // // The returned callback should be called if not nil. RecvMsg(ctx context.Context, data [][]byte, args RecvArgs) (RecvOutput, func(), *syserr.Error) // SendMsg writes data and a control message to the endpoint's peer. // This method does not block if the data cannot be written. // // SendMsg does not take ownership of any of its arguments on error. // // If set, notify is a callback that should be called after RecvMesg // completes without mm.activeMu held. SendMsg(context.Context, [][]byte, ControlMessages, BoundEndpoint) (int64, func(), *syserr.Error) // Connect connects this endpoint directly to another. // // This should be called on the client endpoint, and the (bound) // endpoint passed in as a parameter. // // The error codes are the same as Connect. Connect(ctx context.Context, server BoundEndpoint, opts UnixSocketOpts) *syserr.Error // Shutdown closes the read and/or write end of the endpoint connection // to its peer. Shutdown(flags tcpip.ShutdownFlags) *syserr.Error // Listen puts the endpoint in "listen" mode, which allows it to accept // new connections. Listen(ctx context.Context, backlog int) *syserr.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. // // peerAddr if not nil will be populated with the address of the connected // peer on a successful accept. Accept(ctx context.Context, peerAddr *Address, opts UnixSocketOpts) (Endpoint, *syserr.Error) // Bind binds the endpoint to a specific local address and port. // Specifying a NIC is optional. Bind(address Address) *syserr.Error // Type return the socket type, typically either SockStream, SockDgram // or SockSeqpacket. Type() linux.SockType // GetLocalAddress returns the address to which the endpoint is bound. GetLocalAddress() (Address, tcpip.Error) // GetRemoteAddress returns the address to which the endpoint is // connected. GetRemoteAddress() (Address, tcpip.Error) // SetSockOpt sets a socket option. SetSockOpt(opt tcpip.SettableSocketOption) tcpip.Error // SetSockOptInt sets a socket option for simple cases when a value has // the int type. SetSockOptInt(opt tcpip.SockOptInt, v int) tcpip.Error // GetSockOpt gets a socket option. GetSockOpt(opt tcpip.GettableSocketOption) tcpip.Error // GetSockOptInt gets a socket option for simple cases when a return // value has the int type. GetSockOptInt(opt tcpip.SockOptInt) (int, tcpip.Error) // State returns the current state of the socket, as represented by Linux in // procfs. State() uint32 // LastError clears and returns the last error reported by the endpoint. LastError() tcpip.Error // SocketOptions returns the structure which contains all the socket // level options. SocketOptions() *tcpip.SocketOptions }
Endpoint is the interface implemented by Unix transport protocol implementations that expose functionality like sendmsg, recvmsg, connect, etc. to Unix socket implementations.
func NewConnectioned ¶
NewConnectioned creates a new unbound connectionedEndpoint.
func NewConnectionless ¶
NewConnectionless creates a new unbound dgram endpoint.
type HostBoundEndpoint ¶
type HostBoundEndpoint interface { // SetBoundSocketFD will be called on supporting endpoints after // binding a socket on the host filesystem. Implementations should // delegate Listen and Accept calls to the BoundSocketFD. The ownership // of bsFD is transferred to the endpoint. SetBoundSocketFD(ctx context.Context, bsFD BoundSocketFD) error // ResetBoundSocketFD cleans up the BoundSocketFD set by the last successful // SetBoundSocketFD call. ResetBoundSocketFD(ctx context.Context) }
HostBoundEndpoint is an interface that endpoints can implement if they support binding listening and accepting connections from a bound Unix domain socket on the host.
type HostConnectedEndpoint ¶
type HostConnectedEndpoint struct { HostConnectedEndpointRefs // contains filtered or unexported fields }
HostConnectedEndpoint is an implementation of ConnectedEndpoint and Receiver. It is backed by a host fd that was imported at sentry startup. This fd is shared with a hostfs inode, which retains ownership of it.
HostConnectedEndpoint is saveable, since we expect that the host will provide the same fd upon restore.
As of this writing, we only allow Unix sockets to be imported.
+stateify savable
var HostConnectedEndpointobj *HostConnectedEndpoint
obj is used to customize logging. Note that we use a pointer to T so that we do not copy the entire object when passed as a format parameter.
func NewHostConnectedEndpoint ¶
func NewHostConnectedEndpoint(hostFD int, addr string) (*HostConnectedEndpoint, *syserr.Error)
NewHostConnectedEndpoint creates a new HostConnectedEndpoint backed by a host fd imported at sentry startup.
The caller is responsible for calling Init(). Additionally, Release needs to be called twice because HostConnectedEndpoint is both a Receiver and HostConnectedEndpoint.
func (*HostConnectedEndpoint) CloseNotify ¶
func (c *HostConnectedEndpoint) CloseNotify()
CloseNotify implements ConnectedEndpoint.CloseNotify.
func (*HostConnectedEndpoint) CloseRecv ¶
func (c *HostConnectedEndpoint) CloseRecv()
CloseRecv implements Receiver.CloseRecv.
func (*HostConnectedEndpoint) CloseSend ¶
func (c *HostConnectedEndpoint) CloseSend()
CloseSend implements ConnectedEndpoint.CloseSend.
func (*HostConnectedEndpoint) CloseUnread ¶
func (c *HostConnectedEndpoint) CloseUnread()
CloseUnread implements ConnectedEndpoint.CloseUnread.
func (*HostConnectedEndpoint) EventUpdate ¶
func (c *HostConnectedEndpoint) EventUpdate() error
EventUpdate implements ConnectedEndpoint.EventUpdate.
func (*HostConnectedEndpoint) GetLocalAddress ¶
func (c *HostConnectedEndpoint) GetLocalAddress() (Address, tcpip.Error)
GetLocalAddress implements ConnectedEndpoint.GetLocalAddress.
func (*HostConnectedEndpoint) IsRecvClosed ¶
func (c *HostConnectedEndpoint) IsRecvClosed() bool
IsRecvClosed implements Receiver.IsRecvClosed.
func (*HostConnectedEndpoint) IsSendClosed ¶
func (c *HostConnectedEndpoint) IsSendClosed() bool
IsSendClosed implements ConnectedEndpoint.IsSendClosed.
func (*HostConnectedEndpoint) Passcred ¶
func (c *HostConnectedEndpoint) Passcred() bool
Passcred implements ConnectedEndpoint.Passcred.
func (*HostConnectedEndpoint) Readable ¶
func (c *HostConnectedEndpoint) Readable() bool
Readable implements Receiver.Readable.
func (*HostConnectedEndpoint) Recv ¶
func (c *HostConnectedEndpoint) Recv(ctx context.Context, data [][]byte, args RecvArgs) (RecvOutput, bool, *syserr.Error)
Recv implements Receiver.Recv.
func (*HostConnectedEndpoint) RecvMaxQueueSize ¶
func (c *HostConnectedEndpoint) RecvMaxQueueSize() int64
RecvMaxQueueSize implements Receiver.RecvMaxQueueSize.
func (*HostConnectedEndpoint) RecvNotify ¶
func (c *HostConnectedEndpoint) RecvNotify()
RecvNotify implements Receiver.RecvNotify.
func (*HostConnectedEndpoint) RecvQueuedSize ¶
func (c *HostConnectedEndpoint) RecvQueuedSize() int64
RecvQueuedSize implements Receiver.RecvQueuedSize.
func (*HostConnectedEndpoint) Release ¶
func (c *HostConnectedEndpoint) Release(ctx context.Context)
Release implements ConnectedEndpoint.Release and Receiver.Release.
func (*HostConnectedEndpoint) Send ¶
func (c *HostConnectedEndpoint) Send(ctx context.Context, data [][]byte, controlMessages ControlMessages, from Address) (int64, bool, *syserr.Error)
Send implements ConnectedEndpoint.Send.
func (*HostConnectedEndpoint) SendMaxQueueSize ¶
func (c *HostConnectedEndpoint) SendMaxQueueSize() int64
SendMaxQueueSize implements Receiver.SendMaxQueueSize.
func (*HostConnectedEndpoint) SendNotify ¶
func (c *HostConnectedEndpoint) SendNotify()
SendNotify implements ConnectedEndpoint.SendNotify.
func (*HostConnectedEndpoint) SendQueuedSize ¶
func (c *HostConnectedEndpoint) SendQueuedSize() int64
SendQueuedSize implements Receiver.SendQueuedSize.
func (*HostConnectedEndpoint) SetReceiveBufferSize ¶
func (c *HostConnectedEndpoint) SetReceiveBufferSize(v int64) (newSz int64)
SetReceiveBufferSize implements ConnectedEndpoint.SetReceiveBufferSize.
func (*HostConnectedEndpoint) SetSendBufferSize ¶
func (c *HostConnectedEndpoint) SetSendBufferSize(v int64) (newSz int64)
SetSendBufferSize implements ConnectedEndpoint.SetSendBufferSize.
func (*HostConnectedEndpoint) SockType ¶
func (c *HostConnectedEndpoint) SockType() linux.SockType
SockType returns the underlying socket type.
func (*HostConnectedEndpoint) StateFields ¶
func (c *HostConnectedEndpoint) StateFields() []string
func (*HostConnectedEndpoint) StateLoad ¶
func (c *HostConnectedEndpoint) StateLoad(ctx context.Context, stateSourceObject state.Source)
+checklocksignore
func (*HostConnectedEndpoint) StateSave ¶
func (c *HostConnectedEndpoint) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*HostConnectedEndpoint) StateTypeName ¶
func (c *HostConnectedEndpoint) StateTypeName() string
func (*HostConnectedEndpoint) Writable ¶
func (c *HostConnectedEndpoint) Writable() bool
Writable implements ConnectedEndpoint.Writable.
type HostConnectedEndpointRefs ¶
type HostConnectedEndpointRefs struct {
// contains filtered or unexported fields
}
Refs implements refs.RefCounter. It keeps a reference count using atomic operations and calls the destructor when the count reaches zero.
NOTE: Do not introduce additional fields to the Refs struct. It is used by many filesystem objects, and we want to keep it as small as possible (i.e., the same size as using an int64 directly) to avoid taking up extra cache space. In general, this template should not be extended at the cost of performance. If it does not offer enough flexibility for a particular object (example: b/187877947), we should implement the RefCounter/CheckedObject interfaces manually.
+stateify savable
func (*HostConnectedEndpointRefs) DecRef ¶
func (r *HostConnectedEndpointRefs) DecRef(destroy func())
DecRef implements refs.RefCounter.DecRef.
Note that speculative references are counted here. Since they were added prior to real references reaching zero, they will successfully convert to real references. In other words, we see speculative references only in the following case:
A: TryIncRef [speculative increase => sees non-negative references] B: DecRef [real decrease] A: TryIncRef [transform speculative to real]
func (*HostConnectedEndpointRefs) IncRef ¶
func (r *HostConnectedEndpointRefs) IncRef()
IncRef implements refs.RefCounter.IncRef.
func (*HostConnectedEndpointRefs) InitRefs ¶
func (r *HostConnectedEndpointRefs) InitRefs()
InitRefs initializes r with one reference and, if enabled, activates leak checking.
func (*HostConnectedEndpointRefs) LeakMessage ¶
func (r *HostConnectedEndpointRefs) LeakMessage() string
LeakMessage implements refs.CheckedObject.LeakMessage.
func (*HostConnectedEndpointRefs) LogRefs ¶
func (r *HostConnectedEndpointRefs) LogRefs() bool
LogRefs implements refs.CheckedObject.LogRefs.
func (*HostConnectedEndpointRefs) ReadRefs ¶
func (r *HostConnectedEndpointRefs) ReadRefs() int64
ReadRefs returns the current number of references. The returned count is inherently racy and is unsafe to use without external synchronization.
func (*HostConnectedEndpointRefs) RefType ¶
func (r *HostConnectedEndpointRefs) RefType() string
RefType implements refs.CheckedObject.RefType.
func (*HostConnectedEndpointRefs) StateFields ¶
func (r *HostConnectedEndpointRefs) StateFields() []string
func (*HostConnectedEndpointRefs) StateLoad ¶
func (r *HostConnectedEndpointRefs) StateLoad(ctx context.Context, stateSourceObject state.Source)
+checklocksignore
func (*HostConnectedEndpointRefs) StateSave ¶
func (r *HostConnectedEndpointRefs) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*HostConnectedEndpointRefs) StateTypeName ¶
func (r *HostConnectedEndpointRefs) StateTypeName() string
func (*HostConnectedEndpointRefs) TryIncRef ¶
func (r *HostConnectedEndpointRefs) TryIncRef() bool
TryIncRef implements refs.TryRefCounter.TryIncRef.
To do this safely without a loop, a speculative reference is first acquired on the object. This allows multiple concurrent TryIncRef calls to distinguish other TryIncRef calls from genuine references held.
type Receiver ¶
type Receiver interface { // Recv receives a single message. This method does not block. // // notify indicates if RecvNotify should be called. Recv(ctx context.Context, data [][]byte, args RecvArgs) (out RecvOutput, notify bool, err *syserr.Error) // RecvNotify notifies the Receiver of a successful Recv. This must not be // called while holding any endpoint locks. RecvNotify() // CloseRecv prevents the receiving of additional Messages. // // After CloseRecv is called, CloseNotify must also be called. CloseRecv() // CloseNotify notifies the Receiver of recv being closed. This must not be // called while holding any endpoint locks. CloseNotify() // IsRecvClosed returns true if reception of additional messages is closed. IsRecvClosed() bool // Readable returns if messages should be attempted to be received. This // includes when read has been shutdown. Readable() bool // RecvQueuedSize returns the total amount of data currently receivable. // RecvQueuedSize should return -1 if the operation isn't supported. RecvQueuedSize() int64 // RecvMaxQueueSize returns maximum value for RecvQueuedSize. // RecvMaxQueueSize should return -1 if the operation isn't supported. RecvMaxQueueSize() int64 // Release releases any resources owned by the Receiver. It should be // called before dropping all references to a Receiver. Release(ctx context.Context) }
A Receiver can be used to receive Messages.
type RecvArgs ¶
type RecvArgs struct { // Creds indicates if credential control messages are requested by the // caller. This is useful for determining if control messages can be // coalesced. Creds is a hint and can be safely ignored by the // implementation if no coalescing is possible. It is fine to return // credential control messages when none were requested or to not // return credential control messages when they were requested. Creds bool // NumRights is the number of SCM_RIGHTS FDs requested by the caller. // This is useful if one must allocate a buffer to receive a SCM_RIGHTS // message or determine if control messages can be coalesced. numRights // is a hint and can be safely ignored by the implementation if the // number of available SCM_RIGHTS FDs is known and no coalescing is // possible. It is fine for the returned number of SCM_RIGHTS FDs to be // either higher or lower than the requested number. NumRights int // If Peek is true, no data should be consumed from the Endpoint. Any and // all data returned from a peek should be available in the next call to // Recv or RecvMsg. Peek bool }
RecvArgs are the arguments to Endpoint.RecvMsg and Receiver.Recv.
type RecvOutput ¶
type RecvOutput struct { // RecvLen is the number of bytes copied into RecvArgs.Data. RecvLen int64 // MsgLen is the length of the read message consumed for datagram Endpoints. // MsgLen is always the same as RecvLen for stream Endpoints. MsgLen int64 // Source is the source address we received from. Source Address // Control is the ControlMessages read. Control ControlMessages // ControlTrunc indicates that the NumRights hint was used to receive // fewer than the total available SCM_RIGHTS FDs. Additional truncation // may be required by the caller. ControlTrunc bool // UnusedRights is a slice of unused RightsControlMessage which should // be Release()d. UnusedRights []RightsControlMessage }
RecvOutput is the output from Endpoint.RecvMsg and Receiver.Recv.
type RightsControlMessage ¶
type RightsControlMessage interface { // Clone returns a copy of the RightsControlMessage. Clone() RightsControlMessage // Release releases any resources owned by the RightsControlMessage. Release(ctx context.Context) }
A RightsControlMessage is a control message containing FDs.
+stateify savable
type SCMConnectedEndpoint ¶
type SCMConnectedEndpoint struct { HostConnectedEndpoint // contains filtered or unexported fields }
SCMConnectedEndpoint represents an endpoint backed by a host fd that was passed through a gofer Unix socket. It resembles HostConnectedEndpoint, with the following differences:
- SCMConnectedEndpoint is not saveable by default, because the host cannot guarantee the same descriptor number across S/R. However, it can optionally be placed in a closed state before save.
- SCMConnectedEndpoint holds ownership of its fd and notification queue.
+stateify savable
func NewSCMEndpoint ¶
func NewSCMEndpoint(hostFD int, queue *waiter.Queue, addr string, opts UnixSocketOpts) (*SCMConnectedEndpoint, *syserr.Error)
NewSCMEndpoint creates a new SCMConnectedEndpoint backed by a host fd that was passed through a Unix socket.
The caller is responsible for calling Init(). Additionally, Release needs to be called twice because ConnectedEndpoint is both a Receiver and ConnectedEndpoint.
func (*SCMConnectedEndpoint) Init ¶
func (e *SCMConnectedEndpoint) Init() error
Init will do the initialization required without holding other locks.
func (*SCMConnectedEndpoint) Release ¶
func (e *SCMConnectedEndpoint) Release(ctx context.Context)
Release implements ConnectedEndpoint.Release and Receiver.Release.
func (*SCMConnectedEndpoint) StateFields ¶
func (e *SCMConnectedEndpoint) StateFields() []string
func (*SCMConnectedEndpoint) StateLoad ¶
func (e *SCMConnectedEndpoint) StateLoad(ctx context.Context, stateSourceObject state.Source)
+checklocksignore
func (*SCMConnectedEndpoint) StateSave ¶
func (e *SCMConnectedEndpoint) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*SCMConnectedEndpoint) StateTypeName ¶
func (e *SCMConnectedEndpoint) StateTypeName() string
type SCMRights ¶
type SCMRights struct {
FDs []int
}
SCMRights implements RightsControlMessage with host FDs.
func (*SCMRights) Clone ¶
func (c *SCMRights) Clone() RightsControlMessage
Clone implements RightsControlMessage.Clone.
type UnixSocketOpts ¶
type UnixSocketOpts struct { // If true, the endpoint will be put in a closed state before save; if false, an attempt to save // will throw. DisconnectOnSave bool }
UnixSocketOpts is a container for configuration options for gvisor's management of unix sockets. +stateify savable
func (*UnixSocketOpts) StateFields ¶
func (u *UnixSocketOpts) StateFields() []string
func (*UnixSocketOpts) StateLoad ¶
func (u *UnixSocketOpts) StateLoad(ctx context.Context, stateSourceObject state.Source)
+checklocksignore
func (*UnixSocketOpts) StateSave ¶
func (u *UnixSocketOpts) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*UnixSocketOpts) StateTypeName ¶
func (u *UnixSocketOpts) StateTypeName() string
Source Files ¶
- connectioned.go
- connectioned_state.go
- connectionless.go
- connectionless_state.go
- endpoint_mutex.go
- host.go
- host_connected_endpoint_refs.go
- host_iovec.go
- host_unsafe.go
- queue.go
- queue_mutex.go
- queue_refs.go
- save_restore.go
- stream_queue_receiver_mutex.go
- transport_message_list.go
- transport_state_autogen.go
- transport_unsafe_state_autogen.go
- unix.go