diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-01-26 16:42:14 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-01-26 16:42:14 +0000 |
commit | 894327c74e2cfe9ae4a3ec3ee53d5d14a7b90d3a (patch) | |
tree | 42e07313e97fa866608f97f18c8989bd2cbd1b3b /pkg/tcpip/transport/packet | |
parent | 7430db20e47c7d225c884279e1fea0fe33636e26 (diff) | |
parent | daf0d3f6ca3aad6f3f9ab4d762546c6dee78fa57 (diff) |
Merge release-20210112.0-90-gdaf0d3f6c (automated)
Diffstat (limited to 'pkg/tcpip/transport/packet')
-rw-r--r-- | pkg/tcpip/transport/packet/endpoint.go | 43 | ||||
-rw-r--r-- | pkg/tcpip/transport/packet/endpoint_state.go | 2 | ||||
-rw-r--r-- | pkg/tcpip/transport/packet/packet_state_autogen.go | 26 |
3 files changed, 19 insertions, 52 deletions
diff --git a/pkg/tcpip/transport/packet/endpoint.go b/pkg/tcpip/transport/packet/endpoint.go index 6fd116a98..9ca9c9780 100644 --- a/pkg/tcpip/transport/packet/endpoint.go +++ b/pkg/tcpip/transport/packet/endpoint.go @@ -79,13 +79,11 @@ type endpoint struct { rcvClosed bool // The following fields are protected by mu. - mu sync.RWMutex `state:"nosave"` - sndBufSize int - sndBufSizeMax int - closed bool - stats tcpip.TransportEndpointStats `state:"nosave"` - bound bool - boundNIC tcpip.NICID + mu sync.RWMutex `state:"nosave"` + closed bool + stats tcpip.TransportEndpointStats `state:"nosave"` + bound bool + boundNIC tcpip.NICID // lastErrorMu protects lastError. lastErrorMu sync.Mutex `state:"nosave"` @@ -106,14 +104,13 @@ func NewEndpoint(s *stack.Stack, cooked bool, netProto tcpip.NetworkProtocolNumb netProto: netProto, waiterQueue: waiterQueue, rcvBufSizeMax: 32 * 1024, - sndBufSize: 32 * 1024, } - ep.ops.InitHandler(ep) + ep.ops.InitHandler(ep, ep.stack) // Override with stack defaults. - var ss stack.SendBufferSizeOption + var ss tcpip.SendBufferSizeOption if err := s.Option(&ss); err == nil { - ep.sndBufSizeMax = ss.Default + ep.ops.SetSendBufferSize(int64(ss.Default), false /* notify */, tcpip.GetStackSendBufferLimits) } var rs stack.ReceiveBufferSizeOption @@ -320,24 +317,6 @@ func (ep *endpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error { // SetSockOptInt implements tcpip.Endpoint.SetSockOptInt. func (ep *endpoint) SetSockOptInt(opt tcpip.SockOptInt, v int) *tcpip.Error { switch opt { - case tcpip.SendBufferSizeOption: - // Make sure the send buffer size is within the min and max - // allowed. - var ss stack.SendBufferSizeOption - if err := ep.stack.Option(&ss); err != nil { - panic(fmt.Sprintf("s.Option(%#v) = %s", ss, err)) - } - if v > ss.Max { - v = ss.Max - } - if v < ss.Min { - v = ss.Min - } - ep.mu.Lock() - ep.sndBufSizeMax = v - ep.mu.Unlock() - return nil - case tcpip.ReceiveBufferSizeOption: // Make sure the receive buffer size is within the min and max // allowed. @@ -395,12 +374,6 @@ func (ep *endpoint) GetSockOptInt(opt tcpip.SockOptInt) (int, *tcpip.Error) { ep.rcvMu.Unlock() return v, nil - case tcpip.SendBufferSizeOption: - ep.mu.Lock() - v := ep.sndBufSizeMax - ep.mu.Unlock() - return v, nil - case tcpip.ReceiveBufferSizeOption: ep.rcvMu.Lock() v := ep.rcvBufSizeMax diff --git a/pkg/tcpip/transport/packet/endpoint_state.go b/pkg/tcpip/transport/packet/endpoint_state.go index e2fa96d17..61221be71 100644 --- a/pkg/tcpip/transport/packet/endpoint_state.go +++ b/pkg/tcpip/transport/packet/endpoint_state.go @@ -63,8 +63,8 @@ func (ep *endpoint) loadRcvBufSizeMax(max int) { // afterLoad is invoked by stateify. func (ep *endpoint) afterLoad() { - // StackFromEnv is a stack used specifically for save/restore. ep.stack = stack.StackFromEnv + ep.ops.InitHandler(ep, ep.stack) // TODO(gvisor.dev/173): Once bind is supported, choose the right NIC. if err := ep.stack.RegisterPacketEndpoint(0, ep.netProto, ep); err != nil { diff --git a/pkg/tcpip/transport/packet/packet_state_autogen.go b/pkg/tcpip/transport/packet/packet_state_autogen.go index ccb66800b..4a62f1e4b 100644 --- a/pkg/tcpip/transport/packet/packet_state_autogen.go +++ b/pkg/tcpip/transport/packet/packet_state_autogen.go @@ -58,8 +58,6 @@ func (ep *endpoint) StateFields() []string { "rcvBufSizeMax", "rcvBufSize", "rcvClosed", - "sndBufSize", - "sndBufSizeMax", "closed", "bound", "boundNIC", @@ -73,7 +71,7 @@ func (ep *endpoint) StateSave(stateSinkObject state.Sink) { var rcvBufSizeMaxValue int = ep.saveRcvBufSizeMax() stateSinkObject.SaveValue(6, rcvBufSizeMaxValue) var lastErrorValue string = ep.saveLastError() - stateSinkObject.SaveValue(14, lastErrorValue) + stateSinkObject.SaveValue(12, lastErrorValue) stateSinkObject.Save(0, &ep.TransportEndpointInfo) stateSinkObject.Save(1, &ep.DefaultSocketOptionsHandler) stateSinkObject.Save(2, &ep.netProto) @@ -82,12 +80,10 @@ func (ep *endpoint) StateSave(stateSinkObject state.Sink) { stateSinkObject.Save(5, &ep.rcvList) stateSinkObject.Save(7, &ep.rcvBufSize) stateSinkObject.Save(8, &ep.rcvClosed) - stateSinkObject.Save(9, &ep.sndBufSize) - stateSinkObject.Save(10, &ep.sndBufSizeMax) - stateSinkObject.Save(11, &ep.closed) - stateSinkObject.Save(12, &ep.bound) - stateSinkObject.Save(13, &ep.boundNIC) - stateSinkObject.Save(15, &ep.ops) + stateSinkObject.Save(9, &ep.closed) + stateSinkObject.Save(10, &ep.bound) + stateSinkObject.Save(11, &ep.boundNIC) + stateSinkObject.Save(13, &ep.ops) } func (ep *endpoint) StateLoad(stateSourceObject state.Source) { @@ -99,14 +95,12 @@ func (ep *endpoint) StateLoad(stateSourceObject state.Source) { stateSourceObject.Load(5, &ep.rcvList) stateSourceObject.Load(7, &ep.rcvBufSize) stateSourceObject.Load(8, &ep.rcvClosed) - stateSourceObject.Load(9, &ep.sndBufSize) - stateSourceObject.Load(10, &ep.sndBufSizeMax) - stateSourceObject.Load(11, &ep.closed) - stateSourceObject.Load(12, &ep.bound) - stateSourceObject.Load(13, &ep.boundNIC) - stateSourceObject.Load(15, &ep.ops) + stateSourceObject.Load(9, &ep.closed) + stateSourceObject.Load(10, &ep.bound) + stateSourceObject.Load(11, &ep.boundNIC) + stateSourceObject.Load(13, &ep.ops) stateSourceObject.LoadValue(6, new(int), func(y interface{}) { ep.loadRcvBufSizeMax(y.(int)) }) - stateSourceObject.LoadValue(14, new(string), func(y interface{}) { ep.loadLastError(y.(string)) }) + stateSourceObject.LoadValue(12, new(string), func(y interface{}) { ep.loadLastError(y.(string)) }) stateSourceObject.AfterLoad(ep.afterLoad) } |