From 560709419785fd5207573e50f4fd14746a6ec0df Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Tue, 2 May 2023 11:00:56 -0700 Subject: [PATCH] netstack: don't limit buffer size during S/R We used to check that buffer sizes didn't exceed the stack limit. However, it's perfectly valid for a single endpoint's buffer size to be larger than the systemwide settings via use of forcing sock opts (SO_SNDBUFFORCE and SO_RCVBUFFORCE). Tested with --config=gotsan. PiperOrigin-RevId: 528832810 --- pkg/tcpip/transport/tcp/endpoint_state.go | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/pkg/tcpip/transport/tcp/endpoint_state.go b/pkg/tcpip/transport/tcp/endpoint_state.go index bb2bc4c8f..623ce8cc0 100644 --- a/pkg/tcpip/transport/tcp/endpoint_state.go +++ b/pkg/tcpip/transport/tcp/endpoint_state.go @@ -136,24 +136,6 @@ func (e *endpoint) Resume(s *stack.Stack) { e.protocol = protocolFromStack(s) e.ops.InitHandler(e, e.stack, GetTCPSendBufferLimits, GetTCPReceiveBufferLimits) e.segmentQueue.thaw() - epState := EndpointState(e.origEndpointState) - switch epState { - case StateInitial, StateBound, StateListen, StateConnecting, StateEstablished: - var ss tcpip.TCPSendBufferSizeRangeOption - if err := e.stack.TransportProtocolOption(ProtocolNumber, &ss); err == nil { - sendBufferSize := e.getSendBufferSize() - if sendBufferSize < ss.Min || sendBufferSize > ss.Max { - panic(fmt.Sprintf("endpoint sendBufferSize %d is outside the min and max allowed [%d, %d]", sendBufferSize, ss.Min, ss.Max)) - } - } - - var rs tcpip.TCPReceiveBufferSizeRangeOption - if err := e.stack.TransportProtocolOption(ProtocolNumber, &rs); err == nil { - if rcvBufSize := e.ops.GetReceiveBufferSize(); rcvBufSize < int64(rs.Min) || rcvBufSize > int64(rs.Max) { - panic(fmt.Sprintf("endpoint rcvBufSize %d is outside the min and max allowed [%d, %d]", rcvBufSize, rs.Min, rs.Max)) - } - } - } bind := func() { e.mu.Lock() @@ -180,6 +162,7 @@ func (e *endpoint) Resume(s *stack.Stack) { e.setEndpointState(StateBound) } + epState := EndpointState(e.origEndpointState) switch { case epState.connected(): bind()