summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/link/sharedmem/tx.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/tcpip/link/sharedmem/tx.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/tcpip/link/sharedmem/tx.go')
-rw-r--r--pkg/tcpip/link/sharedmem/tx.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/pkg/tcpip/link/sharedmem/tx.go b/pkg/tcpip/link/sharedmem/tx.go
index 44f421c2d..e3210051f 100644
--- a/pkg/tcpip/link/sharedmem/tx.go
+++ b/pkg/tcpip/link/sharedmem/tx.go
@@ -16,8 +16,8 @@ package sharedmem
import (
"math"
- "syscall"
+ "golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/tcpip/buffer"
"gvisor.dev/gvisor/pkg/tcpip/link/sharedmem/queue"
)
@@ -48,14 +48,14 @@ func (t *tx) init(mtu uint32, c *QueueConfig) error {
rxPipe, err := getBuffer(c.RxPipeFD)
if err != nil {
- syscall.Munmap(txPipe)
+ unix.Munmap(txPipe)
return err
}
data, err := getBuffer(c.DataFD)
if err != nil {
- syscall.Munmap(txPipe)
- syscall.Munmap(rxPipe)
+ unix.Munmap(txPipe)
+ unix.Munmap(rxPipe)
return err
}
@@ -72,9 +72,9 @@ func (t *tx) init(mtu uint32, c *QueueConfig) error {
// called if init() has previously succeeded.
func (t *tx) cleanup() {
a, b := t.q.Bytes()
- syscall.Munmap(a)
- syscall.Munmap(b)
- syscall.Munmap(t.data)
+ unix.Munmap(a)
+ unix.Munmap(b)
+ unix.Munmap(t.data)
}
// transmit sends a packet made of bufs. Returns a boolean that specifies
@@ -145,17 +145,17 @@ func (t *tx) transmit(bufs ...buffer.View) bool {
// getBuffer returns a memory region mapped to the full contents of the given
// file descriptor.
func getBuffer(fd int) ([]byte, error) {
- var s syscall.Stat_t
- if err := syscall.Fstat(fd, &s); err != nil {
+ var s unix.Stat_t
+ if err := unix.Fstat(fd, &s); err != nil {
return nil, err
}
// Check that size doesn't overflow an int.
if s.Size > int64(^uint(0)>>1) {
- return nil, syscall.EDOM
+ return nil, unix.EDOM
}
- return syscall.Mmap(fd, 0, int(s.Size), syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_SHARED|syscall.MAP_FILE)
+ return unix.Mmap(fd, 0, int(s.Size), unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED|unix.MAP_FILE)
}
// idDescriptor is used by idManager to either point to a tx buffer (in case