Skip to content

Commit d98a82a

Browse files
shytyikuba-moo
authored andcommitted
mptcp: handle defer connect in mptcp_sendmsg
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 <[email protected]> Reviewed-by: Matthieu Baerts <[email protected]> Co-developed-by: Benjamin Hesmans <[email protected]> Signed-off-by: Benjamin Hesmans <[email protected]> Signed-off-by: Dmytro Shytyi <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3242abe commit d98a82a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

net/mptcp/protocol.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
16771677
{
16781678
struct mptcp_sock *msk = mptcp_sk(sk);
16791679
struct page_frag *pfrag;
1680+
struct socket *ssock;
16801681
size_t copied = 0;
16811682
int ret = 0;
16821683
long timeo;
@@ -1690,6 +1691,27 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
16901691

16911692
lock_sock(sk);
16921693

1694+
ssock = __mptcp_nmpc_socket(msk);
1695+
if (unlikely(ssock && inet_sk(ssock->sk)->defer_connect)) {
1696+
struct sock *ssk = ssock->sk;
1697+
int copied_syn = 0;
1698+
1699+
lock_sock(ssk);
1700+
1701+
ret = tcp_sendmsg_fastopen(ssk, msg, &copied_syn, len, NULL);
1702+
copied += copied_syn;
1703+
if (ret == -EINPROGRESS && copied_syn > 0) {
1704+
/* reflect the new state on the MPTCP socket */
1705+
inet_sk_state_store(sk, inet_sk_state_load(ssk));
1706+
release_sock(ssk);
1707+
goto out;
1708+
} else if (ret) {
1709+
release_sock(ssk);
1710+
goto out;
1711+
}
1712+
release_sock(ssk);
1713+
}
1714+
16931715
timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
16941716

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

0 commit comments

Comments
 (0)