diff options
author | Ian Gudger <igudger@google.com> | 2018-10-24 11:04:11 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-10-24 11:05:08 -0700 |
commit | 425dccdd7ed035a671aaf8da1982f7b029365d66 (patch) | |
tree | 542f87477c0928dae95d035e2551eedb6606de72 /pkg/sentry/fs/gofer | |
parent | c99006a240be6381f5ac6c6c7c70839df84e1c1d (diff) |
Convert Unix transport to syserr
Previously this code used the tcpip error space. Since it is no longer part of
netstack, it can use the sentry's error space (except for a few cases where
there is still some shared code. This reduces the number of error space
conversions required for hot Unix socket operations.
PiperOrigin-RevId: 218541611
Change-Id: I3d13047006a8245b5dfda73364d37b8a453784bb
Diffstat (limited to 'pkg/sentry/fs/gofer')
-rw-r--r-- | pkg/sentry/fs/gofer/BUILD | 2 | ||||
-rw-r--r-- | pkg/sentry/fs/gofer/socket.go | 32 |
2 files changed, 17 insertions, 17 deletions
diff --git a/pkg/sentry/fs/gofer/BUILD b/pkg/sentry/fs/gofer/BUILD index c9e531e40..35ffadd13 100644 --- a/pkg/sentry/fs/gofer/BUILD +++ b/pkg/sentry/fs/gofer/BUILD @@ -43,8 +43,8 @@ go_library( "//pkg/sentry/safemem", "//pkg/sentry/socket/unix/transport", "//pkg/sentry/usermem", + "//pkg/syserr", "//pkg/syserror", - "//pkg/tcpip", "//pkg/unet", "//pkg/waiter", ], diff --git a/pkg/sentry/fs/gofer/socket.go b/pkg/sentry/fs/gofer/socket.go index 76ce58810..ce6d3d5c3 100644 --- a/pkg/sentry/fs/gofer/socket.go +++ b/pkg/sentry/fs/gofer/socket.go @@ -20,7 +20,7 @@ import ( "gvisor.googlesource.com/gvisor/pkg/sentry/fs" "gvisor.googlesource.com/gvisor/pkg/sentry/fs/host" "gvisor.googlesource.com/gvisor/pkg/sentry/socket/unix/transport" - "gvisor.googlesource.com/gvisor/pkg/tcpip" + "gvisor.googlesource.com/gvisor/pkg/syserr" "gvisor.googlesource.com/gvisor/pkg/waiter" ) @@ -74,10 +74,10 @@ func unixSockToP9(t transport.SockType) (p9.ConnectFlags, bool) { } // BidirectionalConnect implements ConnectableEndpoint.BidirectionalConnect. -func (e *endpoint) BidirectionalConnect(ce transport.ConnectingEndpoint, returnConnect func(transport.Receiver, transport.ConnectedEndpoint)) *tcpip.Error { +func (e *endpoint) BidirectionalConnect(ce transport.ConnectingEndpoint, returnConnect func(transport.Receiver, transport.ConnectedEndpoint)) *syserr.Error { cf, ok := unixSockToP9(ce.Type()) if !ok { - return tcpip.ErrConnectionRefused + return syserr.ErrConnectionRefused } // No lock ordering required as only the ConnectingEndpoint has a mutex. @@ -86,24 +86,24 @@ func (e *endpoint) BidirectionalConnect(ce transport.ConnectingEndpoint, returnC // Check connecting state. if ce.Connected() { ce.Unlock() - return tcpip.ErrAlreadyConnected + return syserr.ErrAlreadyConnected } if ce.Listening() { ce.Unlock() - return tcpip.ErrInvalidEndpointState + return syserr.ErrInvalidEndpointState } hostFile, err := e.file.Connect(cf) if err != nil { ce.Unlock() - return tcpip.ErrConnectionRefused + return syserr.ErrConnectionRefused } - c, terr := host.NewConnectedEndpoint(hostFile, ce.WaiterQueue(), e.path) - if terr != nil { + c, serr := host.NewConnectedEndpoint(hostFile, ce.WaiterQueue(), e.path) + if serr != nil { ce.Unlock() - log.Warningf("Gofer returned invalid host socket for BidirectionalConnect; file %+v flags %+v: %v", e.file, cf, terr) - return terr + log.Warningf("Gofer returned invalid host socket for BidirectionalConnect; file %+v flags %+v: %v", e.file, cf, serr) + return serr } returnConnect(c, c) @@ -115,16 +115,16 @@ func (e *endpoint) BidirectionalConnect(ce transport.ConnectingEndpoint, returnC // UnidirectionalConnect implements // transport.BoundEndpoint.UnidirectionalConnect. -func (e *endpoint) UnidirectionalConnect() (transport.ConnectedEndpoint, *tcpip.Error) { +func (e *endpoint) UnidirectionalConnect() (transport.ConnectedEndpoint, *syserr.Error) { hostFile, err := e.file.Connect(p9.DgramSocket) if err != nil { - return nil, tcpip.ErrConnectionRefused + return nil, syserr.ErrConnectionRefused } - c, terr := host.NewConnectedEndpoint(hostFile, &waiter.Queue{}, e.path) - if terr != nil { - log.Warningf("Gofer returned invalid host socket for UnidirectionalConnect; file %+v: %v", e.file, terr) - return nil, terr + c, serr := host.NewConnectedEndpoint(hostFile, &waiter.Queue{}, e.path) + if serr != nil { + log.Warningf("Gofer returned invalid host socket for UnidirectionalConnect; file %+v: %v", e.file, serr) + return nil, serr } c.Init() |