diff options
author | Willem de Bruijn <[email protected]> | 2019-01-10 14:40:33 -0500 |
---|---|---|
committer | David S. Miller <[email protected]> | 2019-01-15 21:43:18 -0800 |
commit | 13d7f46386e060df31b727c9975e38306fa51e7a (patch) | |
tree | ea9db4125b57bbd99dc0e793ee8276376f318c49 | |
parent | 1d16073a326891c2a964e4cb95bc18fbcafb5f74 (diff) |
tcp: allow MSG_ZEROCOPY transmission also in CLOSE_WAIT state
TCP transmission with MSG_ZEROCOPY fails if the peer closes its end of
the connection and so transitions this socket to CLOSE_WAIT state.
Transmission in close wait state is acceptable. Other similar tests in
the stack (e.g., in FastOpen) accept both states. Relax this test, too.
Link: https://www.mail-archive.com/[email protected]/msg276886.html
Link: https://www.mail-archive.com/[email protected]/msg227390.html
Fixes: f214f915e7db ("tcp: enable MSG_ZEROCOPY")
Reported-by: Marek Majkowski <[email protected]>
Signed-off-by: Willem de Bruijn <[email protected]>
CC: Yuchung Cheng <[email protected]>
CC: Neal Cardwell <[email protected]>
CC: Soheil Hassas Yeganeh <[email protected]>
CC: Alexey Kodanev <[email protected]>
Acked-by: Soheil Hassas Yeganeh <[email protected]>
Reviewed-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
-rw-r--r-- | net/ipv4/tcp.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 27e2f6837062..2079145a3b7c 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1186,7 +1186,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size) flags = msg->msg_flags; if (flags & MSG_ZEROCOPY && size && sock_flag(sk, SOCK_ZEROCOPY)) { - if (sk->sk_state != TCP_ESTABLISHED) { + if ((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) { err = -EINVAL; goto out_err; } |