diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-07-18 22:49:12 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-07-18 22:49:12 +0000 |
commit | 881e2e983db5d5443cf94ef90655e7f698e8961c (patch) | |
tree | 45729e32a35e2250ac1e11c66916ee21b273b7c6 /pkg/sentry/socket/control | |
parent | 2fcf4543244a8762f35e2eced37d65e0c91b2896 (diff) | |
parent | eefa817cfdb04ff07e7069396f21bd6ba2c89957 (diff) |
Merge eefa817c (automated)
Diffstat (limited to 'pkg/sentry/socket/control')
-rw-r--r-- | pkg/sentry/socket/control/control.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/pkg/sentry/socket/control/control.go b/pkg/sentry/socket/control/control.go index 4f4a20dfe..4e95101b7 100644 --- a/pkg/sentry/socket/control/control.go +++ b/pkg/sentry/socket/control/control.go @@ -225,14 +225,14 @@ func putCmsg(buf []byte, flags int, msgType uint32, align uint, data []int32) ([ return alignSlice(buf, align), flags } -func putCmsgStruct(buf []byte, msgType uint32, align uint, data interface{}) []byte { +func putCmsgStruct(buf []byte, msgLevel, msgType uint32, align uint, data interface{}) []byte { if cap(buf)-len(buf) < linux.SizeOfControlMessageHeader { return buf } ob := buf buf = putUint64(buf, uint64(linux.SizeOfControlMessageHeader)) - buf = putUint32(buf, linux.SOL_SOCKET) + buf = putUint32(buf, msgLevel) buf = putUint32(buf, msgType) hdrBuf := buf @@ -307,12 +307,24 @@ func alignSlice(buf []byte, align uint) []byte { func PackTimestamp(t *kernel.Task, timestamp int64, buf []byte) []byte { return putCmsgStruct( buf, + linux.SOL_SOCKET, linux.SO_TIMESTAMP, t.Arch().Width(), linux.NsecToTimeval(timestamp), ) } +// PackInq packs a TCP_INQ socket control message. +func PackInq(t *kernel.Task, inq int32, buf []byte) []byte { + return putCmsgStruct( + buf, + linux.SOL_TCP, + linux.TCP_INQ, + 4, + inq, + ) +} + // Parse parses a raw socket control message into portable objects. func Parse(t *kernel.Task, socketOrEndpoint interface{}, buf []byte) (transport.ControlMessages, error) { var ( |