summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/socket
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-09-01 16:58:01 +0000
committergVisor bot <gvisor-bot@google.com>2020-09-01 16:58:01 +0000
commit964da19b9b3361162209ad820eab7a957d10bc20 (patch)
treee2d3c86de0536d55bff9ece1ccd05787b08d5995 /pkg/sentry/socket
parent1e30e0a3f34aa20e8bc1c827a2c6db7566540ee8 (diff)
parent0eae08bc9e77d54c415c9d59ac3e1fa1f35f0a18 (diff)
Merge release-20200818.0-98-g0eae08bc9 (automated)
Diffstat (limited to 'pkg/sentry/socket')
-rw-r--r--pkg/sentry/socket/netstack/netstack.go45
-rw-r--r--pkg/sentry/socket/unix/socket_refs.go3
-rw-r--r--pkg/sentry/socket/unix/transport/queue_refs.go3
-rw-r--r--pkg/sentry/socket/unix/transport/unix.go10
4 files changed, 7 insertions, 54 deletions
diff --git a/pkg/sentry/socket/netstack/netstack.go b/pkg/sentry/socket/netstack/netstack.go
index 0bf21f7d8..36c17d1ba 100644
--- a/pkg/sentry/socket/netstack/netstack.go
+++ b/pkg/sentry/socket/netstack/netstack.go
@@ -482,35 +482,8 @@ func (s *socketOpsCommon) fetchReadView() *syserr.Error {
}
// Release implements fs.FileOperations.Release.
-func (s *socketOpsCommon) Release(ctx context.Context) {
- e, ch := waiter.NewChannelEntry(nil)
- s.EventRegister(&e, waiter.EventHUp|waiter.EventErr)
- defer s.EventUnregister(&e)
-
+func (s *socketOpsCommon) Release(context.Context) {
s.Endpoint.Close()
-
- // SO_LINGER option is valid only for TCP. For other socket types
- // return after endpoint close.
- if family, skType, _ := s.Type(); skType != linux.SOCK_STREAM || (family != linux.AF_INET && family != linux.AF_INET6) {
- return
- }
-
- var v tcpip.LingerOption
- if err := s.Endpoint.GetSockOpt(&v); err != nil {
- return
- }
-
- // The case for zero timeout is handled in tcp endpoint close function.
- // Close is blocked until either:
- // 1. The endpoint state is not in any of the states: FIN-WAIT1,
- // CLOSING and LAST_ACK.
- // 2. Timeout is reached.
- if v.Enabled && v.Timeout != 0 {
- t := kernel.TaskFromContext(ctx)
- start := t.Kernel().MonotonicClock().Now()
- deadline := start.Add(v.Timeout)
- t.BlockWithDeadline(ch, true, deadline)
- }
}
// Read implements fs.FileOperations.Read.
@@ -1184,16 +1157,7 @@ func getSockOptSocket(t *kernel.Task, s socket.SocketOps, ep commonEndpoint, fam
return nil, syserr.ErrInvalidArgument
}
- var v tcpip.LingerOption
- var linger linux.Linger
- if err := ep.GetSockOpt(&v); err != nil {
- return &linger, nil
- }
-
- if v.Enabled {
- linger.OnOff = 1
- }
- linger.Linger = int32(v.Timeout.Seconds())
+ linger := linux.Linger{}
return &linger, nil
case linux.SO_SNDTIMEO:
@@ -1922,10 +1886,7 @@ func setSockOptSocket(t *kernel.Task, s socket.SocketOps, ep commonEndpoint, nam
socket.SetSockOptEmitUnimplementedEvent(t, name)
}
- return syserr.TranslateNetstackError(
- ep.SetSockOpt(&tcpip.LingerOption{
- Enabled: v.OnOff != 0,
- Timeout: time.Second * time.Duration(v.Linger)}))
+ return nil
case linux.SO_DETACH_FILTER:
// optval is ignored.
diff --git a/pkg/sentry/socket/unix/socket_refs.go b/pkg/sentry/socket/unix/socket_refs.go
index a0e5d1393..39aaedc7f 100644
--- a/pkg/sentry/socket/unix/socket_refs.go
+++ b/pkg/sentry/socket/unix/socket_refs.go
@@ -1,12 +1,11 @@
package unix
import (
- "sync/atomic"
-
"fmt"
"gvisor.dev/gvisor/pkg/log"
refs_vfs1 "gvisor.dev/gvisor/pkg/refs"
"runtime"
+ "sync/atomic"
)
// ownerType is used to customize logging. Note that we use a pointer to T so
diff --git a/pkg/sentry/socket/unix/transport/queue_refs.go b/pkg/sentry/socket/unix/transport/queue_refs.go
index 21d43fc24..4c3dcd13f 100644
--- a/pkg/sentry/socket/unix/transport/queue_refs.go
+++ b/pkg/sentry/socket/unix/transport/queue_refs.go
@@ -1,12 +1,11 @@
package transport
import (
- "sync/atomic"
-
"fmt"
"gvisor.dev/gvisor/pkg/log"
refs_vfs1 "gvisor.dev/gvisor/pkg/refs"
"runtime"
+ "sync/atomic"
)
// ownerType is used to customize logging. Note that we use a pointer to T so
diff --git a/pkg/sentry/socket/unix/transport/unix.go b/pkg/sentry/socket/unix/transport/unix.go
index cc9d650fb..1200cf9bb 100644
--- a/pkg/sentry/socket/unix/transport/unix.go
+++ b/pkg/sentry/socket/unix/transport/unix.go
@@ -942,14 +942,8 @@ func (e *baseEndpoint) GetSockOptInt(opt tcpip.SockOptInt) (int, *tcpip.Error) {
// GetSockOpt implements tcpip.Endpoint.GetSockOpt.
func (e *baseEndpoint) GetSockOpt(opt tcpip.GettableSocketOption) *tcpip.Error {
- switch opt.(type) {
- case *tcpip.LingerOption:
- return nil
-
- default:
- log.Warningf("Unsupported socket option: %T", opt)
- return tcpip.ErrUnknownProtocolOption
- }
+ log.Warningf("Unsupported socket option: %T", opt)
+ return tcpip.ErrUnknownProtocolOption
}
// LastError implements Endpoint.LastError.