summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/socket/socket.go
diff options
context:
space:
mode:
authorAyush Ranjan <ayushranjan@google.com>2021-03-03 10:23:55 -0800
committergVisor bot <gvisor-bot@google.com>2021-03-03 10:25:58 -0800
commita9441aea2780da8c93da1c73da860219f98438de (patch)
tree8b12915756f5bfb926218214cd7bc0b3281605fd /pkg/sentry/socket/socket.go
parentb8a5420f49a2afd622ec08b5019e1bf537f7da82 (diff)
[op] Replace syscall package usage with golang.org/x/sys/unix in pkg/.
The syscall package has been deprecated in favor of golang.org/x/sys. Note that syscall is still used in the following places: - pkg/sentry/socket/hostinet/stack.go: some netlink related functionalities are not yet available in golang.org/x/sys. - syscall.Stat_t is still used in some places because os.FileInfo.Sys() still returns it and not unix.Stat_t. Updates #214 PiperOrigin-RevId: 360701387
Diffstat (limited to 'pkg/sentry/socket/socket.go')
-rw-r--r--pkg/sentry/socket/socket.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/pkg/sentry/socket/socket.go b/pkg/sentry/socket/socket.go
index cc535d794..909341dcf 100644
--- a/pkg/sentry/socket/socket.go
+++ b/pkg/sentry/socket/socket.go
@@ -21,8 +21,8 @@ import (
"bytes"
"fmt"
"sync/atomic"
- "syscall"
+ "golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/abi/linux"
"gvisor.dev/gvisor/pkg/binary"
"gvisor.dev/gvisor/pkg/context"
@@ -198,42 +198,42 @@ type SocketVFS2 interface {
//
// It is implemented by both Socket and SocketVFS2.
type SocketOps interface {
- // Connect implements the connect(2) linux syscall.
+ // Connect implements the connect(2) linux unix.
Connect(t *kernel.Task, sockaddr []byte, blocking bool) *syserr.Error
- // Accept implements the accept4(2) linux syscall.
+ // Accept implements the accept4(2) linux unix.
// Returns fd, real peer address length and error. Real peer address
// length is only set if len(peer) > 0.
Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (int32, linux.SockAddr, uint32, *syserr.Error)
- // Bind implements the bind(2) linux syscall.
+ // Bind implements the bind(2) linux unix.
Bind(t *kernel.Task, sockaddr []byte) *syserr.Error
- // Listen implements the listen(2) linux syscall.
+ // Listen implements the listen(2) linux unix.
Listen(t *kernel.Task, backlog int) *syserr.Error
- // Shutdown implements the shutdown(2) linux syscall.
+ // Shutdown implements the shutdown(2) linux unix.
Shutdown(t *kernel.Task, how int) *syserr.Error
- // GetSockOpt implements the getsockopt(2) linux syscall.
+ // GetSockOpt implements the getsockopt(2) linux unix.
GetSockOpt(t *kernel.Task, level int, name int, outPtr usermem.Addr, outLen int) (marshal.Marshallable, *syserr.Error)
- // SetSockOpt implements the setsockopt(2) linux syscall.
+ // SetSockOpt implements the setsockopt(2) linux unix.
SetSockOpt(t *kernel.Task, level int, name int, opt []byte) *syserr.Error
- // GetSockName implements the getsockname(2) linux syscall.
+ // GetSockName implements the getsockname(2) linux unix.
//
// addrLen is the address length to be returned to the application, not
// necessarily the actual length of the address.
GetSockName(t *kernel.Task) (addr linux.SockAddr, addrLen uint32, err *syserr.Error)
- // GetPeerName implements the getpeername(2) linux syscall.
+ // GetPeerName implements the getpeername(2) linux unix.
//
// addrLen is the address length to be returned to the application, not
// necessarily the actual length of the address.
GetPeerName(t *kernel.Task) (addr linux.SockAddr, addrLen uint32, err *syserr.Error)
- // RecvMsg implements the recvmsg(2) linux syscall.
+ // RecvMsg implements the recvmsg(2) linux unix.
//
// senderAddrLen is the address length to be returned to the application,
// not necessarily the actual length of the address.
@@ -246,7 +246,7 @@ type SocketOps interface {
// If err != nil, the recv was not successful.
RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags int, haveDeadline bool, deadline ktime.Time, senderRequested bool, controlDataLen uint64) (n int, msgFlags int, senderAddr linux.SockAddr, senderAddrLen uint32, controlMessages ControlMessages, err *syserr.Error)
- // SendMsg implements the sendmsg(2) linux syscall. SendMsg does not take
+ // SendMsg implements the sendmsg(2) linux unix. SendMsg does not take
// ownership of the ControlMessage on error.
//
// If n > 0, err will either be nil or an error from t.Block.
@@ -569,21 +569,21 @@ func emitUnimplementedEvent(t *kernel.Task, name int) {
// given family.
func UnmarshalSockAddr(family int, data []byte) linux.SockAddr {
switch family {
- case syscall.AF_INET:
+ case unix.AF_INET:
var addr linux.SockAddrInet
- binary.Unmarshal(data[:syscall.SizeofSockaddrInet4], usermem.ByteOrder, &addr)
+ binary.Unmarshal(data[:unix.SizeofSockaddrInet4], usermem.ByteOrder, &addr)
return &addr
- case syscall.AF_INET6:
+ case unix.AF_INET6:
var addr linux.SockAddrInet6
- binary.Unmarshal(data[:syscall.SizeofSockaddrInet6], usermem.ByteOrder, &addr)
+ binary.Unmarshal(data[:unix.SizeofSockaddrInet6], usermem.ByteOrder, &addr)
return &addr
- case syscall.AF_UNIX:
+ case unix.AF_UNIX:
var addr linux.SockAddrUnix
- binary.Unmarshal(data[:syscall.SizeofSockaddrUnix], usermem.ByteOrder, &addr)
+ binary.Unmarshal(data[:unix.SizeofSockaddrUnix], usermem.ByteOrder, &addr)
return &addr
- case syscall.AF_NETLINK:
+ case unix.AF_NETLINK:
var addr linux.SockAddrNetlink
- binary.Unmarshal(data[:syscall.SizeofSockaddrNetlink], usermem.ByteOrder, &addr)
+ binary.Unmarshal(data[:unix.SizeofSockaddrNetlink], usermem.ByteOrder, &addr)
return &addr
default:
panic(fmt.Sprintf("Unsupported socket family %v", family))