Commit 13d7f463 authored by Willem de Bruijn's avatar Willem de Bruijn Committed by David S. Miller
Browse files

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.

Fixes: f214f915

 ("tcp: enable MSG_ZEROCOPY")
Reported-by: default avatarMarek Majkowski <>
Signed-off-by: default avatarWillem de Bruijn <>
CC: Yuchung Cheng <>
CC: Neal Cardwell <>
CC: Soheil Hassas Yeganeh <>
CC: Alexey Kodanev <>
Acked-by: default avatarSoheil Hassas Yeganeh <>
Reviewed-by: default avatarEric Dumazet <>
Signed-off-by: default avatarDavid S. Miller <>
parent 1d16073a
......@@ -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;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment