Skip to content

A query about the update of 'msk->sk_sndbuf' #602

@Dwyane-Yan

Description

@Dwyane-Yan

Pre-requisites

  • A similar question has not been reported before.
  • mptcp.dev website does not cover my case.
  • The wiki doesn't cover my case.
  • This is not a question related to the current behavior, an issue or a feature requst: if it is, please use another template even if it is a question: we will need details about your system: kernel version, config, etc.

My question

Hi, @matttbe .
I've been looking into the update logic of 'msk->sk_sndbuf' recently, and I have a question for the community. When there is only one subflow, the sk_sndbuf of the newsk in 'mptcp_stream_accept' is not updated to msk->sk_sndbuf.

From my understanding, msk->sk_sndbuf should be updated in the following scenarios:

  • in 'tcp_new_space()' through the callback to 'subflow_write_space';
  • second, when the client connection is fully established, msk->first triggers an update via 'sk_rx_dst_set', which calls 'subflow_finish_connect' -> 'mptcp_propagate_state' -> update msk->sk_sndbuf.

However, it seems that the 'newsk' in 'mptcp_stream_accept' is overlooked. This means that when the connection is fully established and the server sends data to the client, there is a significant discrepancy between 'msk->sk_sndbuf' and 'msk->first->sk_sndbuf'. During my testing, I printed the information in 'mptcp_sendmsg' and observed something like this:

MPTCP: msk:00000000e55b09db, msk->sndbuf:20480, msk->first->sndbuf:2626560.

The reason for this discrepancy is that after the connection is established, the 'newsk->sk_sndbuf' from accept is updated in 'tcp_init_buffer_space' -> 'tcp_sndbuf_expand', but we haven't updated the server's msk->sk_sndbuf afterward. This leads to a high probability of encountering an '-EAGAIN' error when MSG_DONTWAIT is set."

With the patch below applied, the sk_sndbuf can be updated in time.

@@ -4198,6 +4200,7 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
 
                mptcp_graft_subflows(newsk);
                mptcp_rps_record_subflows(msk);
+               __mptcp_sync_sndbuf(newsk);

My question is, is this inconsistency in the sndbuf expected here? Or is this a bug in MPTCP that needs to be fixed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions