summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/packet
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-09-18 03:03:37 +0000
committergVisor bot <gvisor-bot@google.com>2020-09-18 03:03:37 +0000
commite6486141a9b379f06e841b86d867ef4f09421d3a (patch)
tree5be402dc35fdf8360f474172afa6f4cbd4fa0106 /pkg/tcpip/transport/packet
parente6af9699c8065e6f9f578bdf0213853dcbe07bbd (diff)
parentd34bda027309695e3e6fb6f92a5839cd1f21173e (diff)
Merge release-20200907.0-134-gd34bda027 (automated)
Diffstat (limited to 'pkg/tcpip/transport/packet')
-rw-r--r--pkg/tcpip/transport/packet/endpoint.go23
-rw-r--r--pkg/tcpip/transport/packet/packet_state_autogen.go7
2 files changed, 25 insertions, 5 deletions
diff --git a/pkg/tcpip/transport/packet/endpoint.go b/pkg/tcpip/transport/packet/endpoint.go
index 8bd4e5e37..072601d2d 100644
--- a/pkg/tcpip/transport/packet/endpoint.go
+++ b/pkg/tcpip/transport/packet/endpoint.go
@@ -83,6 +83,8 @@ 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"`
@@ -298,10 +300,16 @@ 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 opt.(type) {
+ switch v := 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
}
@@ -366,8 +374,17 @@ func (ep *endpoint) LastError() *tcpip.Error {
}
// GetSockOpt implements tcpip.Endpoint.GetSockOpt.
-func (*endpoint) GetSockOpt(tcpip.GettableSocketOption) *tcpip.Error {
- return tcpip.ErrNotSupported
+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
+ }
}
// GetSockOptBool implements tcpip.Endpoint.GetSockOptBool.
diff --git a/pkg/tcpip/transport/packet/packet_state_autogen.go b/pkg/tcpip/transport/packet/packet_state_autogen.go
index e13dd7827..5edd9db89 100644
--- a/pkg/tcpip/transport/packet/packet_state_autogen.go
+++ b/pkg/tcpip/transport/packet/packet_state_autogen.go
@@ -62,6 +62,7 @@ func (x *endpoint) StateFields() []string {
"closed",
"bound",
"boundNIC",
+ "linger",
"lastError",
}
}
@@ -71,7 +72,7 @@ func (x *endpoint) StateSave(m state.Sink) {
var rcvBufSizeMax int = x.saveRcvBufSizeMax()
m.SaveValue(5, rcvBufSizeMax)
var lastError string = x.saveLastError()
- m.SaveValue(13, lastError)
+ m.SaveValue(14, lastError)
m.Save(0, &x.TransportEndpointInfo)
m.Save(1, &x.netProto)
m.Save(2, &x.waiterQueue)
@@ -84,6 +85,7 @@ func (x *endpoint) StateSave(m state.Sink) {
m.Save(10, &x.closed)
m.Save(11, &x.bound)
m.Save(12, &x.boundNIC)
+ m.Save(13, &x.linger)
}
func (x *endpoint) StateLoad(m state.Source) {
@@ -99,8 +101,9 @@ func (x *endpoint) StateLoad(m state.Source) {
m.Load(10, &x.closed)
m.Load(11, &x.bound)
m.Load(12, &x.boundNIC)
+ m.Load(13, &x.linger)
m.LoadValue(5, new(int), func(y interface{}) { x.loadRcvBufSizeMax(y.(int)) })
- m.LoadValue(13, new(string), func(y interface{}) { x.loadLastError(y.(string)) })
+ m.LoadValue(14, new(string), func(y interface{}) { x.loadLastError(y.(string)) })
m.AfterLoad(x.afterLoad)
}