summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/socket/netlink/socket.go
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-10-24 11:04:11 -0700
committerShentubot <shentubot@google.com>2018-10-24 11:05:08 -0700
commit425dccdd7ed035a671aaf8da1982f7b029365d66 (patch)
tree542f87477c0928dae95d035e2551eedb6606de72 /pkg/sentry/socket/netlink/socket.go
parentc99006a240be6381f5ac6c6c7c70839df84e1c1d (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/socket/netlink/socket.go')
-rw-r--r--pkg/sentry/socket/netlink/socket.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/pkg/sentry/socket/netlink/socket.go b/pkg/sentry/socket/netlink/socket.go
index 4d4130a4c..f901cfa0b 100644
--- a/pkg/sentry/socket/netlink/socket.go
+++ b/pkg/sentry/socket/netlink/socket.go
@@ -109,16 +109,16 @@ func NewSocket(t *kernel.Task, protocol Protocol) (*Socket, *syserr.Error) {
// Bind the endpoint for good measure so we can connect to it. The
// bound address will never be exposed.
- if terr := ep.Bind(tcpip.FullAddress{Addr: "dummy"}, nil); terr != nil {
+ if err := ep.Bind(tcpip.FullAddress{Addr: "dummy"}, nil); err != nil {
ep.Close()
- return nil, syserr.TranslateNetstackError(terr)
+ return nil, err
}
// Create a connection from which the kernel can write messages.
- connection, terr := ep.(transport.BoundEndpoint).UnidirectionalConnect()
- if terr != nil {
+ connection, err := ep.(transport.BoundEndpoint).UnidirectionalConnect()
+ if err != nil {
ep.Close()
- return nil, syserr.TranslateNetstackError(terr)
+ return nil, err
}
return &Socket{
@@ -424,11 +424,11 @@ func (s *Socket) sendResponse(ctx context.Context, ms *MessageSet) *syserr.Error
if len(bufs) > 0 {
// RecvMsg never receives the address, so we don't need to send
// one.
- _, notify, terr := s.connection.Send(bufs, transport.ControlMessages{}, tcpip.FullAddress{})
+ _, notify, err := s.connection.Send(bufs, transport.ControlMessages{}, tcpip.FullAddress{})
// If the buffer is full, we simply drop messages, just like
// Linux.
- if terr != nil && terr != tcpip.ErrWouldBlock {
- return syserr.TranslateNetstackError(terr)
+ if err != nil && err != syserr.ErrWouldBlock {
+ return err
}
if notify {
s.connection.SendNotify()
@@ -448,9 +448,9 @@ func (s *Socket) sendResponse(ctx context.Context, ms *MessageSet) *syserr.Error
PortID: uint32(ms.PortID),
})
- _, notify, terr := s.connection.Send([][]byte{m.Finalize()}, transport.ControlMessages{}, tcpip.FullAddress{})
- if terr != nil && terr != tcpip.ErrWouldBlock {
- return syserr.TranslateNetstackError(terr)
+ _, notify, err := s.connection.Send([][]byte{m.Finalize()}, transport.ControlMessages{}, tcpip.FullAddress{})
+ if err != nil && err != syserr.ErrWouldBlock {
+ return err
}
if notify {
s.connection.SendNotify()