summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/raw
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/raw
parente6af9699c8065e6f9f578bdf0213853dcbe07bbd (diff)
parentd34bda027309695e3e6fb6f92a5839cd1f21173e (diff)
Merge release-20200907.0-134-gd34bda027 (automated)
Diffstat (limited to 'pkg/tcpip/transport/raw')
-rw-r--r--pkg/tcpip/transport/raw/endpoint.go23
-rw-r--r--pkg/tcpip/transport/raw/raw_state_autogen.go7
2 files changed, 25 insertions, 5 deletions
diff --git a/pkg/tcpip/transport/raw/endpoint.go b/pkg/tcpip/transport/raw/endpoint.go
index fb03e6047..e37c00523 100644
--- a/pkg/tcpip/transport/raw/endpoint.go
+++ b/pkg/tcpip/transport/raw/endpoint.go
@@ -84,6 +84,8 @@ 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
@@ -511,10 +513,16 @@ func (e *endpoint) Readiness(mask waiter.EventMask) waiter.EventMask {
// SetSockOpt implements tcpip.Endpoint.SetSockOpt.
func (e *endpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error {
- switch opt.(type) {
+ switch v := 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
}
@@ -577,8 +585,17 @@ func (e *endpoint) SetSockOptInt(opt tcpip.SockOptInt, v int) *tcpip.Error {
}
// GetSockOpt implements tcpip.Endpoint.GetSockOpt.
-func (*endpoint) GetSockOpt(tcpip.GettableSocketOption) *tcpip.Error {
- return tcpip.ErrUnknownProtocolOption
+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
+ }
}
// GetSockOptBool implements tcpip.Endpoint.GetSockOptBool.
diff --git a/pkg/tcpip/transport/raw/raw_state_autogen.go b/pkg/tcpip/transport/raw/raw_state_autogen.go
index 853d60959..4930b46f4 100644
--- a/pkg/tcpip/transport/raw/raw_state_autogen.go
+++ b/pkg/tcpip/transport/raw/raw_state_autogen.go
@@ -59,6 +59,7 @@ func (x *endpoint) StateFields() []string {
"closed",
"connected",
"bound",
+ "linger",
"owner",
}
}
@@ -79,7 +80,8 @@ func (x *endpoint) StateSave(m state.Sink) {
m.Save(10, &x.closed)
m.Save(11, &x.connected)
m.Save(12, &x.bound)
- m.Save(13, &x.owner)
+ m.Save(13, &x.linger)
+ m.Save(14, &x.owner)
}
func (x *endpoint) StateLoad(m state.Source) {
@@ -95,7 +97,8 @@ func (x *endpoint) StateLoad(m state.Source) {
m.Load(10, &x.closed)
m.Load(11, &x.connected)
m.Load(12, &x.bound)
- m.Load(13, &x.owner)
+ m.Load(13, &x.linger)
+ m.Load(14, &x.owner)
m.LoadValue(6, new(int), func(y interface{}) { x.loadRcvBufSizeMax(y.(int)) })
m.AfterLoad(x.afterLoad)
}