summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/link/tun
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-03-03 18:43:27 +0000
committergVisor bot <gvisor-bot@google.com>2021-03-03 18:43:27 +0000
commitaae5455fe381c4cbc956f61c971284ee05c52dfc (patch)
tree2b1cb0233968680dcd0374f20ee826cf311bda95 /pkg/tcpip/link/tun
parente2599d556573b05eb3714c1e791fa29431dc3d3f (diff)
parenta9441aea2780da8c93da1c73da860219f98438de (diff)
Merge release-20210301.0-5-ga9441aea2 (automated)
Diffstat (limited to 'pkg/tcpip/link/tun')
-rw-r--r--pkg/tcpip/link/tun/tun_unsafe.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/pkg/tcpip/link/tun/tun_unsafe.go b/pkg/tcpip/link/tun/tun_unsafe.go
index 09ca9b527..0591fbd63 100644
--- a/pkg/tcpip/link/tun/tun_unsafe.go
+++ b/pkg/tcpip/link/tun/tun_unsafe.go
@@ -18,24 +18,25 @@
package tun
import (
- "syscall"
"unsafe"
+
+ "golang.org/x/sys/unix"
)
// Open opens the specified TUN device, sets it to non-blocking mode, and
// returns its file descriptor.
func Open(name string) (int, error) {
- return open(name, syscall.IFF_TUN|syscall.IFF_NO_PI)
+ return open(name, unix.IFF_TUN|unix.IFF_NO_PI)
}
// OpenTAP opens the specified TAP device, sets it to non-blocking mode, and
// returns its file descriptor.
func OpenTAP(name string) (int, error) {
- return open(name, syscall.IFF_TAP|syscall.IFF_NO_PI)
+ return open(name, unix.IFF_TAP|unix.IFF_NO_PI)
}
func open(name string, flags uint16) (int, error) {
- fd, err := syscall.Open("/dev/net/tun", syscall.O_RDWR, 0)
+ fd, err := unix.Open("/dev/net/tun", unix.O_RDWR, 0)
if err != nil {
return -1, err
}
@@ -48,14 +49,14 @@ func open(name string, flags uint16) (int, error) {
copy(ifr.name[:], name)
ifr.flags = flags
- _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.TUNSETIFF, uintptr(unsafe.Pointer(&ifr)))
+ _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(fd), unix.TUNSETIFF, uintptr(unsafe.Pointer(&ifr)))
if errno != 0 {
- syscall.Close(fd)
+ unix.Close(fd)
return -1, errno
}
- if err = syscall.SetNonblock(fd, true); err != nil {
- syscall.Close(fd)
+ if err = unix.SetNonblock(fd, true); err != nil {
+ unix.Close(fd)
return -1, err
}