Re: [PATCH net-next] net: tcp: Updating MSS, when the sending window is smaller than MSS.

From: Eric Dumazet
Date: Thu Jun 10 2021 - 06:04:59 EST

On Thu, Jun 10, 2021 at 8:00 AM Shuyi Cheng
<chengshuyi@xxxxxxxxxxxxxxxxx> wrote:

> Thank you very much for your reply!
> Maybe it's not clear enough that I described it. The scenario where the
> above problem occurs is precisely because the tcp server sets the size
> of RCVBUFF to be smaller after the connection is established. Here is a
> sample code that caused the problem.
> # default tcp_rmem is 87380

Except that this value is overridden at connection establishment.

tcp_rmem[1] is only a floor value, say if you want a reasonable value
even if MSS == 100

> tcpServerSocket= socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> tcpServerSocket.bind(server_addr)
> tcpServerSocket.listen()
> while True:
> connection,client_addr = tcpServerSocket.accept()
> # Shrink rmem
> connection.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 16*1024)
> Therefore, when the developer calls the sock_setsockopt function to
> reset RCVBUF, we can use sock to determine the TCP state. When in the
> connected state, it is not allowed to set RCVBUF smaller than mss.

Sure, but the application can _also_ set SO_RCVBUF before listen() or connect()

We can not have assumptions about SO_RCVBUF values and socket states.
Otherwise we would have to add some sk_rcvbuf adjustments every time
the socket state is changed.