Skip to content

Commit

Permalink
mptcp: handle defer connect in mptcp_sendmsg
Browse files Browse the repository at this point in the history
When TCP_FASTOPEN_CONNECT has been set on the socket before a connect,
the defer flag is set and must be handled when sendmsg is called.

This is similar to what is done in tcp_sendmsg_locked().

Acked-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Co-developed-by: Benjamin Hesmans <benjamin.hesmans@tessares.net>
Signed-off-by: Benjamin Hesmans <benjamin.hesmans@tessares.net>
Signed-off-by: Dmytro Shytyi <dmytro@shytyi.net>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Dmytro Shytyi authored and kuba-moo committed Sep 29, 2022
1 parent 3242abe commit d98a82a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
{
struct mptcp_sock *msk = mptcp_sk(sk);
struct page_frag *pfrag;
struct socket *ssock;
size_t copied = 0;
int ret = 0;
long timeo;
Expand All @@ -1690,6 +1691,27 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)

lock_sock(sk);

ssock = __mptcp_nmpc_socket(msk);
if (unlikely(ssock && inet_sk(ssock->sk)->defer_connect)) {
struct sock *ssk = ssock->sk;
int copied_syn = 0;

lock_sock(ssk);

ret = tcp_sendmsg_fastopen(ssk, msg, &copied_syn, len, NULL);
copied += copied_syn;
if (ret == -EINPROGRESS && copied_syn > 0) {
/* reflect the new state on the MPTCP socket */
inet_sk_state_store(sk, inet_sk_state_load(ssk));
release_sock(ssk);
goto out;
} else if (ret) {
release_sock(ssk);
goto out;
}
release_sock(ssk);
}

timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);

if ((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) {
Expand Down

0 comments on commit d98a82a

Please sign in to comment.