mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add S/R logic for host.ConnectedEndpoint
Otherwise ConnectedEndpoint.sndbuf will be restored as 0 and writes to the socket will fail with EAGAIN. PiperOrigin-RevId: 368746660
This commit is contained in:
committed by
gVisor bot
parent
b5919d3065
commit
2e50229749
@@ -68,3 +68,10 @@ func (i *inode) afterLoad() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// afterLoad is invoked by stateify.
|
||||
func (c *ConnectedEndpoint) afterLoad() {
|
||||
if err := c.initFromOptions(); err != nil {
|
||||
panic(fmt.Sprintf("initFromOptions failed: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import (
|
||||
func newEndpoint(ctx context.Context, hostFD int, queue *waiter.Queue) (transport.Endpoint, error) {
|
||||
// Set up an external transport.Endpoint using the host fd.
|
||||
addr := fmt.Sprintf("hostfd:[%d]", hostFD)
|
||||
e, err := NewConnectedEndpoint(ctx, hostFD, addr, true /* saveable */)
|
||||
e, err := NewConnectedEndpoint(hostFD, addr)
|
||||
if err != nil {
|
||||
return nil, err.ToError()
|
||||
}
|
||||
@@ -86,7 +86,10 @@ type ConnectedEndpoint struct {
|
||||
// for restoring them.
|
||||
func (c *ConnectedEndpoint) init() *syserr.Error {
|
||||
c.InitRefs()
|
||||
return c.initFromOptions()
|
||||
}
|
||||
|
||||
func (c *ConnectedEndpoint) initFromOptions() *syserr.Error {
|
||||
family, err := unix.GetsockoptInt(c.fd, unix.SOL_SOCKET, unix.SO_DOMAIN)
|
||||
if err != nil {
|
||||
return syserr.FromError(err)
|
||||
@@ -123,7 +126,7 @@ func (c *ConnectedEndpoint) init() *syserr.Error {
|
||||
// The caller is responsible for calling Init(). Additionaly, Release needs to
|
||||
// be called twice because ConnectedEndpoint is both a transport.Receiver and
|
||||
// transport.ConnectedEndpoint.
|
||||
func NewConnectedEndpoint(ctx context.Context, hostFD int, addr string, saveable bool) (*ConnectedEndpoint, *syserr.Error) {
|
||||
func NewConnectedEndpoint(hostFD int, addr string) (*ConnectedEndpoint, *syserr.Error) {
|
||||
e := ConnectedEndpoint{
|
||||
fd: hostFD,
|
||||
addr: addr,
|
||||
|
||||
Reference in New Issue
Block a user