summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/socket/netstack
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2019-12-24 17:03:51 +0000
committergVisor bot <gvisor-bot@google.com>2019-12-24 17:03:51 +0000
commit6d8d66038fd9439822069fd283761d7ea939a433 (patch)
tree188f7a8eee7a3c45dbbfb2871c40d0ea204d6b31 /pkg/sentry/socket/netstack
parent95108940a01c1c1bbf6e8924e27b6cf80ca78ba1 (diff)
parente013c48c78c9a7daf245b7de9563e3a0bd8a1e97 (diff)
Merge release-20191213.0-48-ge013c48 (automated)
Diffstat (limited to 'pkg/sentry/socket/netstack')
-rwxr-xr-xpkg/sentry/socket/netstack/netstack.go42
1 files changed, 41 insertions, 1 deletions
diff --git a/pkg/sentry/socket/netstack/netstack.go b/pkg/sentry/socket/netstack/netstack.go
index 140851c17..d2f263402 100755
--- a/pkg/sentry/socket/netstack/netstack.go
+++ b/pkg/sentry/socket/netstack/netstack.go
@@ -1323,6 +1323,21 @@ func getSockOptIP(t *kernel.Task, ep commonEndpoint, name, outLen int, family in
}
return int32(v), nil
+ case linux.IP_RECVTOS:
+ if outLen < sizeOfInt32 {
+ return nil, syserr.ErrInvalidArgument
+ }
+
+ var v tcpip.ReceiveTOSOption
+ if err := ep.GetSockOpt(&v); err != nil {
+ return nil, syserr.TranslateNetstackError(err)
+ }
+
+ if v {
+ return int32(1), nil
+ }
+ return int32(0), nil
+
default:
emitUnimplementedEventIP(t, name)
}
@@ -1808,6 +1823,16 @@ func setSockOptIP(t *kernel.Task, ep commonEndpoint, name int, optVal []byte) *s
}
return syserr.TranslateNetstackError(ep.SetSockOpt(tcpip.IPv4TOSOption(v)))
+ case linux.IP_RECVTOS:
+ v, err := parseIntOrChar(optVal)
+ if err != nil {
+ return err
+ }
+
+ return syserr.TranslateNetstackError(ep.SetSockOpt(
+ tcpip.ReceiveTOSOption(v != 0),
+ ))
+
case linux.IP_ADD_SOURCE_MEMBERSHIP,
linux.IP_BIND_ADDRESS_NO_PORT,
linux.IP_BLOCK_SOURCE,
@@ -1828,7 +1853,6 @@ func setSockOptIP(t *kernel.Task, ep commonEndpoint, name int, optVal []byte) *s
linux.IP_RECVFRAGSIZE,
linux.IP_RECVOPTS,
linux.IP_RECVORIGDSTADDR,
- linux.IP_RECVTOS,
linux.IP_RECVTTL,
linux.IP_RETOPTS,
linux.IP_TRANSPARENT,
@@ -2139,6 +2163,21 @@ func (s *SocketOperations) fillCmsgInq(cmsg *socket.ControlMessages) {
cmsg.IP.Inq = int32(len(s.readView) + rcvBufUsed)
}
+func (s *SocketOperations) fillCmsgTOS(cmsg *socket.ControlMessages) {
+ if s.skType != linux.SOCK_DGRAM {
+ return
+ }
+ var receiveTOS tcpip.ReceiveTOSOption
+ if err := s.Endpoint.GetSockOpt(&receiveTOS); err != nil {
+ return
+ }
+ if !receiveTOS {
+ return
+ }
+ cmsg.IP.HasTOS = s.readCM.HasTOS
+ cmsg.IP.TOS = s.readCM.TOS
+}
+
// nonBlockingRead issues a non-blocking read.
//
// TODO(b/78348848): Support timestamps for stream sockets.
@@ -2244,6 +2283,7 @@ func (s *SocketOperations) nonBlockingRead(ctx context.Context, dst usermem.IOSe
cmsg := s.controlMessages()
s.fillCmsgInq(&cmsg)
+ s.fillCmsgTOS(&cmsg)
return n, flags, addr, addrLen, cmsg, syserr.FromError(err)
}