diff options
author | Ayush Ranjan <ayushranjan@google.com> | 2021-03-06 09:52:23 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-03-06 09:54:09 -0800 |
commit | 0a909ba75a556db6acbb2a30d2e741b365217c83 (patch) | |
tree | ef8cb5bcc1a6fcdb638c1d1687d530e7d4cc0908 /test/iptables/iptables_unsafe.go | |
parent | fb733cdb8f4050fbc8ad083ea05c3e98b99b9acc (diff) |
[op] Replace syscall package usage with golang.org/x/sys/unix in test/.
The syscall package has been deprecated in favor of golang.org/x/sys.
Note that syscall is still used in some places because the following don't seem
to have an equivalent in unix package:
- syscall.SysProcIDMap
- syscall.Credential
Updates #214
PiperOrigin-RevId: 361332034
Diffstat (limited to 'test/iptables/iptables_unsafe.go')
-rw-r--r-- | test/iptables/iptables_unsafe.go | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/test/iptables/iptables_unsafe.go b/test/iptables/iptables_unsafe.go index bd85a8fea..dd1a1c082 100644 --- a/test/iptables/iptables_unsafe.go +++ b/test/iptables/iptables_unsafe.go @@ -16,12 +16,13 @@ package iptables import ( "fmt" - "syscall" "unsafe" + + "golang.org/x/sys/unix" ) type originalDstError struct { - errno syscall.Errno + errno unix.Errno } func (e originalDstError) Error() string { @@ -32,27 +33,27 @@ func (e originalDstError) Error() string { // getsockopt. const SO_ORIGINAL_DST = 80 -func originalDestination4(connfd int) (syscall.RawSockaddrInet4, error) { - var addr syscall.RawSockaddrInet4 - var addrLen uint32 = syscall.SizeofSockaddrInet4 - if errno := originalDestination(connfd, syscall.SOL_IP, unsafe.Pointer(&addr), &addrLen); errno != 0 { - return syscall.RawSockaddrInet4{}, originalDstError{errno} +func originalDestination4(connfd int) (unix.RawSockaddrInet4, error) { + var addr unix.RawSockaddrInet4 + var addrLen uint32 = unix.SizeofSockaddrInet4 + if errno := originalDestination(connfd, unix.SOL_IP, unsafe.Pointer(&addr), &addrLen); errno != 0 { + return unix.RawSockaddrInet4{}, originalDstError{errno} } return addr, nil } -func originalDestination6(connfd int) (syscall.RawSockaddrInet6, error) { - var addr syscall.RawSockaddrInet6 - var addrLen uint32 = syscall.SizeofSockaddrInet6 - if errno := originalDestination(connfd, syscall.SOL_IPV6, unsafe.Pointer(&addr), &addrLen); errno != 0 { - return syscall.RawSockaddrInet6{}, originalDstError{errno} +func originalDestination6(connfd int) (unix.RawSockaddrInet6, error) { + var addr unix.RawSockaddrInet6 + var addrLen uint32 = unix.SizeofSockaddrInet6 + if errno := originalDestination(connfd, unix.SOL_IPV6, unsafe.Pointer(&addr), &addrLen); errno != 0 { + return unix.RawSockaddrInet6{}, originalDstError{errno} } return addr, nil } -func originalDestination(connfd int, level uintptr, optval unsafe.Pointer, optlen *uint32) syscall.Errno { - _, _, errno := syscall.Syscall6( - syscall.SYS_GETSOCKOPT, +func originalDestination(connfd int, level uintptr, optval unsafe.Pointer, optlen *uint32) unix.Errno { + _, _, errno := unix.Syscall6( + unix.SYS_GETSOCKOPT, uintptr(connfd), level, SO_ORIGINAL_DST, |