mptcp: move msk state update to subflow_syn_recv_sock()
authorPaolo Abeni <pabeni@redhat.com>
Tue, 17 Mar 2020 14:53:34 +0000 (15:53 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Mar 2020 05:52:24 +0000 (22:52 -0700)
After commit 58b09919626b ("mptcp: create msk early"), the
msk socket is already available at subflow_syn_recv_sock()
time. Let's move there the state update, to mirror more
closely the first subflow state.

The above will also help multiple subflow supports.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mptcp/protocol.c
net/mptcp/subflow.c

index 04c3caed92dfbdc446f791dd8aebfa8f7e74efa8..e959104832efa244d7a20b417922ea9f950836b6 100644 (file)
@@ -861,6 +861,9 @@ struct sock *mptcp_sk_clone(const struct sock *sk, struct request_sock *req)
                ack_seq++;
                msk->ack_seq = ack_seq;
        }
+
+       /* will be fully established after successful MPC subflow creation */
+       inet_sk_state_store(nsk, TCP_SYN_RECV);
        bh_unlock_sock(nsk);
 
        /* keep a single reference */
@@ -916,10 +919,6 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,
                mptcp_copy_inaddrs(newsk, ssk);
                list_add(&subflow->node, &msk->conn_list);
 
-               /* will be fully established at mptcp_stream_accept()
-                * completion.
-                */
-               inet_sk_state_store(new_mptcp_sock, TCP_SYN_RECV);
                bh_unlock_sock(new_mptcp_sock);
                local_bh_enable();
        }
@@ -1256,8 +1255,6 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
                        if (!ssk->sk_socket)
                                mptcp_sock_graft(ssk, newsock);
                }
-
-               inet_sk_state_store(newsock->sk, TCP_ESTABLISHED);
        }
 
        sock_put(ssock->sk);
index 8434c7f5f71291b500c38d2f1230d442f7e49725..052d72a1d3a2da9e8927773347ab26417848e081 100644 (file)
@@ -234,6 +234,8 @@ create_child:
                        /* new mpc subflow takes ownership of the newly
                         * created mptcp socket
                         */
+                       inet_sk_state_store((struct sock *)new_msk,
+                                           TCP_ESTABLISHED);
                        ctx->conn = new_msk;
                        new_msk = NULL;
                }