Skip to content

Commit 5cf4a85

Browse files
vwaxdavem330
authored andcommitted
tcp: really ignore MSG_ZEROCOPY if no SO_ZEROCOPY
According to the documentation in msg_zerocopy.rst, the SO_ZEROCOPY flag was introduced because send(2) ignores unknown message flags and any legacy application which was accidentally passing the equivalent of MSG_ZEROCOPY earlier should not see any new behaviour. Before commit f214f91 ("tcp: enable MSG_ZEROCOPY"), a send(2) call which passed the equivalent of MSG_ZEROCOPY without setting SO_ZEROCOPY would succeed. However, after that commit, it fails with -ENOBUFS. So it appears that the SO_ZEROCOPY flag fails to fulfill its intended purpose. Fix it. Fixes: f214f91 ("tcp: enable MSG_ZEROCOPY") Signed-off-by: Vincent Whitchurch <[email protected]> Acked-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a162c35 commit 5cf4a85

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

net/core/skbuff.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -939,9 +939,6 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
939939

940940
WARN_ON_ONCE(!in_task());
941941

942-
if (!sock_flag(sk, SOCK_ZEROCOPY))
943-
return NULL;
944-
945942
skb = sock_omalloc(sk, 0, GFP_KERNEL);
946943
if (!skb)
947944
return NULL;

net/ipv4/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
11851185

11861186
flags = msg->msg_flags;
11871187

1188-
if (flags & MSG_ZEROCOPY && size) {
1188+
if (flags & MSG_ZEROCOPY && size && sock_flag(sk, SOCK_ZEROCOPY)) {
11891189
if (sk->sk_state != TCP_ESTABLISHED) {
11901190
err = -EINVAL;
11911191
goto out_err;

0 commit comments

Comments
 (0)