summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-12-14 20:11:32 +0000
committergVisor bot <gvisor-bot@google.com>2020-12-14 20:11:32 +0000
commit22ae84e87a245ca815d04548b1f3ca6ae5f07af2 (patch)
tree77e7ba1afc34cb67cbf2ab3ed11ab9f612111bb5 /pkg/tcpip/transport
parent702553edddb87e4aa93a190840948539233f61fc (diff)
parent2e191cb3f72858c61943168a69b0aff0fda6ee45 (diff)
Merge release-20201208.0-43-g2e191cb3f (automated)
Diffstat (limited to 'pkg/tcpip/transport')
-rw-r--r--pkg/tcpip/transport/icmp/endpoint.go22
-rw-r--r--pkg/tcpip/transport/icmp/icmp_state_autogen.go11
-rw-r--r--pkg/tcpip/transport/packet/endpoint.go21
-rw-r--r--pkg/tcpip/transport/packet/packet_state_autogen.go11
-rw-r--r--pkg/tcpip/transport/raw/endpoint.go21
-rw-r--r--pkg/tcpip/transport/raw/raw_state_autogen.go11
-rw-r--r--pkg/tcpip/transport/tcp/endpoint.go16
-rw-r--r--pkg/tcpip/transport/tcp/tcp_state_autogen.go7
-rw-r--r--pkg/tcpip/transport/udp/endpoint.go13
-rw-r--r--pkg/tcpip/transport/udp/udp_state_autogen.go7
10 files changed, 23 insertions, 117 deletions
diff --git a/pkg/tcpip/transport/icmp/endpoint.go b/pkg/tcpip/transport/icmp/endpoint.go
index 80c01f2cb..74fe19e98 100644
--- a/pkg/tcpip/transport/icmp/endpoint.go
+++ b/pkg/tcpip/transport/icmp/endpoint.go
@@ -75,8 +75,6 @@ type endpoint struct {
route *stack.Route `state:"manual"`
ttl uint8
stats tcpip.TransportEndpointStats `state:"nosave"`
- // linger is used for SO_LINGER socket option.
- linger tcpip.LingerOption
// owner is used to get uid and gid of the packet.
owner tcpip.PacketOwner
@@ -338,15 +336,6 @@ func (e *endpoint) Peek([][]byte) (int64, *tcpip.Error) {
// SetSockOpt sets a socket option.
func (e *endpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error {
- switch v := opt.(type) {
- case *tcpip.SocketDetachFilterOption:
- return nil
-
- case *tcpip.LingerOption:
- e.mu.Lock()
- e.linger = *v
- e.mu.Unlock()
- }
return nil
}
@@ -399,16 +388,7 @@ func (e *endpoint) GetSockOptInt(opt tcpip.SockOptInt) (int, *tcpip.Error) {
// GetSockOpt implements tcpip.Endpoint.GetSockOpt.
func (e *endpoint) GetSockOpt(opt tcpip.GettableSocketOption) *tcpip.Error {
- switch o := opt.(type) {
- case *tcpip.LingerOption:
- e.mu.Lock()
- *o = e.linger
- e.mu.Unlock()
- return nil
-
- default:
- return tcpip.ErrUnknownProtocolOption
- }
+ return tcpip.ErrUnknownProtocolOption
}
func send4(r *stack.Route, ident uint16, data buffer.View, ttl uint8, owner tcpip.PacketOwner) *tcpip.Error {
diff --git a/pkg/tcpip/transport/icmp/icmp_state_autogen.go b/pkg/tcpip/transport/icmp/icmp_state_autogen.go
index 0fcfe0dd8..28a734f05 100644
--- a/pkg/tcpip/transport/icmp/icmp_state_autogen.go
+++ b/pkg/tcpip/transport/icmp/icmp_state_autogen.go
@@ -59,7 +59,6 @@ func (e *endpoint) StateFields() []string {
"shutdownFlags",
"state",
"ttl",
- "linger",
"owner",
"ops",
}
@@ -81,9 +80,8 @@ func (e *endpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(10, &e.shutdownFlags)
stateSinkObject.Save(11, &e.state)
stateSinkObject.Save(12, &e.ttl)
- stateSinkObject.Save(13, &e.linger)
- stateSinkObject.Save(14, &e.owner)
- stateSinkObject.Save(15, &e.ops)
+ stateSinkObject.Save(13, &e.owner)
+ stateSinkObject.Save(14, &e.ops)
}
func (e *endpoint) StateLoad(stateSourceObject state.Source) {
@@ -99,9 +97,8 @@ func (e *endpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(10, &e.shutdownFlags)
stateSourceObject.Load(11, &e.state)
stateSourceObject.Load(12, &e.ttl)
- stateSourceObject.Load(13, &e.linger)
- stateSourceObject.Load(14, &e.owner)
- stateSourceObject.Load(15, &e.ops)
+ stateSourceObject.Load(13, &e.owner)
+ stateSourceObject.Load(14, &e.ops)
stateSourceObject.LoadValue(6, new(int), func(y interface{}) { e.loadRcvBufSizeMax(y.(int)) })
stateSourceObject.AfterLoad(e.afterLoad)
}
diff --git a/pkg/tcpip/transport/packet/endpoint.go b/pkg/tcpip/transport/packet/endpoint.go
index 1e7debbb4..9faab4b9e 100644
--- a/pkg/tcpip/transport/packet/endpoint.go
+++ b/pkg/tcpip/transport/packet/endpoint.go
@@ -85,8 +85,6 @@ type endpoint struct {
stats tcpip.TransportEndpointStats `state:"nosave"`
bound bool
boundNIC tcpip.NICID
- // linger is used for SO_LINGER socket option.
- linger tcpip.LingerOption
// lastErrorMu protects lastError.
lastErrorMu sync.Mutex `state:"nosave"`
@@ -306,16 +304,10 @@ func (ep *endpoint) Readiness(mask waiter.EventMask) waiter.EventMask {
// used with SetSockOpt, and this function always returns
// tcpip.ErrNotSupported.
func (ep *endpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error {
- switch v := opt.(type) {
+ switch opt.(type) {
case *tcpip.SocketDetachFilterOption:
return nil
- case *tcpip.LingerOption:
- ep.mu.Lock()
- ep.linger = *v
- ep.mu.Unlock()
- return nil
-
default:
return tcpip.ErrUnknownProtocolOption
}
@@ -376,16 +368,7 @@ func (ep *endpoint) LastError() *tcpip.Error {
// GetSockOpt implements tcpip.Endpoint.GetSockOpt.
func (ep *endpoint) GetSockOpt(opt tcpip.GettableSocketOption) *tcpip.Error {
- switch o := opt.(type) {
- case *tcpip.LingerOption:
- ep.mu.Lock()
- *o = ep.linger
- ep.mu.Unlock()
- return nil
-
- default:
- return tcpip.ErrNotSupported
- }
+ return tcpip.ErrNotSupported
}
// GetSockOptInt implements tcpip.Endpoint.GetSockOptInt.
diff --git a/pkg/tcpip/transport/packet/packet_state_autogen.go b/pkg/tcpip/transport/packet/packet_state_autogen.go
index 42236056b..ccb66800b 100644
--- a/pkg/tcpip/transport/packet/packet_state_autogen.go
+++ b/pkg/tcpip/transport/packet/packet_state_autogen.go
@@ -63,7 +63,6 @@ func (ep *endpoint) StateFields() []string {
"closed",
"bound",
"boundNIC",
- "linger",
"lastError",
"ops",
}
@@ -74,7 +73,7 @@ func (ep *endpoint) StateSave(stateSinkObject state.Sink) {
var rcvBufSizeMaxValue int = ep.saveRcvBufSizeMax()
stateSinkObject.SaveValue(6, rcvBufSizeMaxValue)
var lastErrorValue string = ep.saveLastError()
- stateSinkObject.SaveValue(15, lastErrorValue)
+ stateSinkObject.SaveValue(14, lastErrorValue)
stateSinkObject.Save(0, &ep.TransportEndpointInfo)
stateSinkObject.Save(1, &ep.DefaultSocketOptionsHandler)
stateSinkObject.Save(2, &ep.netProto)
@@ -88,8 +87,7 @@ func (ep *endpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(11, &ep.closed)
stateSinkObject.Save(12, &ep.bound)
stateSinkObject.Save(13, &ep.boundNIC)
- stateSinkObject.Save(14, &ep.linger)
- stateSinkObject.Save(16, &ep.ops)
+ stateSinkObject.Save(15, &ep.ops)
}
func (ep *endpoint) StateLoad(stateSourceObject state.Source) {
@@ -106,10 +104,9 @@ func (ep *endpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(11, &ep.closed)
stateSourceObject.Load(12, &ep.bound)
stateSourceObject.Load(13, &ep.boundNIC)
- stateSourceObject.Load(14, &ep.linger)
- stateSourceObject.Load(16, &ep.ops)
+ stateSourceObject.Load(15, &ep.ops)
stateSourceObject.LoadValue(6, new(int), func(y interface{}) { ep.loadRcvBufSizeMax(y.(int)) })
- stateSourceObject.LoadValue(15, new(string), func(y interface{}) { ep.loadLastError(y.(string)) })
+ stateSourceObject.LoadValue(14, new(string), func(y interface{}) { ep.loadLastError(y.(string)) })
stateSourceObject.AfterLoad(ep.afterLoad)
}
diff --git a/pkg/tcpip/transport/raw/endpoint.go b/pkg/tcpip/transport/raw/endpoint.go
index d9a664c03..eee3f11c1 100644
--- a/pkg/tcpip/transport/raw/endpoint.go
+++ b/pkg/tcpip/transport/raw/endpoint.go
@@ -85,8 +85,6 @@ type endpoint struct {
// Connect(), and is valid only when conneted is true.
route *stack.Route `state:"manual"`
stats tcpip.TransportEndpointStats `state:"nosave"`
- // linger is used for SO_LINGER socket option.
- linger tcpip.LingerOption
// owner is used to get uid and gid of the packet.
owner tcpip.PacketOwner
@@ -532,16 +530,10 @@ func (e *endpoint) Readiness(mask waiter.EventMask) waiter.EventMask {
// SetSockOpt implements tcpip.Endpoint.SetSockOpt.
func (e *endpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error {
- switch v := opt.(type) {
+ switch opt.(type) {
case *tcpip.SocketDetachFilterOption:
return nil
- case *tcpip.LingerOption:
- e.mu.Lock()
- e.linger = *v
- e.mu.Unlock()
- return nil
-
default:
return tcpip.ErrUnknownProtocolOption
}
@@ -593,16 +585,7 @@ func (e *endpoint) SetSockOptInt(opt tcpip.SockOptInt, v int) *tcpip.Error {
// GetSockOpt implements tcpip.Endpoint.GetSockOpt.
func (e *endpoint) GetSockOpt(opt tcpip.GettableSocketOption) *tcpip.Error {
- switch o := opt.(type) {
- case *tcpip.LingerOption:
- e.mu.Lock()
- *o = e.linger
- e.mu.Unlock()
- return nil
-
- default:
- return tcpip.ErrUnknownProtocolOption
- }
+ return tcpip.ErrUnknownProtocolOption
}
// GetSockOptInt implements tcpip.Endpoint.GetSockOptInt.
diff --git a/pkg/tcpip/transport/raw/raw_state_autogen.go b/pkg/tcpip/transport/raw/raw_state_autogen.go
index 6a216ccc2..a7ecccb20 100644
--- a/pkg/tcpip/transport/raw/raw_state_autogen.go
+++ b/pkg/tcpip/transport/raw/raw_state_autogen.go
@@ -59,7 +59,6 @@ func (e *endpoint) StateFields() []string {
"closed",
"connected",
"bound",
- "linger",
"owner",
"ops",
}
@@ -81,9 +80,8 @@ func (e *endpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(10, &e.closed)
stateSinkObject.Save(11, &e.connected)
stateSinkObject.Save(12, &e.bound)
- stateSinkObject.Save(13, &e.linger)
- stateSinkObject.Save(14, &e.owner)
- stateSinkObject.Save(15, &e.ops)
+ stateSinkObject.Save(13, &e.owner)
+ stateSinkObject.Save(14, &e.ops)
}
func (e *endpoint) StateLoad(stateSourceObject state.Source) {
@@ -99,9 +97,8 @@ func (e *endpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(10, &e.closed)
stateSourceObject.Load(11, &e.connected)
stateSourceObject.Load(12, &e.bound)
- stateSourceObject.Load(13, &e.linger)
- stateSourceObject.Load(14, &e.owner)
- stateSourceObject.Load(15, &e.ops)
+ stateSourceObject.Load(13, &e.owner)
+ stateSourceObject.Load(14, &e.ops)
stateSourceObject.LoadValue(6, new(int), func(y interface{}) { e.loadRcvBufSizeMax(y.(int)) })
stateSourceObject.AfterLoad(e.afterLoad)
}
diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go
index 69512ebef..7a37c10bb 100644
--- a/pkg/tcpip/transport/tcp/endpoint.go
+++ b/pkg/tcpip/transport/tcp/endpoint.go
@@ -674,9 +674,6 @@ type endpoint struct {
// owner is used to get uid and gid of the packet.
owner tcpip.PacketOwner
- // linger is used for SO_LINGER socket option.
- linger tcpip.LingerOption
-
// ops is used to get socket level options.
ops tcpip.SocketOptions
}
@@ -1040,7 +1037,8 @@ func (e *endpoint) Close() {
return
}
- if e.linger.Enabled && e.linger.Timeout == 0 {
+ linger := e.SocketOptions().GetLinger()
+ if linger.Enabled && linger.Timeout == 0 {
s := e.EndpointState()
isResetState := s == StateEstablished || s == StateCloseWait || s == StateFinWait1 || s == StateFinWait2 || s == StateSynRecv
if isResetState {
@@ -1906,11 +1904,6 @@ func (e *endpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error {
case *tcpip.SocketDetachFilterOption:
return nil
- case *tcpip.LingerOption:
- e.LockUser()
- e.linger = *v
- e.UnlockUser()
-
default:
return nil
}
@@ -2071,11 +2064,6 @@ func (e *endpoint) GetSockOpt(opt tcpip.GettableSocketOption) *tcpip.Error {
Port: port,
}
- case *tcpip.LingerOption:
- e.LockUser()
- *o = e.linger
- e.UnlockUser()
-
default:
return tcpip.ErrUnknownProtocolOption
}
diff --git a/pkg/tcpip/transport/tcp/tcp_state_autogen.go b/pkg/tcpip/transport/tcp/tcp_state_autogen.go
index 71090ab61..8eba0efeb 100644
--- a/pkg/tcpip/transport/tcp/tcp_state_autogen.go
+++ b/pkg/tcpip/transport/tcp/tcp_state_autogen.go
@@ -217,7 +217,6 @@ func (e *endpoint) StateFields() []string {
"closed",
"txHash",
"owner",
- "linger",
"ops",
}
}
@@ -290,8 +289,7 @@ func (e *endpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(58, &e.closed)
stateSinkObject.Save(59, &e.txHash)
stateSinkObject.Save(60, &e.owner)
- stateSinkObject.Save(61, &e.linger)
- stateSinkObject.Save(62, &e.ops)
+ stateSinkObject.Save(61, &e.ops)
}
func (e *endpoint) StateLoad(stateSourceObject state.Source) {
@@ -351,8 +349,7 @@ func (e *endpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(58, &e.closed)
stateSourceObject.Load(59, &e.txHash)
stateSourceObject.Load(60, &e.owner)
- stateSourceObject.Load(61, &e.linger)
- stateSourceObject.Load(62, &e.ops)
+ stateSourceObject.Load(61, &e.ops)
stateSourceObject.LoadValue(4, new(string), func(y interface{}) { e.loadHardError(y.(string)) })
stateSourceObject.LoadValue(5, new(string), func(y interface{}) { e.loadLastError(y.(string)) })
stateSourceObject.LoadValue(13, new(EndpointState), func(y interface{}) { e.loadState(y.(EndpointState)) })
diff --git a/pkg/tcpip/transport/udp/endpoint.go b/pkg/tcpip/transport/udp/endpoint.go
index 3a2baba14..763d1d654 100644
--- a/pkg/tcpip/transport/udp/endpoint.go
+++ b/pkg/tcpip/transport/udp/endpoint.go
@@ -144,9 +144,6 @@ type endpoint struct {
// owner is used to get uid and gid of the packet.
owner tcpip.PacketOwner
- // linger is used for SO_LINGER socket option.
- linger tcpip.LingerOption
-
// ops is used to get socket level options.
ops tcpip.SocketOptions
}
@@ -768,11 +765,6 @@ func (e *endpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error {
case *tcpip.SocketDetachFilterOption:
return nil
-
- case *tcpip.LingerOption:
- e.mu.Lock()
- e.linger = *v
- e.mu.Unlock()
}
return nil
}
@@ -851,11 +843,6 @@ func (e *endpoint) GetSockOpt(opt tcpip.GettableSocketOption) *tcpip.Error {
*o = tcpip.BindToDeviceOption(e.bindToDevice)
e.mu.RUnlock()
- case *tcpip.LingerOption:
- e.mu.RLock()
- *o = e.linger
- e.mu.RUnlock()
-
default:
return tcpip.ErrUnknownProtocolOption
}
diff --git a/pkg/tcpip/transport/udp/udp_state_autogen.go b/pkg/tcpip/transport/udp/udp_state_autogen.go
index 451d8eff0..ec0a8c902 100644
--- a/pkg/tcpip/transport/udp/udp_state_autogen.go
+++ b/pkg/tcpip/transport/udp/udp_state_autogen.go
@@ -82,7 +82,6 @@ func (e *endpoint) StateFields() []string {
"multicastMemberships",
"effectiveNetProtos",
"owner",
- "linger",
"ops",
}
}
@@ -118,8 +117,7 @@ func (e *endpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(24, &e.multicastMemberships)
stateSinkObject.Save(25, &e.effectiveNetProtos)
stateSinkObject.Save(26, &e.owner)
- stateSinkObject.Save(27, &e.linger)
- stateSinkObject.Save(28, &e.ops)
+ stateSinkObject.Save(27, &e.ops)
}
func (e *endpoint) StateLoad(stateSourceObject state.Source) {
@@ -148,8 +146,7 @@ func (e *endpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(24, &e.multicastMemberships)
stateSourceObject.Load(25, &e.effectiveNetProtos)
stateSourceObject.Load(26, &e.owner)
- stateSourceObject.Load(27, &e.linger)
- stateSourceObject.Load(28, &e.ops)
+ stateSourceObject.Load(27, &e.ops)
stateSourceObject.LoadValue(6, new(int), func(y interface{}) { e.loadRcvBufSizeMax(y.(int)) })
stateSourceObject.LoadValue(19, new(string), func(y interface{}) { e.loadLastError(y.(string)) })
stateSourceObject.AfterLoad(e.afterLoad)