summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/link/rawfile
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-07-15 22:20:36 +0000
committergVisor bot <gvisor-bot@google.com>2020-07-15 22:20:36 +0000
commitc75b9053f6dd6312317c0c5d9ba36f8f00db8e88 (patch)
tree94f7a049b70d4dd929d1ea74e7df336fb42569ea /pkg/tcpip/link/rawfile
parenta89a57d437616c9d2463a8d78c37080e4d6edf19 (diff)
parentdb653bb34baeba24b8b658eb0985e4c5185344cb (diff)
Merge release-20200622.1-164-gdb653bb34 (automated)
Diffstat (limited to 'pkg/tcpip/link/rawfile')
-rw-r--r--pkg/tcpip/link/rawfile/rawfile_unsafe.go32
1 files changed, 4 insertions, 28 deletions
diff --git a/pkg/tcpip/link/rawfile/rawfile_unsafe.go b/pkg/tcpip/link/rawfile/rawfile_unsafe.go
index 69de6eb3e..f4c32c2da 100644
--- a/pkg/tcpip/link/rawfile/rawfile_unsafe.go
+++ b/pkg/tcpip/link/rawfile/rawfile_unsafe.go
@@ -66,38 +66,14 @@ func NonBlockingWrite(fd int, buf []byte) *tcpip.Error {
return nil
}
-// NonBlockingWrite3 writes up to three byte slices to a file descriptor in a
-// single syscall. It fails if partial data is written.
-func NonBlockingWrite3(fd int, b1, b2, b3 []byte) *tcpip.Error {
- // If there is no second and third buffer, issue a regular write.
- if len(b2) == 0 && len(b3) == 0 {
- return NonBlockingWrite(fd, b1)
- }
-
- // Build the iovec that represents them and issue a writev syscall.
- iovec := [3]syscall.Iovec{
- {
- Base: &b1[0],
- Len: uint64(len(b1)),
- },
- {
- Base: &b2[0],
- Len: uint64(len(b2)),
- },
- }
- iovecLen := uintptr(2)
-
- if len(b3) > 0 {
- iovecLen++
- iovec[2].Base = &b3[0]
- iovec[2].Len = uint64(len(b3))
- }
-
+// NonBlockingWriteIovec writes iovec to a file descriptor in a single syscall.
+// It fails if partial data is written.
+func NonBlockingWriteIovec(fd int, iovec []syscall.Iovec) *tcpip.Error {
+ iovecLen := uintptr(len(iovec))
_, _, e := syscall.RawSyscall(syscall.SYS_WRITEV, uintptr(fd), uintptr(unsafe.Pointer(&iovec[0])), iovecLen)
if e != 0 {
return TranslateErrno(e)
}
-
return nil
}